Browse Source

Merge branch '17.0' of git@github.com:Dolibarr/dolibarr.git into develop

Laurent Destailleur 2 years ago
parent
commit
357b69a90b

+ 6 - 6
.travis.yml

@@ -95,13 +95,13 @@ notifications:
 
 install:
 - |
-  echo "Updating Composer"
-  rm $TRAVIS_BUILD_DIR/composer.json
-  rm $TRAVIS_BUILD_DIR/composer.lock
+  echo "Updating Composer (version 2.5 is bugged and generate phpunit error Exception: Serialization of 'Closure' is not allowed)"
+  #rm $TRAVIS_BUILD_DIR/composer.json
+  #rm $TRAVIS_BUILD_DIR/composer.lock
   composer -V
-  composer self-update
-  composer -n init
-  composer -n config vendor-dir htdocs/includes
+  composer self-update 2.4.4
+  #composer -n init
+  #composer -n config vendor-dir htdocs/includes
   composer -n config -g vendor-dir htdocs/includes
   echo
 

+ 45 - 4
htdocs/core/boxes/box_members_by_type.php

@@ -92,6 +92,7 @@ class box_members_by_type extends ModeleBoxes
 
 		if ($user->rights->adherent->lire) {
 			$MembersToValidate = array();
+			$MembersPending = array();
 			$MembersValidated = array();
 			$MembersUpToDate = array();
 			$MembersExcluded = array();
@@ -169,34 +170,63 @@ class box_members_by_type extends ModeleBoxes
 					}
 					$this->db->free($result);
 				}
+				// Members pendding (Waiting for first subscription)
+				$sql = "SELECT count(*) as somme , d.fk_adherent_type";
+				$sql .= " FROM " . MAIN_DB_PREFIX . "adherent as d, " . MAIN_DB_PREFIX . "adherent_type as t";
+				$sql .= " WHERE d.entity IN (" . getEntity('adherent') . ")";
+				$sql .= " AND d.statut = 1 AND (d.datefin IS NULL AND t.subscription = 1)";
+				$sql .= " AND t.rowid = d.fk_adherent_type";
+				$sql .= " GROUP BY d.fk_adherent_type";
+
+				dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG);
+				$result = $this->db->query($sql);
+				if ($result) {
+					$num2 = $this->db->num_rows($result);
+					$i = 0;
+					while ($i < $num2) {
+						$objp = $this->db->fetch_object($result);
+						$MembersPending[$objp->fk_adherent_type] = $objp->somme;
+						$i++;
+					}
+					$this->db->free($result);
+				}
 
 				$line = 0;
 				$this->info_box_contents[$line][] = array(
 					'td' => 'class=""',
 					'text' => '',
 				);
+				// Draft
 				$labelstatus = $staticmember->LibStatut($staticmember::STATUS_DRAFT, 0, 0, 1);
 				$this->info_box_contents[$line][] = array(
 					'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"',
 					'text' => $labelstatus
 				);
-				$labelstatus = $langs->trans("UpToDate");
+				// Pending (Waiting for first subscription)
+				$labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, 0, 1);
+				$this->info_box_contents[$line][] = array(
+					'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"',
+					'text' => $labelstatus
+				);
+				// Up to date
 				$labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() + 86400, 1);
 				$this->info_box_contents[$line][] = array(
 					'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"',
 					'text' => $labelstatus,
 				);
-				$labelstatus = $langs->trans("OutOfDate");
+				// Expired
 				$labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, dol_now() - 86400, 1);
 				$this->info_box_contents[$line][] = array(
 					'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"',
 					'text' => $labelstatus
 				);
+				// Excluded
 				$labelstatus = $staticmember->LibStatut($staticmember::STATUS_EXCLUDED, 0, 0, 1);
 				$this->info_box_contents[$line][] = array(
 					'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"',
 					'text' => $labelstatus
 				);
+				// Resiliated
 				$labelstatus = $staticmember->LibStatut($staticmember::STATUS_RESILIATED, 0, 0, 1);
 				$this->info_box_contents[$line][] = array(
 					'td' => 'class="right tdoverflowmax100" width="15%" title="'.dol_escape_htmltag($labelstatus).'"',
@@ -205,7 +235,8 @@ class box_members_by_type extends ModeleBoxes
 				$line++;
 				foreach ($AdherentType as $key => $adhtype) {
 					$SumToValidate += isset($MembersToValidate[$key]) ? $MembersToValidate[$key] : 0;
-					$SumValidated += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) : 0;
+					$SumPending += isset($MembersPending[$key]) ? $MembersPending[$key] : 0;
+					$SumExpired += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) - (isset($MembersPending[$key]) ? $MembersPending[$key] : 0): 0;
 					$SumUpToDate += isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0;
 					$SumExcluded += isset($MembersExcluded[$key]) ? $MembersExcluded [$key] : 0;
 					$SumResiliated += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0;
@@ -220,6 +251,11 @@ class box_members_by_type extends ModeleBoxes
 						'text' => (isset($MembersToValidate[$key]) && $MembersToValidate[$key] > 0 ? $MembersToValidate[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_DRAFT, 1, 0, 3),
 						'asis' => 1,
 					);
+					$this->info_box_contents[$line][] = array(
+						'td' => 'class="right"',
+						'text' => (isset($MembersPending[$key]) && $MembersPending[$key] > 0 ? $MembersPending[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 0, 3),
+						'asis' => 1,
+					);
 					$this->info_box_contents[$line][] = array(
 						'td' => 'class="right"',
 						'text' => (isset($MembersUpToDate[$key]) && $MembersUpToDate[$key] > 0 ? $MembersUpToDate[$key] : '') . ' ' . $staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3),
@@ -260,6 +296,11 @@ class box_members_by_type extends ModeleBoxes
 						'text' => $SumToValidate.' '.$staticmember->LibStatut(Adherent::STATUS_DRAFT, 1, 0, 3),
 						'asis' => 1
 					);
+					$this->info_box_contents[$line][] = array(
+						'td' => 'class="liste_total right"',
+						'text' => $SumPending.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 0, 3),
+						'asis' => 1
+					);
 					$this->info_box_contents[$line][] = array(
 						'td' => 'class="liste_total right"',
 						'text' => $SumUpToDate.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, $now, 3),
@@ -267,7 +308,7 @@ class box_members_by_type extends ModeleBoxes
 					);
 					$this->info_box_contents[$line][] = array(
 						'td' => 'class="liste_total right"',
-						'text' => $SumValidated.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3),
+						'text' => $SumExpired.' '.$staticmember->LibStatut(Adherent::STATUS_VALIDATED, 1, 1, 3),
 						'asis' => 1
 					);
 					$this->info_box_contents[$line][] = array(

+ 6 - 0
htdocs/core/class/commonobject.class.php

@@ -9600,6 +9600,12 @@ abstract class CommonObject
 			}
 		}
 
+		// Delete linked object
+		$res = $this->deleteObjectLinked();
+		if ($res < 0) {
+			$error++;
+		}
+
 		if (!$error && !empty($this->isextrafieldmanaged)) {
 			$result = $this->deleteExtraFields();
 			if ($result < 0) {

+ 1 - 1
htdocs/core/class/validate.class.php

@@ -191,7 +191,7 @@ class Validate
 	 */
 	public function isMinLength($string, $length)
 	{
-		if (!strlen($string) < $length) {
+		if (strlen($string) < $length) {
 			$this->error = $this->outputLang->trans('RequireMinLength', $length);
 			return false;
 		}

+ 1 - 0
htdocs/core/js/lib_foot.js.php

@@ -110,6 +110,7 @@ if (!defined('JS_JQUERY_DISABLE_DROPDOWN')) {
                   	  console.log("toggle dropdown dt a");
 
                       //$(this).parent().parent().find(\'dd ul\').slideToggle(\'fast\');
+                      $(".ulselectedfields").removeClass("open");
 					  $(this).parent().parent().find(\'dd ul\').toggleClass("open");
 
 					  if ($(this).parent().parent().find(\'dd ul\').hasClass("open")) {

+ 1 - 1
htdocs/core/modules/modAsset.class.php

@@ -63,7 +63,7 @@ class modAsset extends DolibarrModules
 		$this->descriptionlong = "Asset module to manage assets module and depreciation charge on Dolibarr";
 
 		// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'
-		$this->version = 'experimental';
+		$this->version = 'development';
 		// Key used in llx_const table to save module status enabled/disabled (where ASSETS is value of property name of module in uppercase)
 		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
 		// Name of image file used for this module.

+ 4 - 1
htdocs/fichinter/list.php

@@ -498,7 +498,7 @@ $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfi
 $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
 
 print '<div class="div-table-responsive">';
-print '<table class="tagtable nobottomiftotal liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
+print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
 
 // Fields title search
 // --------------------------------------------------------------------
@@ -865,6 +865,9 @@ while ($i < $imaxinloop) {
 		if (!$i) {
 			$totalarray['type'][$totalarray['nbfield']] = 'duration';
 		}
+		if (!$i) {
+			$totalarray['pos'][$totalarray['nbfield']] = 'fd.duree';
+		}
 		$totalarray['val']['fd.duree'] += $obj->duree;
 	}
 	// Action column

+ 1 - 0
htdocs/langs/en_US/ticket.lang

@@ -27,6 +27,7 @@ Permission56003=Delete tickets
 Permission56004=Manage tickets
 Permission56005=See tickets of all third parties (not effective for external users, always be limited to the third party they depend on)
 
+Tickets=Tickets
 TicketDictType=Ticket - Types
 TicketDictCategory=Ticket - Groupes
 TicketDictSeverity=Ticket - Severities

+ 3 - 0
htdocs/modulebuilder/template/admin/setup.php

@@ -55,6 +55,9 @@ global $langs, $user;
 // Libraries
 require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
 require_once '../lib/mymodule.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+
+
 //require_once "../class/myclass.class.php";
 
 // Translations

+ 1 - 1
htdocs/modulebuilder/template/class/myobject.class.php

@@ -853,7 +853,7 @@ class MyObject extends CommonObject
 		//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
 
 		global $action, $hookmanager;
-		$hookmanager->initHooks(array('myobjectdao'));
+		$hookmanager->initHooks(array($this->element.'dao'));
 		$parameters = array('id'=>$this->id, 'getnomurl' => &$result);
 		$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 		if ($reshook > 0) {

+ 2 - 2
htdocs/projet/card.php

@@ -500,11 +500,11 @@ llxHeader("", $title, $help_url);
 
 $titleboth = $langs->trans("LeadsOrProjects");
 $titlenew = $langs->trans("NewLeadOrProject"); // Leads and opportunities by default
-if (empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
+if (!getDolGlobalInt('PROJECT_USE_OPPORTUNITIES')) {
 	$titleboth = $langs->trans("Projects");
 	$titlenew = $langs->trans("NewProject");
 }
-if ($conf->global->PROJECT_USE_OPPORTUNITIES == 2) {	// 2 = leads only
+if (getDolGlobalInt('PROJECT_USE_OPPORTUNITIES') == 2) { // 2 = leads only
 	$titleboth = $langs->trans("Leads");
 	$titlenew = $langs->trans("NewLead");
 }

+ 3 - 2
htdocs/projet/class/taskstats.class.php

@@ -15,6 +15,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
  */
+
 include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php';
 include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
 
@@ -195,7 +196,7 @@ class TaskStats extends Stats
 	}
 
 
-		/**
+	/**
 	 * Return the Task amount by month for a year
 	 *
 	 * @param 	int 	$year 		Year to scan
@@ -208,7 +209,7 @@ class TaskStats extends Stats
 		return array();
 	}
 
-		/**
+	/**
 	 * Return average of entity by month
 	 * @param	int     $year           year number
 	 * @return 	int						value

+ 3 - 3
htdocs/projet/tasks/time.php

@@ -191,7 +191,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x'
 	$search_project_ref = '';
 	$search_project_label = '';
 	$search_task_label = '';
-	$search_user = 0;
+	$search_user = -1;
 	$search_valuebilled = '';
 	$search_product_ref = '';
 	$toselect = array();
@@ -1446,7 +1446,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
 				print $langs->trans('InvoiceToUse');
 				print '</td>';
 				print '<td>';
-				$form->selectInvoice('invoice', '', 'invoiceid', 24, 0, $langs->trans('NewInvoice'), 1, 0, 0, 'maxwidth500', '', 'all');
+				$form->selectInvoice($projectstatic->thirdparty->id, '', 'invoiceid', 24, 0, $langs->trans('NewInvoice'), 1, 0, 0, 'maxwidth500', '', 'all');
 				print '</td>';
 				print '</tr>';
 				/*print '<tr>';
@@ -1561,7 +1561,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser
 			if (empty($search_user)) {
 				$search_user = $user->id;
 			}
-			$sql .= " AND t.fk_user = ".((int) $search_user);
+			if ($search_user > 0) $sql .= " AND t.fk_user = ".((int) $search_user);
 		}
 
 		if ($search_note) {

+ 1 - 1
htdocs/takepos/invoice.php

@@ -1094,7 +1094,7 @@ function Print(id, gift){
 function TakeposPrinting(id){
 	var receipt;
 	console.log("TakeposPrinting" + id);
-	$.get("receipt.php?facid="+id, function(data, status){
+	$.get("receipt.php?facid="+id, function(data, status) {
 		receipt=data.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '');
 		$.ajax({
 			type: "POST",

+ 1 - 1
htdocs/takepos/receipt.php

@@ -85,7 +85,7 @@ $hookmanager->initHooks(array('takeposfrontend'), $facid);
 $reshook = $hookmanager->executeHooks('TakeposReceipt', $parameters, $object);
 if (!empty($hookmanager->resPrint)) {
 	print $hookmanager->resPrint;
-	exit;
+	return;	// Receipt page can be called by the takepos/send.php page that use ob_start/end so we must use return and not exit to stop page
 }
 
 // IMPORTANT: This file is sended to 'Takepos Printing' application. Keep basic file. No external files as css, js... If you need images use absolute path.

+ 3 - 3
htdocs/takepos/send.php

@@ -69,19 +69,19 @@ if ($action == "send") {
 	include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
 	$formmail = new FormMail($db);
 	$outputlangs = new Translate('', $conf);
-	$model_id = $conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE;
+	$model_id = getDolGlobalString('TAKEPOS_EMAIL_TEMPLATE_INVOICE');
 	$arraydefaultmessage = $formmail->getEMailTemplate($db, 'facture_send', $user, $outputlangs, $model_id);
 	$subject = $arraydefaultmessage->topic;
 
 	ob_start(); // turn on output receipt
-	include 'receipt.php';
+	include DOL_DOCUMENT_ROOT.'/takepos/receipt.php';
 	$receipt = ob_get_contents(); // get the contents of the output buffer
 	ob_end_clean();
 
 	$msg = "<html>".$arraydefaultmessage->content."<br>".$receipt."</html>";
 	$sendto = $email;
 	$from = $mysoc->email;
-	$mail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1);
+	$mail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', '', '', '', '', DOL_DOCUMENT_ROOT.'/documents/takepos/temp');
 	if ($mail->error || !empty($mail->errors)) {
 		setEventMessages($mail->error, $mail->errors, 'errors');
 	} else {

+ 2 - 0
test/phpunit/AdminLibTest.php

@@ -46,6 +46,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
  */
 class AdminLibTest extends PHPUnit\Framework\TestCase
 {
+	protected $backupGlobalsBlacklist = array('conf', 'user', 'langs', 'db');
 	protected $savconf;
 	protected $savuser;
 	protected $savlangs;
@@ -69,6 +70,7 @@ class AdminLibTest extends PHPUnit\Framework\TestCase
 		$this->savdb=$db;
 
 		print __METHOD__." db->type=".$db->type." user->id=".$user->id;
+
 		//print " - db ".$db->db;
 		print "\n";
 	}

+ 2 - 2
test/phpunit/phpunittest.xml

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE phpunit SYSTEM "phpunit.dtd" >
 <phpunit
-	backupGlobals="true"
-	backupStaticAttributes="false"
+	backupGlobals="false"
+	backupStaticAttributes="true"
 	convertErrorsToExceptions="true"
 	convertNoticesToExceptions="true"
 	convertWarningsToExceptions="true"