Przeglądaj źródła

Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
Scrutinizer Auto-Fixer 5 lat temu
rodzic
commit
5f99e25c45

+ 1 - 1
htdocs/admin/emailcollector_card.php

@@ -431,7 +431,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 
 			$connection = imap_open($connectstringsource, $object->login, $object->password);
 		}
-		catch(Exception $e)
+		catch (Exception $e)
 		{
 			print $e->getMessage();
 		}

+ 14 - 14
htdocs/admin/expensereport_rules.php

@@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
 require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_rule.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("admin","other","trips","errors","dict"));
+$langs->loadLangs(array("admin", "other", "trips", "errors", "dict"));
 
 if (!$user->admin) accessforbidden();
 
@@ -96,18 +96,18 @@ if ($action == 'save')
 	{
 		$object->setValues($_POST);
 
-		if($apply_to=='U'){
+		if ($apply_to == 'U') {
 			$object->fk_user = (int) $fk_user;
-			$object->fk_usergroup=0;
-			$object->is_for_all=0;
-		}elseif($apply_to=='G'){
+			$object->fk_usergroup = 0;
+			$object->is_for_all = 0;
+		}elseif ($apply_to == 'G') {
 			$object->fk_usergroup = (int) $fk_usergroup;
-			$object->fk_user=0;
-			$object->is_for_all=0;
-		}elseif($apply_to=='A'){
-			$object->is_for_all=1;
-			$object->fk_user=0;
-			$object->fk_usergroup=0;
+			$object->fk_user = 0;
+			$object->is_for_all = 0;
+		}elseif ($apply_to == 'A') {
+			$object->is_for_all = 1;
+			$object->fk_user = 0;
+			$object->fk_usergroup = 0;
 		}
 
 		$object->dates = $dates;
@@ -145,12 +145,12 @@ $tab_rules_type = array('EX_DAY' => $langs->trans('Day'), 'EX_MON' => $langs->tr
 
 llxHeader('', $langs->trans("ExpenseReportsSetup"));
 
-$form=new Form($db);
+$form = new Form($db);
 
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
 print load_fiche_titre($langs->trans("ExpenseReportsRulesSetup"), $linkback, 'title_setup');
 
-$head=expensereport_admin_prepare_head();
+$head = expensereport_admin_prepare_head();
 dol_fiche_head($head, 'expenserules', $langs->trans("ExpenseReportsRules"), -1, 'trip');
 
 echo $langs->trans('ExpenseReportRulesDesc');

+ 118 - 118
htdocs/admin/mails.php

@@ -30,23 +30,23 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 // Load translation files required by the page
 $langs->loadLangs(array("companies", "products", "admin", "mails", "other", "errors"));
 
-$action=GETPOST('action', 'alpha');
+$action = GETPOST('action', 'alpha');
 
-if (! $user->admin) accessforbidden();
+if (!$user->admin) accessforbidden();
 
-$usersignature=$user->signature;
+$usersignature = $user->signature;
 // For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html.
 if ($action == 'test' || $action == 'send')
 {
-	$usersignature=dol_string_nohtmltag($usersignature);
+	$usersignature = dol_string_nohtmltag($usersignature);
 }
 
-$substitutionarrayfortest=array(
+$substitutionarrayfortest = array(
 '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
 '__ID__' => 'RecipientIdRecord',
 //'__EMAIL__' => 'RecipientEMail',				// Done into actions_sendmails
-'__CHECK_READ__' => (is_object($object) && is_object($object->thirdparty))?'<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>':'',
-'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))?$usersignature:''),		// Done into actions_sendmails
+'__CHECK_READ__' => (is_object($object) && is_object($object->thirdparty)) ? '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$object->thirdparty->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>' : '',
+'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails
 '__LOGIN__' => 'RecipientLogin',
 '__LASTNAME__' => 'RecipientLastname',
 '__FIRSTNAME__' => 'RecipientFirstname',
@@ -93,16 +93,16 @@ if ($action == 'update' && empty($_POST["cancel"]))
 
 
 // Actions to send emails
-$id=0;
-$actiontypecode='';     // Not an event for agenda
-$trigger_name='';       // Disable triggers
-$paramname='id';
-$mode='emailfortest';
-$trackid=(($action == 'testhtml')?"testhtml":"test");
+$id = 0;
+$actiontypecode = ''; // Not an event for agenda
+$trigger_name = ''; // Disable triggers
+$paramname = 'id';
+$mode = 'emailfortest';
+$trackid = (($action == 'testhtml') ? "testhtml" : "test");
 include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
 
-if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test')       $action='test';
-if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml')   $action='testhtml';
+if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test')       $action = 'test';
+if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml')   $action = 'testhtml';
 
 
 
@@ -113,18 +113,18 @@ if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml')   $
 
 $form = new Form($db);
 
-$linuxlike=1;
-if (preg_match('/^win/i', PHP_OS)) $linuxlike=0;
-if (preg_match('/^mac/i', PHP_OS)) $linuxlike=0;
+$linuxlike = 1;
+if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0;
+if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0;
 
-if (empty($conf->global->MAIN_MAIL_SENDMODE)) $conf->global->MAIN_MAIL_SENDMODE='mail';
-$port=! empty($conf->global->MAIN_MAIL_SMTP_PORT)?$conf->global->MAIN_MAIL_SMTP_PORT:ini_get('smtp_port');
-if (! $port) $port=25;
-$server=! empty($conf->global->MAIN_MAIL_SMTP_SERVER)?$conf->global->MAIN_MAIL_SMTP_SERVER:ini_get('SMTP');
-if (! $server) $server='127.0.0.1';
+if (empty($conf->global->MAIN_MAIL_SENDMODE)) $conf->global->MAIN_MAIL_SENDMODE = 'mail';
+$port = !empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : ini_get('smtp_port');
+if (!$port) $port = 25;
+$server = !empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : ini_get('SMTP');
+if (!$server) $server = '127.0.0.1';
 
 
-$wikihelp='EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
+$wikihelp = 'EN:Setup_EMails|FR:Paramétrage_EMails|ES:Configuración_EMails';
 llxHeader('', $langs->trans("Setup"), $wikihelp);
 
 print load_fiche_titre($langs->trans("EMailsSetup"), '', 'title_setup');
@@ -132,11 +132,11 @@ print load_fiche_titre($langs->trans("EMailsSetup"), '', 'title_setup');
 $head = email_admin_prepare_head();
 
 // List of sending methods
-$listofmethods=array();
-$listofmethods['mail']='PHP mail function';
+$listofmethods = array();
+$listofmethods['mail'] = 'PHP mail function';
 //$listofmethods['simplemail']='Simplemail class';
-$listofmethods['smtps']='SMTP/SMTPS socket library';
-$listofmethods['swiftmailer']='Swift Mailer socket library';
+$listofmethods['smtps'] = 'SMTP/SMTPS socket library';
+$listofmethods['swiftmailer'] = 'Swift Mailer socket library';
 
 
 if ($action == 'edit')
@@ -267,7 +267,7 @@ if ($action == 'edit')
 
 	// Force e-mail recipient
 	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_FORCE_SENDTO").'</td><td>';
-	print '<input class="flat" name="MAIN_MAIL_FORCE_SENDTO" size="32" value="' . (! empty($conf->global->MAIN_MAIL_FORCE_SENDTO)?$conf->global->MAIN_MAIL_FORCE_SENDTO:'') . '" />';
+	print '<input class="flat" name="MAIN_MAIL_FORCE_SENDTO" size="32" value="'.(!empty($conf->global->MAIN_MAIL_FORCE_SENDTO) ? $conf->global->MAIN_MAIL_FORCE_SENDTO : '').'" />';
 	print '</td></tr>';
 
 
@@ -299,7 +299,7 @@ if ($action == 'edit')
 
 	// Host server
 	print '<tr class="oddeven"><td>';
-	if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail')
+	if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail')
 	{
 		print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
 		print '</td><td>';
@@ -307,21 +307,21 @@ if ($action == 'edit')
 	}
 	else
 	{
-		$mainserver = (! empty($conf->global->MAIN_MAIL_SMTP_SERVER)?$conf->global->MAIN_MAIL_SMTP_SERVER:'');
-		$smtpserver = ini_get('SMTP')?ini_get('SMTP'):$langs->transnoentities("Undefined");
+		$mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : '');
+		$smtpserver = ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined");
 		if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike");
 		else print $langs->trans("MAIN_MAIL_SMTP_SERVER", $smtpserver);
 		print '</td><td>';
 		// SuperAdministrator access only
-		if (empty($conf->multicompany->enabled) || ($user->admin && ! $user->entity))
+		if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
 		{
-			print '<input class="flat" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" size="18" value="' . $mainserver . '" autocomplete="off">';
-			print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="' . $mainserver . '">';
+			print '<input class="flat" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" size="18" value="'.$mainserver.'" autocomplete="off">';
+			print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER_sav" name="MAIN_MAIL_SMTP_SERVER_sav" value="'.$mainserver.'">';
 			print '<span id="smtp_server_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
 		}
 		else
 		{
-			$text = ! empty($mainserver) ? $mainserver : $smtpserver;
+			$text = !empty($mainserver) ? $mainserver : $smtpserver;
 			$htmltext = $langs->trans("ContactSuperAdminForChange");
 			print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
 			print '<input type="hidden" id="MAIN_MAIL_SMTP_SERVER" name="MAIN_MAIL_SMTP_SERVER" value="'.$mainserver.'">';
@@ -331,7 +331,7 @@ if ($action == 'edit')
 
 	// Port
 	print '<tr class="oddeven"><td>';
-	if (! $conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail')
+	if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail')
 	{
 		print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
 		print '</td><td>';
@@ -339,21 +339,21 @@ if ($action == 'edit')
 	}
 	else
 	{
-		$mainport = (! empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : '');
-		$smtpport = ini_get('smtp_port')?ini_get('smtp_port'):$langs->transnoentities("Undefined");
+		$mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : '');
+		$smtpport = ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined");
 		if ($linuxlike) print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike");
 		else print $langs->trans("MAIN_MAIL_SMTP_PORT", $smtpport);
 		print '</td><td>';
 		// SuperAdministrator access only
-		if (empty($conf->multicompany->enabled) || ($user->admin && ! $user->entity))
+		if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
 		{
-			print '<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="' . $mainport . '">';
-			print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="' . $mainport . '">';
+			print '<input class="flat" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" size="3" value="'.$mainport.'">';
+			print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT_sav" name="MAIN_MAIL_SMTP_PORT_sav" value="'.$mainport.'">';
 			print '<span id="smtp_port_mess" class="opacitymedium">'.$langs->trans("SeeLocalSendMailSetup").'</span>';
 		}
 		else
 		{
-			$text = (! empty($mainport) ? $mainport : $smtpport);
+			$text = (!empty($mainport) ? $mainport : $smtpport);
 			$htmltext = $langs->trans("ContactSuperAdminForChange");
 			print $form->textwithpicto($text, $htmltext, 1, 'superadmin');
 			print '<input type="hidden" id="MAIN_MAIL_SMTP_PORT" name="MAIN_MAIL_SMTP_PORT" value="'.$mainport.'">';
@@ -362,14 +362,14 @@ if ($action == 'edit')
 	print '</td></tr>';
 
 	// ID
-	if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))))
+	if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))))
 	{
-		$mainstmpid=(! empty($conf->global->MAIN_MAIL_SMTPS_ID)?$conf->global->MAIN_MAIL_SMTPS_ID:'');
+		$mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID) ? $conf->global->MAIN_MAIL_SMTPS_ID : '');
 		print '<tr class="drag drop oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTPS_ID").'</td><td>';
 		// SuperAdministrator access only
 		if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
 		{
-			print '<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="' . $mainstmpid . '">';
+			print '<input class="flat" name="MAIN_MAIL_SMTPS_ID" size="32" value="'.$mainstmpid.'">';
 		}
 		else
 		{
@@ -381,16 +381,16 @@ if ($action == 'edit')
 	}
 
 	// PW
-	if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))))
+	if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))))
 	{
-		$mainsmtppw=(! empty($conf->global->MAIN_MAIL_SMTPS_PW)?$conf->global->MAIN_MAIL_SMTPS_PW:'');
+		$mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW) ? $conf->global->MAIN_MAIL_SMTPS_PW : '');
 		print '<tr class="drag drop oddeven"><td>';
 		print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_PW"), $langs->trans("WithGMailYouCanCreateADedicatedPassword"));
 		print '</td><td>';
 		// SuperAdministrator access only
 		if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity))
 		{
-			print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="' . $mainsmtppw . '" autocomplete="off">';
+			print '<input class="flat" type="password" name="MAIN_MAIL_SMTPS_PW" size="32" value="'.$mainsmtppw.'" autocomplete="off">';
 		}
 		else
 		{
@@ -403,11 +403,11 @@ if ($action == 'edit')
 
     // TLS
     print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_TLS").'</td><td>';
-	if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))))
+	if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))))
 	{
 		if (function_exists('openssl_open'))
 		{
-			print $form->selectyesno('MAIN_MAIL_EMAIL_TLS', (! empty($conf->global->MAIN_MAIL_EMAIL_TLS)?$conf->global->MAIN_MAIL_EMAIL_TLS:0), 1);
+			print $form->selectyesno('MAIN_MAIL_EMAIL_TLS', (!empty($conf->global->MAIN_MAIL_EMAIL_TLS) ? $conf->global->MAIN_MAIL_EMAIL_TLS : 0), 1);
 		}
 		else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
 	}
@@ -416,11 +416,11 @@ if ($action == 'edit')
 
 	// STARTTLS
 	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_STARTTLS").'</td><td>';
-	if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))))
+	if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('smtps', 'swiftmailer'))))
 	{
 		if (function_exists('openssl_open'))
 		{
-			print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS', (! empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS)?$conf->global->MAIN_MAIL_EMAIL_STARTTLS:0), 1);
+			print $form->selectyesno('MAIN_MAIL_EMAIL_STARTTLS', (!empty($conf->global->MAIN_MAIL_EMAIL_STARTTLS) ? $conf->global->MAIN_MAIL_EMAIL_STARTTLS : 0), 1);
 		}
 		else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
 	}
@@ -429,11 +429,11 @@ if ($action == 'edit')
 
 	// DKIM
 	print '<tr class="oddeven dkim"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_ENABLED").'</td><td>';
-	if (! empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('swiftmailer'))))
+	if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE) && in_array($conf->global->MAIN_MAIL_SENDMODE, array('swiftmailer'))))
 	{
 		if (function_exists('openssl_open'))
 		{
-			print $form->selectyesno('MAIN_MAIL_EMAIL_DKIM_ENABLED', (! empty($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED)?$conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED:0), 1);
+			print $form->selectyesno('MAIN_MAIL_EMAIL_DKIM_ENABLED', (!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED : 0), 1);
 		}
 		else print yn(0).' ('.$langs->trans("YourPHPDoesNotHaveSSLSupport").')';
 	}
@@ -442,31 +442,31 @@ if ($action == 'edit')
 
     // DKIM Domain
     print '<tr class="oddeven dkim"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").'</td>';
-    print '<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_DOMAIN" name="MAIN_MAIL_EMAIL_DKIM_DOMAIN" size="32" value="' . (! empty($conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN)?$conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN:'');
+    print '<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_DOMAIN" name="MAIN_MAIL_EMAIL_DKIM_DOMAIN" size="32" value="'.(!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN : '');
     print '"></td></tr>';
 
     // DKIM Selector
     print '<tr class="oddeven dkim"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").'</td>';
-    print '<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_SELECTOR" name="MAIN_MAIL_EMAIL_DKIM_SELECTOR" size="32" value="' . (! empty($conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR)?$conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR:'');
+    print '<td><input class="flat" id="MAIN_MAIL_EMAIL_DKIM_SELECTOR" name="MAIN_MAIL_EMAIL_DKIM_SELECTOR" size="32" value="'.(!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR : '');
     print '"></td></tr>';
 
     // DKIM PRIVATE KEY
     print '<tr class="oddeven dkim"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").'</td>';
-    print '<td><textarea id="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" name="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" rows="15" cols="100">' . (! empty($conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY)?$conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY:'').'</textarea>';
+    print '<td><textarea id="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" name="MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY" rows="15" cols="100">'.(!empty($conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY) ? $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY : '').'</textarea>';
     print '</td></tr>';
 
     // Separator
 	print '<tr class="oddeven"><td colspan="2">&nbsp;</td></tr>';
 
 	// From
-	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).'</td>';
-	print '<td><input class="flat" name="MAIN_MAIL_EMAIL_FROM" size="32" value="' . (! empty($conf->global->MAIN_MAIL_EMAIL_FROM)?$conf->global->MAIN_MAIL_EMAIL_FROM:'');
+	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).'</td>';
+	print '<td><input class="flat" name="MAIN_MAIL_EMAIL_FROM" size="32" value="'.(!empty($conf->global->MAIN_MAIL_EMAIL_FROM) ? $conf->global->MAIN_MAIL_EMAIL_FROM : '');
 	print '"></td></tr>';
 
 	// Default from type
 	$liste = array();
 	$liste['user'] = $langs->trans('UserEmail');
-	$liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL)?$langs->trans("NotDefined"):$conf->global->MAIN_INFO_SOCIETE_MAIL).')';
+	$liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')';
 	/*
 	$sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE active = 1';
 	$resql = $db->query($sql);
@@ -495,12 +495,12 @@ if ($action == 'edit')
 
 	// From
 	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
-	print '<td><input class="flat" name="MAIN_MAIL_ERRORS_TO" size="32" value="' . (! empty($conf->global->MAIN_MAIL_ERRORS_TO)?$conf->global->MAIN_MAIL_ERRORS_TO:'');
+	print '<td><input class="flat" name="MAIN_MAIL_ERRORS_TO" size="32" value="'.(!empty($conf->global->MAIN_MAIL_ERRORS_TO) ? $conf->global->MAIN_MAIL_ERRORS_TO : '');
 	print '"></td></tr>';
 
 	// Autocopy to
 	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>';
-	print '<td><input class="flat" name="MAIN_MAIL_AUTOCOPY_TO" size="32" value="' . (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)?$conf->global->MAIN_MAIL_AUTOCOPY_TO:'');
+	print '<td><input class="flat" name="MAIN_MAIL_AUTOCOPY_TO" size="32" value="'.(!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO) ? $conf->global->MAIN_MAIL_AUTOCOPY_TO : '');
 	print '"></td></tr>';
 
 	print '</table>';
@@ -527,14 +527,14 @@ else
 
 	// Disable
 	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_DISABLE_ALL_MAILS").'</td><td>'.yn($conf->global->MAIN_DISABLE_ALL_MAILS);
-	if (! empty($conf->global->MAIN_DISABLE_ALL_MAILS)) print img_warning($langs->trans("Disabled"));
+	if (!empty($conf->global->MAIN_DISABLE_ALL_MAILS)) print img_warning($langs->trans("Disabled"));
 	print '</td></tr>';
 
 	// Force e-mail recipient
 	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_FORCE_SENDTO").'</td><td>'.$conf->global->MAIN_MAIL_FORCE_SENDTO;
-	if (! empty($conf->global->MAIN_MAIL_FORCE_SENDTO))
+	if (!empty($conf->global->MAIN_MAIL_FORCE_SENDTO))
 	{
-		if (! isValidEmail($conf->global->MAIN_MAIL_FORCE_SENDTO)) print img_warning($langs->trans("ErrorBadEMail"));
+		if (!isValidEmail($conf->global->MAIN_MAIL_FORCE_SENDTO)) print img_warning($langs->trans("ErrorBadEMail"));
 		else print img_warning($langs->trans("RecipientEmailsWillBeReplacedWithThisValue"));
 	}
 	print '</td></tr>';
@@ -547,8 +547,8 @@ else
 
 	// Method
 	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SENDMODE").'</td><td>';
-	$text=$listofmethods[$conf->global->MAIN_MAIL_SENDMODE];
-	if (empty($text)) $text=$langs->trans("Undefined").img_warning();
+	$text = $listofmethods[$conf->global->MAIN_MAIL_SENDMODE];
+	if (empty($text)) $text = $langs->trans("Undefined").img_warning();
 	print $text;
 	print '</td></tr>';
 
@@ -559,7 +559,7 @@ else
 	}
 	else
 	{
-		print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP')?ini_get('SMTP'):$langs->transnoentities("Undefined")).'</td><td>'.(! empty($conf->global->MAIN_MAIL_SMTP_SERVER)?$conf->global->MAIN_MAIL_SMTP_SERVER:'').'</td></tr>';
+		print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_SERVER", ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_SERVER) ? $conf->global->MAIN_MAIL_SMTP_SERVER : '').'</td></tr>';
 	}
 
 	// Port
@@ -569,7 +569,7 @@ else
 	}
 	else
 	{
-		print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port')?ini_get('smtp_port'):$langs->transnoentities("Undefined")).'</td><td>'.(! empty($conf->global->MAIN_MAIL_SMTP_PORT)?$conf->global->MAIN_MAIL_SMTP_PORT:'').'</td></tr>';
+		print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).'</td><td>'.(!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : '').'</td></tr>';
 	}
 
 	// SMTPS ID
@@ -628,17 +628,17 @@ else
 
 	    // Domain
 	    print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_DOMAIN").'</td>';
-	    print '<td>' . $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN;
+	    print '<td>'.$conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN;
 	    print '</td></tr>';
 
 	    // Selector
 	    print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_SELECTOR").'</td>';
-	    print '<td>' . $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR;
+	    print '<td>'.$conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR;
 	    print '</td></tr>';
 
 	    // PRIVATE KEY
 	    print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY").'</td>';
-	    print '<td>' . $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY;
+	    print '<td>'.$conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY;
 	    print '</td></tr>';
 	}
 
@@ -646,22 +646,22 @@ else
 	print '<tr class="oddeven"><td colspan="2">&nbsp;</td></tr>';
 
 	// From
-	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).'</td>';
+	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_EMAIL_FROM", ini_get('sendmail_from') ?ini_get('sendmail_from') : $langs->transnoentities("Undefined")).'</td>';
 	print '<td>'.$conf->global->MAIN_MAIL_EMAIL_FROM;
-	if (! empty($conf->global->MAIN_MAIL_EMAIL_FROM) && ! isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail"));
+	if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && !isValidEmail($conf->global->MAIN_MAIL_EMAIL_FROM)) print img_warning($langs->trans("ErrorBadEMail"));
 	print '</td></tr>';
 
 	// Default from type
 	$liste = array();
 	$liste['user'] = $langs->trans('UserEmail');
-	$liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL)?$langs->trans("NotDefined"):$conf->global->MAIN_INFO_SOCIETE_MAIL).')';
-	$sql='SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE active = 1';
+	$liste['company'] = $langs->trans('CompanyEmail').' ('.(empty($conf->global->MAIN_INFO_SOCIETE_MAIL) ? $langs->trans("NotDefined") : $conf->global->MAIN_INFO_SOCIETE_MAIL).')';
+	$sql = 'SELECT rowid, label, email FROM '.MAIN_DB_PREFIX.'c_email_senderprofile WHERE active = 1';
 	$resql = $db->query($sql);
 	if ($resql)
 	{
 		$num = $db->num_rows($resql);
-		$i=0;
-		while($i < $num)
+		$i = 0;
+		while ($i < $num)
 		{
 			$obj = $db->fetch_object($resql);
 			if ($obj)
@@ -705,16 +705,16 @@ else
 	// Errors To
 	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_ERRORS_TO").'</td>';
 	print '<td>'.$conf->global->MAIN_MAIL_ERRORS_TO;
-	if (! empty($conf->global->MAIN_MAIL_ERRORS_TO) && ! isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print img_warning($langs->trans("ErrorBadEMail"));
+	if (!empty($conf->global->MAIN_MAIL_ERRORS_TO) && !isValidEmail($conf->global->MAIN_MAIL_ERRORS_TO)) print img_warning($langs->trans("ErrorBadEMail"));
 	print '</td></tr>';
 
 	// Autocopy to
 	print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_AUTOCOPY_TO").'</td>';
 	print '<td>';
-	if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO))
+	if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO))
 	{
 		print $conf->global->MAIN_MAIL_AUTOCOPY_TO;
-		if (! isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print img_warning($langs->trans("ErrorBadEMail"));
+		if (!isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print img_warning($langs->trans("ErrorBadEMail"));
 	}
 	else
 	{
@@ -732,7 +732,7 @@ else
 
 	print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit">'.$langs->trans("Modify").'</a>';
 
-	if ($conf->global->MAIN_MAIL_SENDMODE != 'mail' || ! $linuxlike)
+	if ($conf->global->MAIN_MAIL_SENDMODE != 'mail' || !$linuxlike)
 	{
 		if (function_exists('fsockopen') && $port && $server)
 		{
@@ -746,7 +746,7 @@ else
 
 	print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&mode=init#formmailbeforetitle">'.$langs->trans("DoTestSend").'</a>';
 
-	if (! empty($conf->fckeditor->enabled))
+	if (!empty($conf->fckeditor->enabled))
 	{
 		print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=testhtml&mode=init#formmailbeforetitle">'.$langs->trans("DoTestSendHTML").'</a>';
 	}
@@ -770,17 +770,17 @@ else
 		print info_admin($langs->trans("SendmailOptionMayHurtBuggedMTA"));
 	}
 
-	if (! in_array($action, array('testconnect', 'test', 'testhtml')))
+	if (!in_array($action, array('testconnect', 'test', 'testhtml')))
 	{
 		$text = '';
 		if ($conf->global->MAIN_MAIL_SENDMODE == 'mail')
 		{
-			$text.= $langs->trans("WarningPHPMail");
+			$text .= $langs->trans("WarningPHPMail");
 		}
 		//$conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS='1.2.3.4';
-		if (! empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS))
+		if (!empty($conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS))
 		{
-			$text.= ($text?'<br>':'').$langs->trans("WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
+			$text .= ($text ? '<br>' : '').$langs->trans("WarningPHPMail2", $conf->global->MAIN_EXTERNAL_SMTP_CLIENT_IP_ADDRESS);
 		}
 		if ($text) print info_admin($text);
 	}
@@ -792,7 +792,7 @@ else
 
 		include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
 		$mail = new CMailFile('', '', '', '');
-		$result=$mail->check_server_port($server, $port);
+		$result = $mail->check_server_port($server, $port);
 		if ($result) print '<div class="ok">'.$langs->trans("ServerAvailableOnIPOrPort", $server, $port).'</div>';
 		else
 		{
@@ -811,45 +811,45 @@ else
 	if ($action == 'test' || $action == 'testhtml')
 	{
 		print '<div id="formmailbeforetitle" name="formmailbeforetitle"></div>';
-		print load_fiche_titre($action == 'testhtml'?$langs->trans("DoTestSendHTML"):$langs->trans("DoTestSend"));
+		print load_fiche_titre($action == 'testhtml' ? $langs->trans("DoTestSendHTML") : $langs->trans("DoTestSend"));
 
 		dol_fiche_head('');
 
 		// Cree l'objet formulaire mail
 		include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
 		$formmail = new FormMail($db);
-		$formmail->trackid=(($action == 'testhtml')?"testhtml":"test");
-		$formmail->fromname = (isset($_POST['fromname'])?$_POST['fromname']:$conf->global->MAIN_MAIL_EMAIL_FROM);
-		$formmail->frommail = (isset($_POST['frommail'])?$_POST['frommail']:$conf->global->MAIN_MAIL_EMAIL_FROM);
-		$formmail->fromid=$user->id;
-		$formmail->fromalsorobot=1;
-		$formmail->fromtype=(GETPOSTISSET('fromtype')?GETPOST('fromtype', 'aZ09'):(!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE)?$conf->global->MAIN_MAIL_DEFAULT_FROMTYPE:'user'));
-		$formmail->withfromreadonly=1;
-		$formmail->withsubstit=1;
-		$formmail->withfrom=1;
-		$formmail->witherrorsto=1;
-		$formmail->withto=(! empty($_POST['sendto'])?$_POST['sendto']:($user->email?$user->email:1));
-		$formmail->withtocc=(! empty($_POST['sendtocc'])?$_POST['sendtocc']:1);       // ! empty to keep field if empty
-		$formmail->withtoccc=(! empty($_POST['sendtoccc'])?$_POST['sendtoccc']:1);    // ! empty to keep field if empty
-		$formmail->withtopic=(isset($_POST['subject'])?$_POST['subject']:$langs->trans("Test"));
-		$formmail->withtopicreadonly=0;
-		$formmail->withfile=2;
-		$formmail->withbody=(isset($_POST['message'])?$_POST['message']:($action == 'testhtml'?$langs->transnoentities("PredefinedMailTestHtml"):$langs->transnoentities("PredefinedMailTest")));
-		$formmail->withbodyreadonly=0;
-		$formmail->withcancel=1;
-		$formmail->withdeliveryreceipt=1;
-		$formmail->withfckeditor=($action == 'testhtml'?1:0);
-		$formmail->ckeditortoolbar='dolibarr_mailings';
+		$formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test");
+		$formmail->fromname = (isset($_POST['fromname']) ? $_POST['fromname'] : $conf->global->MAIN_MAIL_EMAIL_FROM);
+		$formmail->frommail = (isset($_POST['frommail']) ? $_POST['frommail'] : $conf->global->MAIN_MAIL_EMAIL_FROM);
+		$formmail->fromid = $user->id;
+		$formmail->fromalsorobot = 1;
+		$formmail->fromtype = (GETPOSTISSET('fromtype') ?GETPOST('fromtype', 'aZ09') : (!empty($conf->global->MAIN_MAIL_DEFAULT_FROMTYPE) ? $conf->global->MAIN_MAIL_DEFAULT_FROMTYPE : 'user'));
+		$formmail->withfromreadonly = 1;
+		$formmail->withsubstit = 1;
+		$formmail->withfrom = 1;
+		$formmail->witherrorsto = 1;
+		$formmail->withto = (!empty($_POST['sendto']) ? $_POST['sendto'] : ($user->email ? $user->email : 1));
+		$formmail->withtocc = (!empty($_POST['sendtocc']) ? $_POST['sendtocc'] : 1); // ! empty to keep field if empty
+		$formmail->withtoccc = (!empty($_POST['sendtoccc']) ? $_POST['sendtoccc'] : 1); // ! empty to keep field if empty
+		$formmail->withtopic = (isset($_POST['subject']) ? $_POST['subject'] : $langs->trans("Test"));
+		$formmail->withtopicreadonly = 0;
+		$formmail->withfile = 2;
+		$formmail->withbody = (isset($_POST['message']) ? $_POST['message'] : ($action == 'testhtml' ? $langs->transnoentities("PredefinedMailTestHtml") : $langs->transnoentities("PredefinedMailTest")));
+		$formmail->withbodyreadonly = 0;
+		$formmail->withcancel = 1;
+		$formmail->withdeliveryreceipt = 1;
+		$formmail->withfckeditor = ($action == 'testhtml' ? 1 : 0);
+		$formmail->ckeditortoolbar = 'dolibarr_mailings';
 		// Tableau des substitutions
-		$formmail->substit=$substitutionarrayfortest;
+		$formmail->substit = $substitutionarrayfortest;
 		// Tableau des parametres complementaires du post
-		$formmail->param["action"]="send";
-		$formmail->param["models"]="body";
-		$formmail->param["mailid"]=0;
-		$formmail->param["returnurl"]=$_SERVER["PHP_SELF"];
+		$formmail->param["action"] = "send";
+		$formmail->param["models"] = "body";
+		$formmail->param["mailid"] = 0;
+		$formmail->param["returnurl"] = $_SERVER["PHP_SELF"];
 
 		// Init list of files
-		if (GETPOST("mode", "aZ09")=='init')
+		if (GETPOST("mode", "aZ09") == 'init')
 		{
 			$formmail->clear_attached_files();
 		}

+ 8 - 8
htdocs/bom/bom_agenda.php

@@ -32,32 +32,32 @@ require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom.lib.php';
 
 
 // Load translation files required by the page
-$langs->loadLangs(array("mrp","other"));
+$langs->loadLangs(array("mrp", "other"));
 
 // Get parameters
-$id			= GETPOST('id', 'int');
+$id = GETPOST('id', 'int');
 $ref        = GETPOST('ref', 'alpha');
-$action		= GETPOST('action', 'alpha');
+$action = GETPOST('action', 'alpha');
 $cancel     = GETPOST('cancel', 'aZ09');
 $backtopage = GETPOST('backtopage', 'alpha');
 
 if (GETPOST('actioncode', 'array'))
 {
-    $actioncode=GETPOST('actioncode', 'array', 3);
-    if (! count($actioncode)) $actioncode='0';
+    $actioncode = GETPOST('actioncode', 'array', 3);
+    if (!count($actioncode)) $actioncode = '0';
 }
 else
 {
-    $actioncode=GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
+    $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
 }
-$search_agenda_label=GETPOST('search_agenda_label');
+$search_agenda_label = GETPOST('search_agenda_label');
 
 // Security check - Protection if external user
 //if ($user->socid > 0) accessforbidden();
 //if ($user->socid > 0) $socid = $user->socid;
 //$result = restrictedArea($user, 'bom', $id);
 
-$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
 $sortfield = GETPOST("sortfield", 'alpha');
 $sortorder = GETPOST("sortorder", 'alpha');
 $page = GETPOST("page", 'int');

+ 5 - 5
htdocs/bom/bom_card.php

@@ -625,28 +625,28 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
     		// Close / Cancel
     		if ($permissiontoadd && $object->status == $object::STATUS_VALIDATED)
     		{
-    			print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=close">' . $langs->trans("Disable") . '</a>';
+    			print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close">'.$langs->trans("Disable").'</a>';
     		}
 
     		// Re-open
     		if ($permissiontoadd && $object->status == $object::STATUS_CANCELED)
     		{
-    			print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=reopen">' . $langs->trans("ReOpen") . '</a>';
+    			print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen">'.$langs->trans("ReOpen").'</a>';
     		}
 
     		// Create MO
     		if ($conf->mrp->enabled)
     		{
-	    		if ($object->status == $object::STATUS_VALIDATED && ! empty($user->rights->mrp->write))
+	    		if ($object->status == $object::STATUS_VALIDATED && !empty($user->rights->mrp->write))
 	    		{
-	    			print '<a class="butAction" href="' . DOL_URL_ROOT.'/mrp/mo_card.php?action=create&fk_bom='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">' . $langs->trans("CreateMO") . '</a>';
+	    			print '<a class="butAction" href="'.DOL_URL_ROOT.'/mrp/mo_card.php?action=create&fk_bom='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("CreateMO").'</a>';
 	    		}
     		}
 
     		// Clone
     		if ($permissiontoadd)
     		{
-    			print '<a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=clone&object=bom">' . $langs->trans("ToClone") . '</a>';
+    			print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=clone&object=bom">'.$langs->trans("ToClone").'</a>';
     		}
 
     		/*

+ 4 - 4
htdocs/comm/remx.php

@@ -745,7 +745,7 @@ if ($socid > 0)
 		$sql .= " , ".MAIN_DB_PREFIX."facturedet as fc";
 		$sql .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc";
 		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid";
-		$sql .= " WHERE rc.fk_soc =". $object->id;
+		$sql .= " WHERE rc.fk_soc =".$object->id;
 		$sql .= " AND rc.fk_facture_line = fc.rowid";
 		$sql .= " AND fc.fk_facture = f.rowid";
 		$sql .= " AND rc.fk_user = u.rowid";
@@ -763,7 +763,7 @@ if ($socid > 0)
 		$sql2 .= " , ".MAIN_DB_PREFIX."user as u";
 		$sql2 .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc";
 		$sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."facture as fa ON rc.fk_facture_source = fa.rowid";
-		$sql2 .= " WHERE rc.fk_soc =". $object->id;
+		$sql2 .= " WHERE rc.fk_soc =".$object->id;
 		$sql2 .= " AND rc.fk_facture = f.rowid";
 		$sql2 .= " AND rc.fk_user = u.rowid";
 		$sql2 .= " AND rc.discount_type = 0"; // Eliminate supplier discounts
@@ -920,7 +920,7 @@ if ($socid > 0)
 		$sql .= " , ".MAIN_DB_PREFIX."facture_fourn_det as fc";
 		$sql .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc";
 		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid";
-		$sql .= " WHERE rc.fk_soc =". $object->id;
+		$sql .= " WHERE rc.fk_soc =".$object->id;
 		$sql .= " AND rc.fk_invoice_supplier_line = fc.rowid";
 		$sql .= " AND fc.fk_facture_fourn = f.rowid";
 		$sql .= " AND rc.fk_user = u.rowid";
@@ -938,7 +938,7 @@ if ($socid > 0)
 		$sql2 .= " , ".MAIN_DB_PREFIX."user as u";
 		$sql2 .= " , ".MAIN_DB_PREFIX."societe_remise_except as rc";
 		$sql2 .= " LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as fa ON rc.fk_invoice_supplier_source = fa.rowid";
-		$sql2 .= " WHERE rc.fk_soc =". $object->id;
+		$sql2 .= " WHERE rc.fk_soc =".$object->id;
 		$sql2 .= " AND rc.fk_invoice_supplier = f.rowid";
 		$sql2 .= " AND rc.fk_user = u.rowid";
 		$sql2 .= " AND rc.discount_type = 1"; // Eliminate customer discounts

+ 191 - 191
htdocs/compta/bank/graph.php

@@ -31,22 +31,22 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
 // Load translation files required by the page
 $langs->loadLangs(array('banks', 'categories'));
 
-$WIDTH=DolGraph::getDefaultGraphSizeForStats('width', 768);
-$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height', 200);
+$WIDTH = DolGraph::getDefaultGraphSizeForStats('width', 768);
+$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height', 200);
 
 // Security check
 if (isset($_GET["account"]) || isset($_GET["ref"]))
 {
-	$id = isset($_GET["account"])?$_GET["account"]:(isset($_GET["ref"])?$_GET["ref"]:'');
+	$id = isset($_GET["account"]) ? $_GET["account"] : (isset($_GET["ref"]) ? $_GET["ref"] : '');
 }
-$fieldid = isset($_GET["ref"])?'ref':'rowid';
-if ($user->socid) $socid=$user->socid;
-$result=restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid);
+$fieldid = isset($_GET["ref"]) ? 'ref' : 'rowid';
+if ($user->socid) $socid = $user->socid;
+$result = restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '', $fieldid);
 
-$account=GETPOST("account");
-$mode='standard';
-if (GETPOST("mode") == 'showalltime') $mode='showalltime';
-$error=0;
+$account = GETPOST("account");
+$mode = 'standard';
+if (GETPOST("mode") == 'showalltime') $mode = 'showalltime';
+$error = 0;
 
 
 /*
@@ -63,22 +63,22 @@ $datetime = dol_now();
 $year = dol_print_date($datetime, "%Y");
 $month = dol_print_date($datetime, "%m");
 $day = dol_print_date($datetime, "%d");
-if (GETPOST("year"))  $year=sprintf("%04d", GETPOST("year"));
-if (GETPOST("month")) $month=sprintf("%02d", GETPOST("month"));
+if (GETPOST("year"))  $year = sprintf("%04d", GETPOST("year"));
+if (GETPOST("month")) $month = sprintf("%02d", GETPOST("month"));
 
 
 $object = new Account($db);
-if ($_GET["account"] && ! preg_match('/,/', $_GET["account"]))	// if for a particular account and not a list
+if ($_GET["account"] && !preg_match('/,/', $_GET["account"]))	// if for a particular account and not a list
 {
-	$result=$object->fetch(GETPOST("account", "int"));
+	$result = $object->fetch(GETPOST("account", "int"));
 }
 if ($_GET["ref"])
 {
-	$result=$object->fetch(0, GETPOST("ref"));
-	$account=$object->id;
+	$result = $object->fetch(0, GETPOST("ref"));
+	$account = $object->id;
 }
 
-$result=dol_mkdir($conf->bank->dir_temp);
+$result = dol_mkdir($conf->bank->dir_temp);
 if ($result < 0)
 {
 	$langs->load("errors");
@@ -89,11 +89,11 @@ else
 {
 	// Calcul $min and $max
 	$sql = "SELECT MIN(b.datev) as min, MAX(b.datev) as max";
-	$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
-	$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
-	$sql.= " WHERE b.fk_account = ba.rowid";
-	$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
-	if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
+	$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
+	$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
+	$sql .= " WHERE b.fk_account = ba.rowid";
+	$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
+	if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
 
 	$resql = $db->query($sql);
 	if ($resql)
@@ -109,7 +109,7 @@ else
 	}
 	if (empty($min)) $min = dol_now() - 3600 * 24;
 
-	$log="graph.php: min=".$min." max=".$max;
+	$log = "graph.php: min=".$min." max=".$max;
 	dol_syslog($log);
 
 
@@ -120,24 +120,24 @@ else
 		// Loading table $amounts
 		$amounts = array();
 
-		$monthnext = $month+1;
+		$monthnext = $month + 1;
 		$yearnext = $year;
 		if ($monthnext > 12)
 		{
-			$monthnext=1;
+			$monthnext = 1;
 			$yearnext++;
 		}
 
 		$sql = "SELECT date_format(b.datev,'%Y%m%d')";
-		$sql.= ", SUM(b.amount)";
-		$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
-		$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
-		$sql.= " WHERE b.fk_account = ba.rowid";
-		$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
-		$sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'";
-		$sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
-		if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
-		$sql.= " GROUP BY date_format(b.datev,'%Y%m%d')";
+		$sql .= ", SUM(b.amount)";
+		$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
+		$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
+		$sql .= " WHERE b.fk_account = ba.rowid";
+		$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
+		$sql .= " AND b.datev >= '".$year."-".$month."-01 00:00:00'";
+		$sql .= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
+		if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
+		$sql .= " GROUP BY date_format(b.datev,'%Y%m%d')";
 
 		$resql = $db->query($sql);
 		if ($resql)
@@ -161,12 +161,12 @@ else
 		$solde = 0;
 
 		$sql = "SELECT SUM(b.amount)";
-		$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
-		$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
-		$sql.= " WHERE b.fk_account = ba.rowid";
-		$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
-		$sql.= " AND b.datev < '".$year."-".sprintf("%02s", $month)."-01'";
-		if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
+		$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
+		$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
+		$sql .= " WHERE b.fk_account = ba.rowid";
+		$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
+		$sql .= " AND b.datev < '".$year."-".sprintf("%02s", $month)."-01'";
+		if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
 
 		$resql = $db->query($sql);
 		if ($resql)
@@ -225,36 +225,36 @@ else
 		//exit;
 
 		// Fabrication tableau 1
-		$file= $conf->bank->dir_temp."/balance".$account."-".$year.$month.".png";
-		$fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account."-".$year.$month.".png";
-		$title=$langs->transnoentities("Balance").' - '.$langs->transnoentities("Month").': '.$month.' '.$langs->transnoentities("Year").': '.$year;
-		$graph_datas=array();
-		foreach($datas as $i => $val)
+		$file = $conf->bank->dir_temp."/balance".$account."-".$year.$month.".png";
+		$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account."-".$year.$month.".png";
+		$title = $langs->transnoentities("Balance").' - '.$langs->transnoentities("Month").': '.$month.' '.$langs->transnoentities("Year").': '.$year;
+		$graph_datas = array();
+		foreach ($datas as $i => $val)
 		{
-			$graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]);
+			$graph_datas[$i] = array(isset($labels[$i]) ? $labels[$i] : '', $datas[$i]);
 			if ($object->min_desired) array_push($graph_datas[$i], $datamin[$i]);
 			if ($object->min_allowed) array_push($graph_datas[$i], $dataall[$i]);
 		}
 
 		$px1 = new DolGraph();
 		$px1->SetData($graph_datas);
-		$arraylegends=array($langs->transnoentities("Balance"));
+		$arraylegends = array($langs->transnoentities("Balance"));
 		if ($object->min_desired) array_push($arraylegends, $langs->transnoentities("BalanceMinimalDesired"));
 		if ($object->min_allowed) array_push($arraylegends, $langs->transnoentities("BalanceMinimalAllowed"));
 		$px1->SetLegend($arraylegends);
 		$px1->SetLegendWidthMin(180);
-		$px1->SetMaxValue($px1->GetCeilMaxValue()<0?0:$px1->GetCeilMaxValue());
-		$px1->SetMinValue($px1->GetFloorMinValue()>0?0:$px1->GetFloorMinValue());
+		$px1->SetMaxValue($px1->GetCeilMaxValue() < 0 ? 0 : $px1->GetCeilMaxValue());
+		$px1->SetMinValue($px1->GetFloorMinValue() > 0 ? 0 : $px1->GetFloorMinValue());
 		$px1->SetTitle($title);
 		$px1->SetWidth($WIDTH);
 		$px1->SetHeight($HEIGHT);
-		$px1->SetType(array('lines','lines','lines'));
+		$px1->SetType(array('lines', 'lines', 'lines'));
 		$px1->setBgColor('onglet');
-		$px1->setBgColorGrid(array(255,255,255));
+		$px1->setBgColorGrid(array(255, 255, 255));
 		$px1->SetHorizTickIncrement(1);
 		$px1->draw($file, $fileurl);
 
-		$show1=$px1->show();
+		$show1 = $px1->show();
 		unset($graph_datas);
 		unset($px1);
 		unset($datas);
@@ -271,14 +271,14 @@ else
 		// Loading table $amounts
 		$amounts = array();
 		$sql = "SELECT date_format(b.datev,'%Y%m%d')";
-		$sql.= ", SUM(b.amount)";
-		$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
-		$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
-		$sql.= " WHERE b.fk_account = ba.rowid";
-		$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
-		$sql.= " AND b.datev >= '".$year."-01-01 00:00:00'";
-		$sql.= " AND b.datev <= '".$year."-12-31 23:59:59'";
-		if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
+		$sql .= ", SUM(b.amount)";
+		$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
+		$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
+		$sql .= " WHERE b.fk_account = ba.rowid";
+		$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
+		$sql .= " AND b.datev >= '".$year."-01-01 00:00:00'";
+		$sql .= " AND b.datev <= '".$year."-12-31 23:59:59'";
+		if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
 		$sql .= " GROUP BY date_format(b.datev,'%Y%m%d')";
 
 		$resql = $db->query($sql);
@@ -303,12 +303,12 @@ else
 		$solde = 0;
 
 		$sql = "SELECT SUM(b.amount)";
-		$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
-		$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
-		$sql.= " WHERE b.fk_account = ba.rowid";
-		$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
-		$sql.= " AND b.datev < '".$year."-01-01'";
-		if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
+		$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
+		$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
+		$sql .= " WHERE b.fk_account = ba.rowid";
+		$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
+		$sql .= " AND b.datev < '".$year."-01-01'";
+		if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
 
 		$resql = $db->query($sql);
 		if ($resql)
@@ -361,36 +361,36 @@ else
 		}
 
 		// Fabrication tableau 2
-		$file= $conf->bank->dir_temp."/balance".$account."-".$year.".png";
-		$fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account."-".$year.".png";
-		$title=$langs->transnoentities("Balance").' - '.$langs->transnoentities("Year").': '.$year;
-		$graph_datas=array();
-		foreach($datas as $i => $val)
+		$file = $conf->bank->dir_temp."/balance".$account."-".$year.".png";
+		$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account."-".$year.".png";
+		$title = $langs->transnoentities("Balance").' - '.$langs->transnoentities("Year").': '.$year;
+		$graph_datas = array();
+		foreach ($datas as $i => $val)
 		{
-			$graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]);
+			$graph_datas[$i] = array(isset($labels[$i]) ? $labels[$i] : '', $datas[$i]);
 			if ($object->min_desired) array_push($graph_datas[$i], $datamin[$i]);
 			if ($object->min_allowed) array_push($graph_datas[$i], $dataall[$i]);
 		}
 		$px2 = new DolGraph();
 		$px2->SetData($graph_datas);
-		$arraylegends=array($langs->transnoentities("Balance"));
+		$arraylegends = array($langs->transnoentities("Balance"));
 		if ($object->min_desired) array_push($arraylegends, $langs->transnoentities("BalanceMinimalDesired"));
 		if ($object->min_allowed) array_push($arraylegends, $langs->transnoentities("BalanceMinimalAllowed"));
 		$px2->SetLegend($arraylegends);
 		$px2->SetLegendWidthMin(180);
-		$px2->SetMaxValue($px2->GetCeilMaxValue()<0?0:$px2->GetCeilMaxValue());
-		$px2->SetMinValue($px2->GetFloorMinValue()>0?0:$px2->GetFloorMinValue());
+		$px2->SetMaxValue($px2->GetCeilMaxValue() < 0 ? 0 : $px2->GetCeilMaxValue());
+		$px2->SetMinValue($px2->GetFloorMinValue() > 0 ? 0 : $px2->GetFloorMinValue());
 		$px2->SetTitle($title);
 		$px2->SetWidth($WIDTH);
 		$px2->SetHeight($HEIGHT);
-		$px2->SetType(array('linesnopoint','linesnopoint','linesnopoint'));
+		$px2->SetType(array('linesnopoint', 'linesnopoint', 'linesnopoint'));
 		$px2->setBgColor('onglet');
-		$px2->setBgColorGrid(array(255,255,255));
+		$px2->setBgColorGrid(array(255, 255, 255));
 		$px2->SetHideXGrid(true);
 		//$px2->SetHorizTickIncrement(30.41);	// 30.41 jours/mois en moyenne
 		$px2->draw($file, $fileurl);
 
-		$show2=$px2->show();
+		$show2 = $px2->show();
 
 		unset($px2);
 		unset($graph_datas);
@@ -409,13 +409,13 @@ else
 		$amounts = array();
 
 		$sql = "SELECT date_format(b.datev,'%Y%m%d')";
-		$sql.= ", SUM(b.amount)";
-		$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
-		$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
-		$sql.= " WHERE b.fk_account = ba.rowid";
-		$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
-		if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
-		$sql.= " GROUP BY date_format(b.datev,'%Y%m%d')";
+		$sql .= ", SUM(b.amount)";
+		$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
+		$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
+		$sql .= " WHERE b.fk_account = ba.rowid";
+		$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
+		if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
+		$sql .= " GROUP BY date_format(b.datev,'%Y%m%d')";
 
 		$resql = $db->query($sql);
 		if ($resql)
@@ -447,20 +447,20 @@ else
 		$subtotal = 0;
 
 		$day = $min;
-		$textdate=strftime("%Y%m%d", $day);
+		$textdate = strftime("%Y%m%d", $day);
 		//print "x".$textdate;
 		$i = 0;
-		while ($day <= ($max+86400))	// On va au dela du dernier jour
+		while ($day <= ($max + 86400))	// On va au dela du dernier jour
 		{
 			$subtotal = $subtotal + (isset($amounts[$textdate]) ? $amounts[$textdate] : 0);
 			//print strftime ("%e %d %m %y",$day)." ".$subtotal."\n<br>";
-			if ($day > ($max+86400))
+			if ($day > ($max + 86400))
 			{
 				$datas[$i] = ''; // Valeur speciale permettant de ne pas tracer le graph
 			}
 			else
 			{
-				$datas[$i] = '' + $solde + $subtotal;
+				$datas[$i] = '' +$solde + $subtotal;
 			}
 			$datamin[$i] = $object->min_desired;
 			$dataall[$i] = $object->min_allowed;
@@ -470,40 +470,40 @@ else
 			}
 
 			$day += 86400;
-			$textdate=strftime("%Y%m%d", $day);
+			$textdate = strftime("%Y%m%d", $day);
 			$i++;
 		}
 
 		// Fabrication tableau 3
-		$file= $conf->bank->dir_temp."/balance".$account.".png";
-		$fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account.".png";
-		$title=$langs->transnoentities("Balance")." - ".$langs->transnoentities("AllTime");
-		$graph_datas=array();
-		foreach($datas as $i => $val)
+		$file = $conf->bank->dir_temp."/balance".$account.".png";
+		$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/balance".$account.".png";
+		$title = $langs->transnoentities("Balance")." - ".$langs->transnoentities("AllTime");
+		$graph_datas = array();
+		foreach ($datas as $i => $val)
 		{
-			$graph_datas[$i]=array(isset($labels[$i])?$labels[$i]:'',$datas[$i]);
+			$graph_datas[$i] = array(isset($labels[$i]) ? $labels[$i] : '', $datas[$i]);
 			if ($object->min_desired) array_push($graph_datas[$i], $datamin[$i]);
 			if ($object->min_allowed) array_push($graph_datas[$i], $dataall[$i]);
 		}
 
 		$px3 = new DolGraph();
 		$px3->SetData($graph_datas);
-		$arraylegends=array($langs->transnoentities("Balance"));
+		$arraylegends = array($langs->transnoentities("Balance"));
 		if ($object->min_desired) array_push($arraylegends, $langs->transnoentities("BalanceMinimalDesired"));
 		if ($object->min_allowed) array_push($arraylegends, $langs->transnoentities("BalanceMinimalAllowed"));
 		$px3->SetLegend($arraylegends);
 		$px3->SetLegendWidthMin(180);
-		$px3->SetMaxValue($px3->GetCeilMaxValue()<0?0:$px3->GetCeilMaxValue());
-		$px3->SetMinValue($px3->GetFloorMinValue()>0?0:$px3->GetFloorMinValue());
+		$px3->SetMaxValue($px3->GetCeilMaxValue() < 0 ? 0 : $px3->GetCeilMaxValue());
+		$px3->SetMinValue($px3->GetFloorMinValue() > 0 ? 0 : $px3->GetFloorMinValue());
 		$px3->SetTitle($title);
 		$px3->SetWidth($WIDTH);
 		$px3->SetHeight($HEIGHT);
-		$px3->SetType(array('linesnopoint','linesnopoint','linesnopoint'));
+		$px3->SetType(array('linesnopoint', 'linesnopoint', 'linesnopoint'));
 		$px3->setBgColor('onglet');
-		$px3->setBgColorGrid(array(255,255,255));
+		$px3->setBgColorGrid(array(255, 255, 255));
 		$px3->draw($file, $fileurl);
 
-		$show3=$px3->show();
+		$show3 = $px3->show();
 
 		unset($px3);
 		unset($graph_datas);
@@ -522,25 +522,25 @@ else
 		$credits = array();
 		$debits = array();
 
-		$monthnext = $month+1;
+		$monthnext = $month + 1;
 		$yearnext = $year;
 		if ($monthnext > 12)
 		{
-			$monthnext=1;
+			$monthnext = 1;
 			$yearnext++;
 		}
 
 		$sql = "SELECT date_format(b.datev,'%d')";
-		$sql.= ", SUM(b.amount)";
+		$sql .= ", SUM(b.amount)";
 		$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
-		$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
-		$sql.= " WHERE b.fk_account = ba.rowid";
-		$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
-		$sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'";
-		$sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
-		$sql.= " AND b.amount > 0";
-		if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
-		$sql.= " GROUP BY date_format(b.datev,'%d')";
+		$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
+		$sql .= " WHERE b.fk_account = ba.rowid";
+		$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
+		$sql .= " AND b.datev >= '".$year."-".$month."-01 00:00:00'";
+		$sql .= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
+		$sql .= " AND b.amount > 0";
+		if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
+		$sql .= " GROUP BY date_format(b.datev,'%d')";
 
 		$resql = $db->query($sql);
 		if ($resql)
@@ -560,24 +560,24 @@ else
 			dol_print_error($db);
 		}
 
-		$monthnext = $month+1;
+		$monthnext = $month + 1;
 		$yearnext = $year;
 		if ($monthnext > 12)
 		{
-			$monthnext=1;
+			$monthnext = 1;
 			$yearnext++;
 		}
 
 		$sql = "SELECT date_format(b.datev,'%d')";
-		$sql.= ", SUM(b.amount)";
+		$sql .= ", SUM(b.amount)";
 		$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
-		$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
-		$sql.= " WHERE b.fk_account = ba.rowid";
-		$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
-		$sql.= " AND b.datev >= '".$year."-".$month."-01 00:00:00'";
-		$sql.= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
-		$sql.= " AND b.amount < 0";
-		if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
+		$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
+		$sql .= " WHERE b.fk_account = ba.rowid";
+		$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
+		$sql .= " AND b.datev >= '".$year."-".$month."-01 00:00:00'";
+		$sql .= " AND b.datev < '".$yearnext."-".$monthnext."-01 00:00:00'";
+		$sql .= " AND b.amount < 0";
+		if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
 		$sql .= " GROUP BY date_format(b.datev,'%d')";
 
 		$resql = $db->query($sql);
@@ -599,40 +599,40 @@ else
 		$labels = array();
 		$data_credit = array();
 		$data_debit = array();
-		for ($i = 0 ; $i < 31 ; $i++)
+		for ($i = 0; $i < 31; $i++)
 		{
-			$data_credit[$i] = isset($credits[substr("0".($i+1), -2)]) ? $credits[substr("0".($i+1), -2)] : 0;
-			$data_debit[$i] = isset($debits[substr("0".($i+1), -2)]) ? $debits[substr("0".($i+1), -2)] : 0;
-			$labels[$i] = sprintf("%02d", $i+1);
+			$data_credit[$i] = isset($credits[substr("0".($i + 1), -2)]) ? $credits[substr("0".($i + 1), -2)] : 0;
+			$data_debit[$i] = isset($debits[substr("0".($i + 1), -2)]) ? $debits[substr("0".($i + 1), -2)] : 0;
+			$labels[$i] = sprintf("%02d", $i + 1);
 			$datamin[$i] = $object->min_desired;
 		}
 
 		// Fabrication tableau 4a
-		$file= $conf->bank->dir_temp."/movement".$account."-".$year.$month.".png";
-		$fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/movement".$account."-".$year.$month.".png";
-		$title=$langs->transnoentities("BankMovements").' - '.$langs->transnoentities("Month").': '.$month.' '.$langs->transnoentities("Year").': '.$year;
-		$graph_datas=array();
-		foreach($data_credit as $i => $val)
+		$file = $conf->bank->dir_temp."/movement".$account."-".$year.$month.".png";
+		$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/movement".$account."-".$year.$month.".png";
+		$title = $langs->transnoentities("BankMovements").' - '.$langs->transnoentities("Month").': '.$month.' '.$langs->transnoentities("Year").': '.$year;
+		$graph_datas = array();
+		foreach ($data_credit as $i => $val)
 		{
-			$graph_datas[$i]=array($labels[$i],$data_credit[$i],$data_debit[$i]);
+			$graph_datas[$i] = array($labels[$i], $data_credit[$i], $data_debit[$i]);
 		}
 		$px4 = new DolGraph();
 		$px4->SetData($graph_datas);
-		$px4->SetLegend(array($langs->transnoentities("Credit"),$langs->transnoentities("Debit")));
+		$px4->SetLegend(array($langs->transnoentities("Credit"), $langs->transnoentities("Debit")));
 		$px4->SetLegendWidthMin(180);
-		$px4->SetMaxValue($px4->GetCeilMaxValue()<0?0:$px4->GetCeilMaxValue());
-		$px4->SetMinValue($px4->GetFloorMinValue()>0?0:$px4->GetFloorMinValue());
+		$px4->SetMaxValue($px4->GetCeilMaxValue() < 0 ? 0 : $px4->GetCeilMaxValue());
+		$px4->SetMinValue($px4->GetFloorMinValue() > 0 ? 0 : $px4->GetFloorMinValue());
 		$px4->SetTitle($title);
 		$px4->SetWidth($WIDTH);
 		$px4->SetHeight($HEIGHT);
-		$px4->SetType(array('bars','bars'));
+		$px4->SetType(array('bars', 'bars'));
 		$px4->SetShading(3);
 		$px4->setBgColor('onglet');
-		$px4->setBgColorGrid(array(255,255,255));
+		$px4->setBgColorGrid(array(255, 255, 255));
 		$px4->SetHorizTickIncrement(1);
 		$px4->draw($file, $fileurl);
 
-		$show4=$px4->show();
+		$show4 = $px4->show();
 
 		unset($graph_datas);
 		unset($px4);
@@ -648,15 +648,15 @@ else
 		$credits = array();
 		$debits = array();
 		$sql = "SELECT date_format(b.datev,'%m')";
-		$sql.= ", SUM(b.amount)";
-		$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
-		$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
-		$sql.= " WHERE b.fk_account = ba.rowid";
-		$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
-		$sql.= " AND b.datev >= '".$year."-01-01 00:00:00'";
-		$sql.= " AND b.datev <= '".$year."-12-31 23:59:59'";
-		$sql.= " AND b.amount > 0";
-		if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
+		$sql .= ", SUM(b.amount)";
+		$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
+		$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
+		$sql .= " WHERE b.fk_account = ba.rowid";
+		$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
+		$sql .= " AND b.datev >= '".$year."-01-01 00:00:00'";
+		$sql .= " AND b.datev <= '".$year."-12-31 23:59:59'";
+		$sql .= " AND b.amount > 0";
+		if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
 		$sql .= " GROUP BY date_format(b.datev,'%m');";
 
 		$resql = $db->query($sql);
@@ -677,15 +677,15 @@ else
 			dol_print_error($db);
 		}
 		$sql = "SELECT date_format(b.datev,'%m')";
-		$sql.= ", SUM(b.amount)";
-		$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
-		$sql.= ", ".MAIN_DB_PREFIX."bank_account as ba";
-		$sql.= " WHERE b.fk_account = ba.rowid";
-		$sql.= " AND ba.entity IN (".getEntity('bank_account').")";
-		$sql.= " AND b.datev >= '".$year."-01-01 00:00:00'";
-		$sql.= " AND b.datev <= '".$year."-12-31 23:59:59'";
-		$sql.= " AND b.amount < 0";
-		if ($account && $_GET["option"]!='all') $sql.= " AND b.fk_account IN (".$account.")";
+		$sql .= ", SUM(b.amount)";
+		$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
+		$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba";
+		$sql .= " WHERE b.fk_account = ba.rowid";
+		$sql .= " AND ba.entity IN (".getEntity('bank_account').")";
+		$sql .= " AND b.datev >= '".$year."-01-01 00:00:00'";
+		$sql .= " AND b.datev <= '".$year."-12-31 23:59:59'";
+		$sql .= " AND b.amount < 0";
+		if ($account && $_GET["option"] != 'all') $sql .= " AND b.fk_account IN (".$account.")";
 		$sql .= " GROUP BY date_format(b.datev,'%m')";
 
 		$resql = $db->query($sql);
@@ -707,40 +707,40 @@ else
 		$labels = array();
 		$data_credit = array();
 		$data_debit = array();
-		for ($i = 0 ; $i < 12 ; $i++)
+		for ($i = 0; $i < 12; $i++)
 		{
-			$data_credit[$i] = isset($credits[substr("0".($i+1), -2)]) ? $credits[substr("0".($i+1), -2)] : 0;
-			$data_debit[$i] = isset($debits[substr("0".($i+1), -2)]) ? $debits[substr("0".($i+1), -2)] : 0;
-			$labels[$i] = dol_print_date(dol_mktime(12, 0, 0, $i+1, 1, 2000), "%b");
+			$data_credit[$i] = isset($credits[substr("0".($i + 1), -2)]) ? $credits[substr("0".($i + 1), -2)] : 0;
+			$data_debit[$i] = isset($debits[substr("0".($i + 1), -2)]) ? $debits[substr("0".($i + 1), -2)] : 0;
+			$labels[$i] = dol_print_date(dol_mktime(12, 0, 0, $i + 1, 1, 2000), "%b");
 			$datamin[$i] = $object->min_desired;
 		}
 
 		// Fabrication tableau 4b
-		$file= $conf->bank->dir_temp."/movement".$account."-".$year.".png";
-		$fileurl=DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/movement".$account."-".$year.".png";
-		$title=$langs->transnoentities("BankMovements").' - '.$langs->transnoentities("Year").': '.$year;
-		$graph_datas=array();
-		foreach($data_credit as $i => $val)
+		$file = $conf->bank->dir_temp."/movement".$account."-".$year.".png";
+		$fileurl = DOL_URL_ROOT.'/viewimage.php?modulepart=banque_temp&file='."/movement".$account."-".$year.".png";
+		$title = $langs->transnoentities("BankMovements").' - '.$langs->transnoentities("Year").': '.$year;
+		$graph_datas = array();
+		foreach ($data_credit as $i => $val)
 		{
-			$graph_datas[$i]=array($labels[$i],$data_credit[$i],$data_debit[$i]);
+			$graph_datas[$i] = array($labels[$i], $data_credit[$i], $data_debit[$i]);
 		}
 		$px5 = new DolGraph();
 		$px5->SetData($graph_datas);
-		$px5->SetLegend(array($langs->transnoentities("Credit"),$langs->transnoentities("Debit")));
+		$px5->SetLegend(array($langs->transnoentities("Credit"), $langs->transnoentities("Debit")));
 		$px5->SetLegendWidthMin(180);
-		$px5->SetMaxValue($px5->GetCeilMaxValue()<0?0:$px5->GetCeilMaxValue());
-		$px5->SetMinValue($px5->GetFloorMinValue()>0?0:$px5->GetFloorMinValue());
+		$px5->SetMaxValue($px5->GetCeilMaxValue() < 0 ? 0 : $px5->GetCeilMaxValue());
+		$px5->SetMinValue($px5->GetFloorMinValue() > 0 ? 0 : $px5->GetFloorMinValue());
 		$px5->SetTitle($title);
 		$px5->SetWidth($WIDTH);
 		$px5->SetHeight($HEIGHT);
-		$px5->SetType(array('bars','bars'));
+		$px5->SetType(array('bars', 'bars'));
 		$px5->SetShading(3);
 		$px5->setBgColor('onglet');
-		$px5->setBgColorGrid(array(255,255,255));
+		$px5->setBgColorGrid(array(255, 255, 255));
 		$px5->SetHorizTickIncrement(1);
 		$px5->draw($file, $fileurl);
 
-		$show5=$px5->show();
+		$show5 = $px5->show();
 
 		unset($graph_datas);
 		unset($px5);
@@ -751,7 +751,7 @@ else
 
 
 // Onglets
-$head=bank_prepare_head($object);
+$head = bank_prepare_head($object);
 dol_fiche_head($head, 'graph', $langs->trans("FinancialAccount"), 0, 'account');
 
 
@@ -759,32 +759,32 @@ $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_v
 
 if ($account)
 {
-	if (! preg_match('/,/', $account))
+	if (!preg_match('/,/', $account))
 	{
-		$moreparam='&month='.$month.'&year='.$year.($mode=='showalltime'?'&mode=showalltime':'');
+		$moreparam = '&month='.$month.'&year='.$year.($mode == 'showalltime' ? '&mode=showalltime' : '');
 
-		if ($_GET["option"]!='all')
+		if ($_GET["option"] != 'all')
 		{
-			$morehtml='<a href="'.$_SERVER["PHP_SELF"].'?account='.$account.'&option=all'.$moreparam.'">'.$langs->trans("ShowAllAccounts").'</a>';
+			$morehtml = '<a href="'.$_SERVER["PHP_SELF"].'?account='.$account.'&option=all'.$moreparam.'">'.$langs->trans("ShowAllAccounts").'</a>';
     		dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam, 0, '', '', 1);
 		}
 		else
 		{
-			$morehtml='<a href="'.$_SERVER["PHP_SELF"].'?account='.$account.$moreparam.'">'.$langs->trans("BackToAccount").'</a>';
+			$morehtml = '<a href="'.$_SERVER["PHP_SELF"].'?account='.$account.$moreparam.'">'.$langs->trans("BackToAccount").'</a>';
 			print $langs->trans("AllAccounts");
 			//print $morehtml;
 		}
 	}
 	else
 	{
-	    $bankaccount=new Account($db);
-		$listid=explode(',', $account);
-		foreach($listid as $key => $id)
+	    $bankaccount = new Account($db);
+		$listid = explode(',', $account);
+		foreach ($listid as $key => $id)
 		{
 			$bankaccount->fetch($id);
-			$bankaccount->label=$bankaccount->ref;
+			$bankaccount->label = $bankaccount->ref;
 			print $bankaccount->getNomUrl(1);
-			if ($key < (count($listid)-1)) print ', ';
+			if ($key < (count($listid) - 1)) print ', ';
 		}
 	}
 }
@@ -818,13 +818,13 @@ print '<br><br></td></tr>';
 // Graphs
 if ($mode == 'standard')
 {
-	$prevyear=$year; $nextyear=$year;
-	$prevmonth=$month-1;$nextmonth=$month+1;
-	if ($prevmonth < 1)  { $prevmonth=12; $prevyear--; }
-	if ($nextmonth > 12) { $nextmonth=1; $nextyear++; }
+	$prevyear = $year; $nextyear = $year;
+	$prevmonth = $month - 1; $nextmonth = $month + 1;
+	if ($prevmonth < 1) { $prevmonth = 12; $prevyear--; }
+	if ($nextmonth > 12) { $nextmonth = 1; $nextyear++; }
 
 	// For month
-	$link="<a href='".$_SERVER["PHP_SELF"]."?account=".$account.($_GET["option"]!='all'?'':'&option=all')."&year=".$prevyear."&month=".$prevmonth."'>".img_previous('', 'class="valignbottom"')."</a> ".$langs->trans("Month")." <a href='".$_SERVER["PHP_SELF"]."?account=".$account."&year=".$nextyear."&month=".$nextmonth."'>".img_next('', 'class="valignbottom"')."</a>";
+	$link = "<a href='".$_SERVER["PHP_SELF"]."?account=".$account.($_GET["option"] != 'all' ? '' : '&option=all')."&year=".$prevyear."&month=".$prevmonth."'>".img_previous('', 'class="valignbottom"')."</a> ".$langs->trans("Month")." <a href='".$_SERVER["PHP_SELF"]."?account=".$account."&year=".$nextyear."&month=".$nextmonth."'>".img_next('', 'class="valignbottom"')."</a>";
 	print '<tr><td class="right">'.$link.'</td></tr>';
 
 	print '<tr><td class="center">';
@@ -837,8 +837,8 @@ if ($mode == 'standard')
 	print '</td></tr>';
 
 	// For year
-	$prevyear=$year-1;$nextyear=$year+1;
-	$link="<a href='".$_SERVER["PHP_SELF"]."?account=".$account.($_GET["option"]!='all'?'':'&option=all')."&year=".($prevyear)."'>".img_previous('', 'class="valignbottom"')."</a> ".$langs->trans("Year")." <a href='".$_SERVER["PHP_SELF"]."?account=".$account."&year=".($nextyear)."'>".img_next('', 'class="valignbottom"')."</a>";
+	$prevyear = $year - 1; $nextyear = $year + 1;
+	$link = "<a href='".$_SERVER["PHP_SELF"]."?account=".$account.($_GET["option"] != 'all' ? '' : '&option=all')."&year=".($prevyear)."'>".img_previous('', 'class="valignbottom"')."</a> ".$langs->trans("Year")." <a href='".$_SERVER["PHP_SELF"]."?account=".$account."&year=".($nextyear)."'>".img_next('', 'class="valignbottom"')."</a>";
 	print '<tr><td class="right">'.$link.'</td></tr>';
 
 	print '<tr><td class="center">';

+ 28 - 28
htdocs/core/boxes/box_shipments.php

@@ -32,9 +32,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
  */
 class box_shipments extends ModeleBoxes
 {
-    public $boxcode="lastcustomershipments";
-    public $boximg="sending";
-    public $boxlabel="BoxLastCustomerShipments";
+    public $boxcode = "lastcustomershipments";
+    public $boximg = "sending";
+    public $boxlabel = "BoxLastCustomerShipments";
     public $depends = array("expedition");
 
 	/**
@@ -58,9 +58,9 @@ class box_shipments extends ModeleBoxes
     {
         global $user;
 
-        $this->db=$db;
+        $this->db = $db;
 
-        $this->hidden=! ($user->rights->expedition->lire);
+        $this->hidden = !($user->rights->expedition->lire);
     }
 
     /**
@@ -88,26 +88,26 @@ class box_shipments extends ModeleBoxes
         if ($user->rights->expedition->lire)
         {
             $sql = "SELECT s.nom as name";
-            $sql.= ", s.rowid as socid";
-            $sql.= ", s.code_client";
-            $sql.= ", s.logo, s.email";
-            $sql.= ", e.ref, e.tms";
-            $sql.= ", e.rowid";
-            $sql.= ", e.ref_customer";
-            $sql.= ", e.fk_statut";
-            $sql.= ", e.fk_user_valid";
-            $sql.= ", c.ref as commande_ref";
-            $sql.= ", c.rowid as commande_id";
-            $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e";
-            $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')";
-            $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'";
-            $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
-            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
-            $sql.= " WHERE e.entity = ".$conf->entity;
-            if (! empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql.=" AND e.fk_statut = 1";
-            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND sc.fk_user = " .$user->id;
-            else $sql.= " ORDER BY e.date_delivery, e.ref DESC ";
-            $sql.= $this->db->plimit($max, 0);
+            $sql .= ", s.rowid as socid";
+            $sql .= ", s.code_client";
+            $sql .= ", s.logo, s.email";
+            $sql .= ", e.ref, e.tms";
+            $sql .= ", e.rowid";
+            $sql .= ", e.ref_customer";
+            $sql .= ", e.fk_statut";
+            $sql .= ", e.fk_user_valid";
+            $sql .= ", c.ref as commande_ref";
+            $sql .= ", c.rowid as commande_id";
+            $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e";
+            $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'shipping' AND el.sourcetype IN ('commande')";
+            $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON el.fk_source = c.rowid AND el.sourcetype IN ('commande') AND el.targettype = 'shipping'";
+            $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
+            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
+            $sql .= " WHERE e.entity = ".$conf->entity;
+            if (!empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql .= " AND e.fk_statut = 1";
+            if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= " AND sc.fk_user = ".$user->id;
+            else $sql .= " ORDER BY e.date_delivery, e.ref DESC ";
+            $sql .= $this->db->plimit($max, 0);
 
             $result = $this->db->query($sql);
             if ($result) {
@@ -122,8 +122,8 @@ class box_shipments extends ModeleBoxes
                     $shipmentstatic->ref = $objp->ref;
                     $shipmentstatic->ref_customer = $objp->ref_customer;
 
-                    $orderstatic->id= $objp->commande_id;
-                    $orderstatic->ref=$objp->commande_ref;
+                    $orderstatic->id = $objp->commande_id;
+                    $orderstatic->ref = $objp->commande_ref;
 
                     $societestatic->id = $objp->socid;
                     $societestatic->name = $objp->name;
@@ -157,7 +157,7 @@ class box_shipments extends ModeleBoxes
                     $line++;
                 }
 
-                if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedShipments"));
+                if ($num == 0) $this->info_box_contents[$line][0] = array('td' => 'class="center"', 'text'=>$langs->trans("NoRecordedShipments"));
 
                 $this->db->free($result);
             } else {

+ 19 - 19
htdocs/core/class/emailsenderprofile.class.php

@@ -26,7 +26,7 @@
  */
 
 // Put here all includes required by your class file
-require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
 //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
 //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
 
@@ -84,7 +84,7 @@ class EmailSenderProfile extends CommonObject
 	/**
 	 * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
 	 */
-	public $fields=array(
+	public $fields = array(
 		'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'visible'=>-1, 'enabled'=>1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>'Id',),
 		'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>-1, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,),
 		'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>1),
@@ -167,8 +167,8 @@ class EmailSenderProfile extends CommonObject
 
 		$this->db = $db;
 
-		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible']=0;
-		if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled']=0;
+		if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0;
+		if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled'] = 0;
 	}
 
 	/**
@@ -244,7 +244,7 @@ class EmailSenderProfile extends CommonObject
 	public function fetch($id, $ref = null)
 	{
 		$result = $this->fetchCommon($id, $ref);
-		if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
+		if ($result > 0 && !empty($this->table_element_line)) $this->fetchLines();
 		return $result;
 	}
 
@@ -255,11 +255,11 @@ class EmailSenderProfile extends CommonObject
 	 */
 	public function fetchLines()
 	{
-		$this->lines=array();
+		$this->lines = array();
 
 		// Load lines with object EmailSenderProfileLine
 
-		return count($this->lines)?1:0;
+		return count($this->lines) ? 1 : 0;
 	}
 
 	/**
@@ -301,19 +301,19 @@ class EmailSenderProfile extends CommonObject
 		$result = '';
 		$companylink = '';
 
-        $label=$this->label;
+        $label = $this->label;
 
-        $url='';
+        $url = '';
 		//$url = dol_buildpath('/monmodule/emailsenderprofile_card.php',1).'?id='.$this->id;
 
 		$linkstart = '';
-		$linkend='';
+		$linkend = '';
 
 		if ($withpicto) {
-			$result.=($linkstart.img_object($label, 'label', 'class="classfortooltip"').$linkend);
-			if ($withpicto != 2) $result.=' ';
+			$result .= ($linkstart.img_object($label, 'label', 'class="classfortooltip"').$linkend);
+			if ($withpicto != 2) $result .= ' ';
 		}
-		$result.= $linkstart . $this->label . $linkend;
+		$result .= $linkstart.$this->label.$linkend;
 		return $result;
 	}
 
@@ -381,10 +381,10 @@ class EmailSenderProfile extends CommonObject
 	public function info($id)
 	{
 		$sql = 'SELECT rowid, date_creation as datec, tms as datem,';
-		$sql.= ' fk_user_creat, fk_user_modif';
-		$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
-		$sql.= ' WHERE t.rowid = '.$id;
-		$result=$this->db->query($sql);
+		$sql .= ' fk_user_creat, fk_user_modif';
+		$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
+		$sql .= ' WHERE t.rowid = '.$id;
+		$result = $this->db->query($sql);
 		if ($result)
 		{
 			if ($this->db->num_rows($result))
@@ -395,7 +395,7 @@ class EmailSenderProfile extends CommonObject
 				{
 					$cuser = new User($this->db);
 					$cuser->fetch($obj->fk_user_author);
-					$this->user_creation   = $cuser;
+					$this->user_creation = $cuser;
 				}
 
 				if ($obj->fk_user_valid)
@@ -409,7 +409,7 @@ class EmailSenderProfile extends CommonObject
 				{
 					$cluser = new User($this->db);
 					$cluser->fetch($obj->fk_user_cloture);
-					$this->user_cloture   = $cluser;
+					$this->user_cloture = $cluser;
 				}
 
 				$this->date_creation     = $this->db->jdate($obj->datec);

+ 72 - 72
htdocs/core/class/events.class.php

@@ -31,12 +31,12 @@ class Events // extends CommonObject
 	/**
 	 * @var string ID to identify managed object
 	 */
-	public $element='events';
+	public $element = 'events';
 
 	/**
 	 * @var string Name of table without prefix where object is stored
 	 */
-	public $table_element='events';
+	public $table_element = 'events';
 
 	/**
 	 * @var int ID
@@ -51,7 +51,7 @@ class Events // extends CommonObject
 	/**
 	 * @var string Error code (or message)
 	 */
-	public $error='';
+	public $error = '';
 
 	/**
 	 * @var int timestamp
@@ -91,18 +91,18 @@ class Events // extends CommonObject
 	public $prefix_session;
 
 	// List of all Audit/Security events supported by triggers
-	public $eventstolog=array(
-		array('id'=>'USER_LOGIN',             'test'=>1),
-		array('id'=>'USER_LOGIN_FAILED',      'test'=>1),
-	    array('id'=>'USER_LOGOUT',            'test'=>1),
-		array('id'=>'USER_CREATE',            'test'=>1),
-		array('id'=>'USER_MODIFY',            'test'=>1),
-		array('id'=>'USER_NEW_PASSWORD',      'test'=>1),
-		array('id'=>'USER_ENABLEDISABLE',     'test'=>1),
-		array('id'=>'USER_DELETE',            'test'=>1),
-		array('id'=>'GROUP_CREATE',           'test'=>1),
-		array('id'=>'GROUP_MODIFY',           'test'=>1),
-		array('id'=>'GROUP_DELETE',           'test'=>1),
+	public $eventstolog = array(
+		array('id'=>'USER_LOGIN', 'test'=>1),
+		array('id'=>'USER_LOGIN_FAILED', 'test'=>1),
+	    array('id'=>'USER_LOGOUT', 'test'=>1),
+		array('id'=>'USER_CREATE', 'test'=>1),
+		array('id'=>'USER_MODIFY', 'test'=>1),
+		array('id'=>'USER_NEW_PASSWORD', 'test'=>1),
+		array('id'=>'USER_ENABLEDISABLE', 'test'=>1),
+		array('id'=>'USER_DELETE', 'test'=>1),
+		array('id'=>'GROUP_CREATE', 'test'=>1),
+		array('id'=>'GROUP_MODIFY', 'test'=>1),
+		array('id'=>'GROUP_DELETE', 'test'=>1),
 	);
 
 
@@ -110,11 +110,11 @@ class Events // extends CommonObject
 	/**
 	 * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
 	 */
-	public $fields=array(
-		'rowid'         =>array('type'=>'integer',      'label'=>'TechnicalID',      'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
-		'entity'        =>array('type'=>'integer',      'label'=>'Entity',           'enabled'=>1, 'visible'=>0,  'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>20),
-		'prefix_session'=>array('type'=>'varchar(255)', 'label'=>'PrefixSession',    'enabled'=>1, 'visible'=>-1, 'notnull'=>-1, 'index'=>0,  'position'=>1000),
-		'user_agent'    =>array('type'=>'varchar(255)', 'label'=>'UserAgent',        'enabled'=>1, 'visible'=>-1, 'notnull'=> 1, 'default'=>0, 'index'=>1,  'position'=>1000),
+	public $fields = array(
+		'rowid'         =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'noteditable'=>1, 'notnull'=> 1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
+		'entity'        =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>20),
+		'prefix_session'=>array('type'=>'varchar(255)', 'label'=>'PrefixSession', 'enabled'=>1, 'visible'=>-1, 'notnull'=>-1, 'index'=>0, 'position'=>1000),
+		'user_agent'    =>array('type'=>'varchar(255)', 'label'=>'UserAgent', 'enabled'=>1, 'visible'=>-1, 'notnull'=> 1, 'default'=>0, 'index'=>1, 'position'=>1000),
 	);
 
 
@@ -140,35 +140,35 @@ class Events // extends CommonObject
 		global $conf;
 
 		// Clean parameters
-		$this->description=trim($this->description);
-		if (empty($this->user_agent) && !empty($_SERVER['HTTP_USER_AGENT'])) $this->user_agent=$_SERVER['HTTP_USER_AGENT'];
+		$this->description = trim($this->description);
+		if (empty($this->user_agent) && !empty($_SERVER['HTTP_USER_AGENT'])) $this->user_agent = $_SERVER['HTTP_USER_AGENT'];
 
 		// Check parameters
-		if (empty($this->description)) { $this->error='ErrorBadValueForParameterCreateEventDesc'; return -1; }
+		if (empty($this->description)) { $this->error = 'ErrorBadValueForParameterCreateEventDesc'; return -1; }
 
 		// Insert request
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."events(";
-		$sql.= "type,";
-		$sql.= "entity,";
-		$sql.= "ip,";
-		$sql.= "user_agent,";
-		$sql.= "dateevent,";
-		$sql.= "fk_user,";
-		$sql.= "description,";
-		$sql.= "prefix_session";
-		$sql.= ") VALUES (";
-		$sql.= " '".$this->db->escape($this->type)."',";
-		$sql.= " ".$conf->entity.",";
-		$sql.= " '".$this->db->escape(getUserRemoteIP())."',";
-		$sql.= " ".($this->user_agent ? "'".$this->db->escape(dol_trunc($this->user_agent, 250))."'" : 'NULL').",";
-		$sql.= " '".$this->db->idate($this->dateevent)."',";
-		$sql.= " ".($user->id?"'".$this->db->escape($user->id)."'":'NULL').",";
-		$sql.= " '".$this->db->escape(dol_trunc($this->description, 250))."',";
-		$sql.= " '".$this->db->escape(dol_getprefix())."'";
-		$sql.= ")";
+		$sql .= "type,";
+		$sql .= "entity,";
+		$sql .= "ip,";
+		$sql .= "user_agent,";
+		$sql .= "dateevent,";
+		$sql .= "fk_user,";
+		$sql .= "description,";
+		$sql .= "prefix_session";
+		$sql .= ") VALUES (";
+		$sql .= " '".$this->db->escape($this->type)."',";
+		$sql .= " ".$conf->entity.",";
+		$sql .= " '".$this->db->escape(getUserRemoteIP())."',";
+		$sql .= " ".($this->user_agent ? "'".$this->db->escape(dol_trunc($this->user_agent, 250))."'" : 'NULL').",";
+		$sql .= " '".$this->db->idate($this->dateevent)."',";
+		$sql .= " ".($user->id ? "'".$this->db->escape($user->id)."'" : 'NULL').",";
+		$sql .= " '".$this->db->escape(dol_trunc($this->description, 250))."',";
+		$sql .= " '".$this->db->escape(dol_getprefix())."'";
+		$sql .= ")";
 
 		dol_syslog(get_class($this)."::create", LOG_DEBUG);
-		$resql=$this->db->query($sql);
+		$resql = $this->db->query($sql);
 		if ($resql)
 		{
 			$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."events");
@@ -176,7 +176,7 @@ class Events // extends CommonObject
 		}
 		else
 		{
-			$this->error="Error ".$this->db->lasterror();
+			$this->error = "Error ".$this->db->lasterror();
 			return -1;
 		}
 	}
@@ -193,24 +193,24 @@ class Events // extends CommonObject
 	{
 		// Clean parameters
 		$this->id = (int) $this->id;
-		$this->type=trim($this->type);
-		$this->description=trim($this->description);
+		$this->type = trim($this->type);
+		$this->description = trim($this->description);
 
 		// Check parameters
 		// Put here code to add control on parameters values
 
 		// Update request
 		$sql = "UPDATE ".MAIN_DB_PREFIX."events SET";
-		$sql.= " type='".$this->db->escape($this->type)."',";
-		$sql.= " dateevent='".$this->db->idate($this->dateevent)."',";
-		$sql.= " description='".$this->db->escape($this->description)."'";
-		$sql.= " WHERE rowid=".$this->id;
+		$sql .= " type='".$this->db->escape($this->type)."',";
+		$sql .= " dateevent='".$this->db->idate($this->dateevent)."',";
+		$sql .= " description='".$this->db->escape($this->description)."'";
+		$sql .= " WHERE rowid=".$this->id;
 
 		dol_syslog(get_class($this)."::update", LOG_DEBUG);
 		$resql = $this->db->query($sql);
-		if (! $resql)
+		if (!$resql)
 		{
-			$this->error="Error ".$this->db->lasterror();
+			$this->error = "Error ".$this->db->lasterror();
 			return -1;
 		}
 		return 1;
@@ -227,20 +227,20 @@ class Events // extends CommonObject
     public function fetch($id, $user = null)
 	{
 		$sql = "SELECT";
-		$sql.= " t.rowid,";
-		$sql.= " t.tms,";
-		$sql.= " t.type,";
-		$sql.= " t.entity,";
-		$sql.= " t.dateevent,";
-		$sql.= " t.description,";
-		$sql.= " t.ip,";
-		$sql.= " t.user_agent,";
-		$sql.= " t.prefix_session";
-		$sql.= " FROM ".MAIN_DB_PREFIX."events as t";
-		$sql.= " WHERE t.rowid = ".$id;
+		$sql .= " t.rowid,";
+		$sql .= " t.tms,";
+		$sql .= " t.type,";
+		$sql .= " t.entity,";
+		$sql .= " t.dateevent,";
+		$sql .= " t.description,";
+		$sql .= " t.ip,";
+		$sql .= " t.user_agent,";
+		$sql .= " t.prefix_session";
+		$sql .= " FROM ".MAIN_DB_PREFIX."events as t";
+		$sql .= " WHERE t.rowid = ".$id;
 
 		dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
-		$resql=$this->db->query($sql);
+		$resql = $this->db->query($sql);
 		if ($resql)
 		{
 			if ($this->db->num_rows($resql))
@@ -263,7 +263,7 @@ class Events // extends CommonObject
 		}
 		else
 		{
-			$this->error="Error ".$this->db->lasterror();
+			$this->error = "Error ".$this->db->lasterror();
 			return -1;
 		}
 	}
@@ -278,13 +278,13 @@ class Events // extends CommonObject
     public function delete($user)
 	{
 		$sql = "DELETE FROM ".MAIN_DB_PREFIX."events";
-		$sql.= " WHERE rowid=".$this->id;
+		$sql .= " WHERE rowid=".$this->id;
 
 		dol_syslog(get_class($this)."::delete", LOG_DEBUG);
 		$resql = $this->db->query($sql);
-		if (! $resql)
+		if (!$resql)
 		{
-			$this->error="Error ".$this->db->lasterror();
+			$this->error = "Error ".$this->db->lasterror();
 			return -1;
 		}
 
@@ -301,12 +301,12 @@ class Events // extends CommonObject
      */
     public function initAsSpecimen()
 	{
-		$this->id=0;
+		$this->id = 0;
 
-		$this->tms=time();
-		$this->type='';
-		$this->dateevent=time();
-		$this->description='This is a specimen event';
+		$this->tms = time();
+		$this->type = '';
+		$this->dateevent = time();
+		$this->description = 'This is a specimen event';
 		$this->ip = '1.2.3.4';
 		$this->user_agent = 'Mozilla specimen User Agent X.Y';
 		$this->prefix_session = dol_getprefix();

+ 21 - 21
htdocs/core/class/html.formcron.class.php

@@ -36,7 +36,7 @@ class FormCron extends Form
     /**
      * @var string Error code (or message)
      */
-    public $error='';
+    public $error = '';
 
     /**
      *  Constructor
@@ -66,35 +66,35 @@ class FormCron extends Form
         $langs->load('cron@cron');
         $out = '';
         if (!empty($readonly)) {
-            if ($selected=='command') {
-                $out= $langs->trans('CronType_command');
-                $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>';
-                $out.= '<OPTION value="command" selected>'.$langs->trans('CronType_command').'</OPTION>';
-                $out.='</SELECT>';
-            } elseif ($selected=='method') {
-                $out= $langs->trans('CronType_method');
-                $out.='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>';
-                $out.= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>';
-                $out.='</SELECT>';
+            if ($selected == 'command') {
+                $out = $langs->trans('CronType_command');
+                $out .= '<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>';
+                $out .= '<OPTION value="command" selected>'.$langs->trans('CronType_command').'</OPTION>';
+                $out .= '</SELECT>';
+            } elseif ($selected == 'method') {
+                $out = $langs->trans('CronType_method');
+                $out .= '<SELECT name="'.$htmlname.'" id="'.$htmlname.'" style="display:none"/>';
+                $out .= '<OPTION value="method" selected>'.$langs->trans('CronType_method').'</OPTION>';
+                $out .= '</SELECT>';
             }
         } else {
-            $out='<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />';
+            $out = '<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />';
 
-            if ($selected=='command') {
-                $selected_attr=' selected ';
+            if ($selected == 'command') {
+                $selected_attr = ' selected ';
             } else {
-                $selected_attr='';
+                $selected_attr = '';
             }
-            $out.= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>';
+            $out .= '<OPTION value="command" '.$selected_attr.'>'.$langs->trans('CronType_command').'</OPTION>';
 
-            if ($selected=='method') {
-                $selected_attr=' selected ';
+            if ($selected == 'method') {
+                $selected_attr = ' selected ';
             } else {
-                $selected_attr='';
+                $selected_attr = '';
             }
-            $out.= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>';
+            $out .= '<OPTION value="method" '.$selected_attr.'>'.$langs->trans('CronType_method').'</OPTION>';
 
-            $out.='</SELECT>';
+            $out .= '</SELECT>';
         }
 
         return $out;

+ 40 - 40
htdocs/core/lib/functions.lib.php

@@ -6061,49 +6061,49 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null,
 
 			if (is_object($object) && $object->element == 'societe')
 			{
-				$substitutionarray['__THIRDPARTY_ID__'] = (is_object($object)?$object->id:'');
-				$substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object)?$object->name:'');
-				$substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object)?$object->name_alias:'');
-				$substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object)?$object->code_client:'');
-				$substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object)?$object->code_fournisseur:'');
-				$substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object)?$object->email:'');
-				$substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object)?$object->phone:'');
-				$substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object)?$object->fax:'');
-				$substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object)?$object->address:'');
-				$substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object)?$object->zip:'');
-				$substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object)?$object->town:'');
-				$substitutionarray['__THIRDPARTY_IDPROF1__'] = (is_object($object)?$object->idprof1:'');
-				$substitutionarray['__THIRDPARTY_IDPROF2__'] = (is_object($object)?$object->idprof2:'');
-				$substitutionarray['__THIRDPARTY_IDPROF3__'] = (is_object($object)?$object->idprof3:'');
-				$substitutionarray['__THIRDPARTY_IDPROF4__'] = (is_object($object)?$object->idprof4:'');
-				$substitutionarray['__THIRDPARTY_IDPROF5__'] = (is_object($object)?$object->idprof5:'');
-				$substitutionarray['__THIRDPARTY_IDPROF6__'] = (is_object($object)?$object->idprof6:'');
-				$substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object)?$object->tva_intra:'');
-				$substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object)?dol_htmlentitiesbr($object->note_public):'');
-				$substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object)?dol_htmlentitiesbr($object->note_private):'');
+				$substitutionarray['__THIRDPARTY_ID__'] = (is_object($object) ? $object->id : '');
+				$substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object) ? $object->name : '');
+				$substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object) ? $object->name_alias : '');
+				$substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object) ? $object->code_client : '');
+				$substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object) ? $object->code_fournisseur : '');
+				$substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object) ? $object->email : '');
+				$substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object) ? $object->phone : '');
+				$substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object) ? $object->fax : '');
+				$substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object) ? $object->address : '');
+				$substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object) ? $object->zip : '');
+				$substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object) ? $object->town : '');
+				$substitutionarray['__THIRDPARTY_IDPROF1__'] = (is_object($object) ? $object->idprof1 : '');
+				$substitutionarray['__THIRDPARTY_IDPROF2__'] = (is_object($object) ? $object->idprof2 : '');
+				$substitutionarray['__THIRDPARTY_IDPROF3__'] = (is_object($object) ? $object->idprof3 : '');
+				$substitutionarray['__THIRDPARTY_IDPROF4__'] = (is_object($object) ? $object->idprof4 : '');
+				$substitutionarray['__THIRDPARTY_IDPROF5__'] = (is_object($object) ? $object->idprof5 : '');
+				$substitutionarray['__THIRDPARTY_IDPROF6__'] = (is_object($object) ? $object->idprof6 : '');
+				$substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object) ? $object->tva_intra : '');
+				$substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object) ?dol_htmlentitiesbr($object->note_public) : '');
+				$substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object) ?dol_htmlentitiesbr($object->note_private) : '');
 			}
 			elseif (is_object($object->thirdparty) && $object->thirdparty->id > 0)
 			{
-				$substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty)?$object->thirdparty->id:'');
-				$substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty)?$object->thirdparty->name:'');
-				$substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty)?$object->thirdparty->name_alias:'');
-				$substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object->thirdparty)?$object->thirdparty->code_client:'');
-				$substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty)?$object->thirdparty->code_fournisseur:'');
-				$substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty)?$object->thirdparty->email:'');
-				$substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty)?$object->thirdparty->phone:'');
-				$substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object->thirdparty)?$object->thirdparty->fax:'');
-				$substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object->thirdparty)?$object->thirdparty->address:'');
-				$substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty)?$object->thirdparty->zip:'');
-				$substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty)?$object->thirdparty->town:'');
-				$substitutionarray['__THIRDPARTY_IDPROF1__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof1:'');
-				$substitutionarray['__THIRDPARTY_IDPROF2__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof2:'');
-				$substitutionarray['__THIRDPARTY_IDPROF3__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof3:'');
-				$substitutionarray['__THIRDPARTY_IDPROF4__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof4:'');
-				$substitutionarray['__THIRDPARTY_IDPROF5__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof5:'');
-				$substitutionarray['__THIRDPARTY_IDPROF6__'] = (is_object($object->thirdparty)?$object->thirdparty->idprof6:'');
-				$substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object->thirdparty)?$object->thirdparty->tva_intra:'');
-				$substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object->thirdparty)?dol_htmlentitiesbr($object->thirdparty->note_public):'');
-				$substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object->thirdparty)?dol_htmlentitiesbr($object->thirdparty->note_private):'');
+				$substitutionarray['__THIRDPARTY_ID__'] = (is_object($object->thirdparty) ? $object->thirdparty->id : '');
+				$substitutionarray['__THIRDPARTY_NAME__'] = (is_object($object->thirdparty) ? $object->thirdparty->name : '');
+				$substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = (is_object($object->thirdparty) ? $object->thirdparty->name_alias : '');
+				$substitutionarray['__THIRDPARTY_CODE_CLIENT__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_client : '');
+				$substitutionarray['__THIRDPARTY_CODE_FOURNISSEUR__'] = (is_object($object->thirdparty) ? $object->thirdparty->code_fournisseur : '');
+				$substitutionarray['__THIRDPARTY_EMAIL__'] = (is_object($object->thirdparty) ? $object->thirdparty->email : '');
+				$substitutionarray['__THIRDPARTY_PHONE__'] = (is_object($object->thirdparty) ? $object->thirdparty->phone : '');
+				$substitutionarray['__THIRDPARTY_FAX__'] = (is_object($object->thirdparty) ? $object->thirdparty->fax : '');
+				$substitutionarray['__THIRDPARTY_ADDRESS__'] = (is_object($object->thirdparty) ? $object->thirdparty->address : '');
+				$substitutionarray['__THIRDPARTY_ZIP__'] = (is_object($object->thirdparty) ? $object->thirdparty->zip : '');
+				$substitutionarray['__THIRDPARTY_TOWN__'] = (is_object($object->thirdparty) ? $object->thirdparty->town : '');
+				$substitutionarray['__THIRDPARTY_IDPROF1__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof1 : '');
+				$substitutionarray['__THIRDPARTY_IDPROF2__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof2 : '');
+				$substitutionarray['__THIRDPARTY_IDPROF3__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof3 : '');
+				$substitutionarray['__THIRDPARTY_IDPROF4__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof4 : '');
+				$substitutionarray['__THIRDPARTY_IDPROF5__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof5 : '');
+				$substitutionarray['__THIRDPARTY_IDPROF6__'] = (is_object($object->thirdparty) ? $object->thirdparty->idprof6 : '');
+				$substitutionarray['__THIRDPARTY_TVAINTRA__'] = (is_object($object->thirdparty) ? $object->thirdparty->tva_intra : '');
+				$substitutionarray['__THIRDPARTY_NOTE_PUBLIC__'] = (is_object($object->thirdparty) ?dol_htmlentitiesbr($object->thirdparty->note_public) : '');
+				$substitutionarray['__THIRDPARTY_NOTE_PRIVATE__'] = (is_object($object->thirdparty) ?dol_htmlentitiesbr($object->thirdparty->note_private) : '');
 			}
 
 			if (is_object($object->project) && $object->project->id > 0)

+ 70 - 70
htdocs/core/modules/modExpedition.class.php

@@ -27,7 +27,7 @@
  *	\brief      Fichier de description et activation du module Expedition
  */
 
-include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
+include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
 
 
 /**
@@ -76,11 +76,11 @@ class modExpedition extends DolibarrModules
 		$this->depends = array("modCommande");
 		$this->requiredby = array();
 		$this->conflictwith = array();
-		$this->langfiles = array('deliveries','sendings');
+		$this->langfiles = array('deliveries', 'sendings');
 
 		// Constants
 		$this->const = array();
-		$r=0;
+		$r = 0;
 
 		$this->const[$r][0] = "EXPEDITION_ADDON_PDF";
 		$this->const[$r][1] = "chaine";
@@ -133,13 +133,13 @@ class modExpedition extends DolibarrModules
 
 		// Boxes
 		$this->boxes = array(
-			0=>array('file'=>'box_shipments.php','enabledbydefaulton'=>'Home'),
+			0=>array('file'=>'box_shipments.php', 'enabledbydefaulton'=>'Home'),
 		);
 
 		// Permissions
 		$this->rights = array();
 		$this->rights_class = 'expedition';
-		$r=0;
+		$r = 0;
 
 		$r++;
 		$this->rights[$r][0] = 101;
@@ -221,92 +221,92 @@ class modExpedition extends DolibarrModules
 
 		// Menus
 		//-------
-		$this->menu = 1;        // This module add menu entries. They are coded into menu manager.
+		$this->menu = 1; // This module add menu entries. They are coded into menu manager.
 
 
 		// Exports
 		//--------
-		$r=0;
+		$r = 0;
 
 		include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
-		$shipment=new Commande($this->db);
-		$contact_arrays=$shipment->liste_type_contact('external', '', 0, 0, '');
-		if (is_array($contact_arrays) && count($contact_arrays)>0){
-			$idcontacts=join(',', array_keys($shipment->liste_type_contact('external', '', 0, 0, '')));
+		$shipment = new Commande($this->db);
+		$contact_arrays = $shipment->liste_type_contact('external', '', 0, 0, '');
+		if (is_array($contact_arrays) && count($contact_arrays) > 0) {
+			$idcontacts = join(',', array_keys($shipment->liste_type_contact('external', '', 0, 0, '')));
 		} else {
-			$idcontacts=0;
+			$idcontacts = 0;
 		}
 
 
 		$r++;
-		$this->export_code[$r]=$this->rights_class.'_'.$r;
-		$this->export_label[$r]='Shipments';	// Translation key (used only if key ExportDataset_xxx_z not found)
-		$this->export_permission[$r]=array(array("expedition","shipment","export"));
-		$this->export_fields_array[$r]=array(
-			's.rowid'=>"IdCompany",'s.nom'=>'ThirdParty','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','d.nom'=>'State','co.label'=>'Country',
-			'co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5',
-			's.idprof6'=>'ProfId6','c.rowid'=>"Id",'c.ref'=>"Ref",'c.ref_customer'=>"RefCustomer",'c.fk_soc'=>"IdCompany",'c.date_creation'=>"DateCreation",
-			'c.date_delivery'=>"DateDeliveryPlanned",'c.tracking_number'=>"TrackingNumber",'c.height'=>"Height",'c.width'=>"Width",'c.size'=>"Depth",
-			'c.size_units'=>'SizeUnits','c.weight'=>"Weight",'c.weight_units'=>"WeightUnits",'c.fk_statut'=>'Status','c.note_public'=>"NotePublic",
-			'ed.rowid'=>'LineId','cd.description'=>'Description','ed.qty'=>"Qty",'p.rowid'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel',
-			'p.weight'=>'ProductWeight','p.weight_units'=>'WeightUnits','p.volume'=>'ProductVolume','p.volume_units'=>'VolumeUnits'
+		$this->export_code[$r] = $this->rights_class.'_'.$r;
+		$this->export_label[$r] = 'Shipments'; // Translation key (used only if key ExportDataset_xxx_z not found)
+		$this->export_permission[$r] = array(array("expedition", "shipment", "export"));
+		$this->export_fields_array[$r] = array(
+			's.rowid'=>"IdCompany", 's.nom'=>'ThirdParty', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town', 'd.nom'=>'State', 'co.label'=>'Country',
+			'co.code'=>'CountryCode', 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5',
+			's.idprof6'=>'ProfId6', 'c.rowid'=>"Id", 'c.ref'=>"Ref", 'c.ref_customer'=>"RefCustomer", 'c.fk_soc'=>"IdCompany", 'c.date_creation'=>"DateCreation",
+			'c.date_delivery'=>"DateDeliveryPlanned", 'c.tracking_number'=>"TrackingNumber", 'c.height'=>"Height", 'c.width'=>"Width", 'c.size'=>"Depth",
+			'c.size_units'=>'SizeUnits', 'c.weight'=>"Weight", 'c.weight_units'=>"WeightUnits", 'c.fk_statut'=>'Status', 'c.note_public'=>"NotePublic",
+			'ed.rowid'=>'LineId', 'cd.description'=>'Description', 'ed.qty'=>"Qty", 'p.rowid'=>'ProductId', 'p.ref'=>'ProductRef', 'p.label'=>'ProductLabel',
+			'p.weight'=>'ProductWeight', 'p.weight_units'=>'WeightUnits', 'p.volume'=>'ProductVolume', 'p.volume_units'=>'VolumeUnits'
 		);
-		if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r]+=array('sp.rowid'=>'IdContact','sp.lastname'=>'Lastname','sp.firstname'=>'Firstname','sp.note_public'=>'NotePublic');
+		if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_fields_array[$r] += array('sp.rowid'=>'IdContact', 'sp.lastname'=>'Lastname', 'sp.firstname'=>'Firstname', 'sp.note_public'=>'NotePublic');
 		//$this->export_TypeFields_array[$r]=array(
 		//	's.rowid'=>"List:societe:nom",'s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label',
 		//	'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_client'=>"Text",
 		//	'c.date_creation'=>"Date",'c.date_commande'=>"Date",'c.amount_ht'=>"Numeric",'c.remise_percent'=>"Numeric",'c.total_ht'=>"Numeric",
 		//	'c.total_ttc'=>"Numeric",'c.facture'=>"Boolean",'c.fk_statut'=>'Status','c.note_public'=>"Text",'c.date_livraison'=>'Date','ed.qty'=>"Text"
 		//);
-		$this->export_TypeFields_array[$r]=array(
-			's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','co.label'=>'List:c_country:label:label','co.code'=>'Text','s.phone'=>'Text',
-			's.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','c.ref'=>"Text",'c.ref_customer'=>"Text",'c.date_creation'=>"Date",
-			'c.date_delivery'=>"Date",'c.tracking_number'=>"Numeric",'c.height'=>"Numeric",'c.width'=>"Numeric",'c.weight'=>"Numeric",'c.fk_statut'=>'Status',
-			'c.note_public'=>"Text",'ed.qty'=>"Numeric",'d.nom'=>'Text'
+		$this->export_TypeFields_array[$r] = array(
+			's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text', 'co.label'=>'List:c_country:label:label', 'co.code'=>'Text', 's.phone'=>'Text',
+			's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 'c.ref'=>"Text", 'c.ref_customer'=>"Text", 'c.date_creation'=>"Date",
+			'c.date_delivery'=>"Date", 'c.tracking_number'=>"Numeric", 'c.height'=>"Numeric", 'c.width'=>"Numeric", 'c.weight'=>"Numeric", 'c.fk_statut'=>'Status',
+			'c.note_public'=>"Text", 'ed.qty'=>"Numeric", 'd.nom'=>'Text'
 		);
-		$this->export_entities_array[$r]=array(
-			's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','d.nom'=>'company','co.label'=>'company',
-			'co.code'=>'company','s.fk_pays'=>'company','s.phone'=>'company','s.siren'=>'company','s.ape'=>'company','s.siret'=>'company','s.idprof4'=>'company',
-			's.idprof5'=>'company','s.idprof6'=>'company','c.rowid'=>"shipment",'c.ref'=>"shipment",'c.ref_customer'=>"shipment",'c.fk_soc'=>"shipment",
-			'c.date_creation'=>"shipment",'c.date_delivery'=>"shipment",'c.tracking_number'=>'shipment','c.height'=>"shipment",'c.width'=>"shipment",
-			'c.size'=>'shipment','c.size_units'=>'shipment','c.weight'=>"shipment",'c.weight_units'=>'shipment','c.fk_statut'=>"shipment",'c.note_public'=>"shipment",
-			'ed.rowid'=>'shipment_line','cd.description'=>'shipment_line','ed.qty'=>"shipment_line",'p.rowid'=>'product','p.ref'=>'product','p.label'=>'product',
-			'p.weight'=>'product','p.weight_units'=>'product','p.volume'=>'product','p.volume_units'=>'product'
+		$this->export_entities_array[$r] = array(
+			's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company', 'd.nom'=>'company', 'co.label'=>'company',
+			'co.code'=>'company', 's.fk_pays'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.ape'=>'company', 's.siret'=>'company', 's.idprof4'=>'company',
+			's.idprof5'=>'company', 's.idprof6'=>'company', 'c.rowid'=>"shipment", 'c.ref'=>"shipment", 'c.ref_customer'=>"shipment", 'c.fk_soc'=>"shipment",
+			'c.date_creation'=>"shipment", 'c.date_delivery'=>"shipment", 'c.tracking_number'=>'shipment', 'c.height'=>"shipment", 'c.width'=>"shipment",
+			'c.size'=>'shipment', 'c.size_units'=>'shipment', 'c.weight'=>"shipment", 'c.weight_units'=>'shipment', 'c.fk_statut'=>"shipment", 'c.note_public'=>"shipment",
+			'ed.rowid'=>'shipment_line', 'cd.description'=>'shipment_line', 'ed.qty'=>"shipment_line", 'p.rowid'=>'product', 'p.ref'=>'product', 'p.label'=>'product',
+			'p.weight'=>'product', 'p.weight_units'=>'product', 'p.volume'=>'product', 'p.volume_units'=>'product'
 		);
-		if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r]+=array('sp.rowid'=>'contact','sp.lastname'=>'contact','sp.firstname'=>'contact','sp.note_public'=>'contact');
-		$this->export_dependencies_array[$r]=array('shipment_line'=>'ed.rowid','product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
-		if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT))
+		if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) $this->export_entities_array[$r] += array('sp.rowid'=>'contact', 'sp.lastname'=>'contact', 'sp.firstname'=>'contact', 'sp.note_public'=>'contact');
+		$this->export_dependencies_array[$r] = array('shipment_line'=>'ed.rowid', 'product'=>'ed.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
+		if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT))
 		{
-		    $keyforselect='socpeople'; $keyforelement='contact'; $keyforaliasextra='extra3';
+		    $keyforselect = 'socpeople'; $keyforelement = 'contact'; $keyforaliasextra = 'extra3';
 		    include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
 		}
-		$keyforselect='expedition'; $keyforelement='shipment'; $keyforaliasextra='extra';
+		$keyforselect = 'expedition'; $keyforelement = 'shipment'; $keyforaliasextra = 'extra';
 		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
-		$keyforselect='expeditiondet'; $keyforelement='shipment_line'; $keyforaliasextra='extra2';
+		$keyforselect = 'expeditiondet'; $keyforelement = 'shipment_line'; $keyforaliasextra = 'extra2';
 		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
-		$keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extraprod';
+		$keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extraprod';
 		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
 
-		$this->export_sql_start[$r]='SELECT DISTINCT ';
-		$this->export_sql_end[$r]  =' FROM '.MAIN_DB_PREFIX.'expedition as c';
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'expedition_extrafields as extra ON c.rowid = extra.fk_object,';
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'societe as s';
-		if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
-		$this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'expeditiondet as ed';
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'expeditiondet_extrafields as extra2 ON ed.rowid = extra2.fk_object';
-		$this->export_sql_end[$r] .=' , '.MAIN_DB_PREFIX.'commandedet as cd';
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid';
-		$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extraprod ON p.rowid = extraprod.fk_object';
-		if ($idcontacts && ! empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) {
-		    $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')';
-		    $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople';
-		    $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';
+		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
+		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'expedition as c';
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expedition_extrafields as extra ON c.rowid = extra.fk_object,';
+		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'societe as s';
+		if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON s.fk_departement = d.rowid';
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON s.fk_pays = co.rowid,';
+		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'expeditiondet as ed';
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'expeditiondet_extrafields as extra2 ON ed.rowid = extra2.fk_object';
+		$this->export_sql_end[$r] .= ' , '.MAIN_DB_PREFIX.'commandedet as cd';
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on cd.fk_product = p.rowid';
+		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extraprod ON p.rowid = extraprod.fk_object';
+		if ($idcontacts && !empty($conf->global->SHIPMENT_ADD_CONTACTS_IN_EXPORT)) {
+		    $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'element_contact as ee ON ee.element_id = cd.fk_commande AND ee.fk_c_type_contact IN ('.$idcontacts.')';
+		    $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp ON sp.rowid = ee.fk_socpeople';
+		    $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople_extrafields as extra3 ON sp.rowid = extra3.fk_object';
 		}
-		$this->export_sql_end[$r] .=' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid';
-		$this->export_sql_end[$r] .=' AND c.entity IN ('.getEntity('expedition').')';
-		if(!$user->rights->societe->client->voir) $this->export_sql_end[$r] .=' AND sc.fk_user = '.$user->id;
+		$this->export_sql_end[$r] .= ' WHERE c.fk_soc = s.rowid AND c.rowid = ed.fk_expedition AND ed.fk_origin_line = cd.rowid';
+		$this->export_sql_end[$r] .= ' AND c.entity IN ('.getEntity('expedition').')';
+		if (!$user->rights->societe->client->voir) $this->export_sql_end[$r] .= ' AND sc.fk_user = '.$user->id;
 	}
 
 
@@ -320,25 +320,25 @@ class modExpedition extends DolibarrModules
 	 */
 	public function init($options = '')
 	{
-		global $conf,$langs;
+		global $conf, $langs;
 
 		// Permissions
 		$this->remove($options);
 
 		//ODT template
-		$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/shipment/template_shipment.odt';
-		$dirodt=DOL_DATA_ROOT.'/doctemplates/shipment';
-		$dest=$dirodt.'/template_shipment.odt';
+		$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/shipment/template_shipment.odt';
+		$dirodt = DOL_DATA_ROOT.'/doctemplates/shipment';
+		$dest = $dirodt.'/template_shipment.odt';
 
-		if (file_exists($src) && ! file_exists($dest))
+		if (file_exists($src) && !file_exists($dest))
 		{
 			require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 			dol_mkdir($dirodt);
-			$result=dol_copy($src, $dest, 0, 0);
+			$result = dol_copy($src, $dest, 0, 0);
 			if ($result < 0)
 			{
 				$langs->load("errors");
-				$this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
+				$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
 				return 0;
 			}
 		}

+ 39 - 39
htdocs/main.inc.php

@@ -880,7 +880,7 @@ if (!defined('NOLOGIN'))
 if (GETPOST('theme', 'alpha'))
 {
 	$conf->theme = GETPOST('theme', 'alpha', 1);
-	$conf->css  = "/theme/".$conf->theme."/style.css.php";
+	$conf->css = "/theme/".$conf->theme."/style.css.php";
 }
 
 
@@ -926,7 +926,7 @@ if (!empty($conf->dol_use_jmobile)) $conf->use_javascript_ajax = 1;
 if (!empty($conf->dol_use_jmobile) && in_array($conf->theme, array('bureau2crea', 'cameleo', 'amarok')))
 {
 	$conf->theme = 'eldy';
-	$conf->css  = "/theme/".$conf->theme."/style.css.php";
+	$conf->css = "/theme/".$conf->theme."/style.css.php";
 }
 
 if (!defined('NOREQUIRETRAN'))
@@ -1361,93 +1361,93 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr
 		}
 
 		// Output standard javascript links
-		if (! defined('DISABLE_JQUERY') && ! $disablejs && ! empty($conf->use_javascript_ajax))
+		if (!defined('DISABLE_JQUERY') && !$disablejs && !empty($conf->use_javascript_ajax))
 		{
 			// JQuery. Must be before other includes
 			print '<!-- Includes JS for JQuery -->'."\n";
-			if (defined('JS_JQUERY') && constant('JS_JQUERY')) print '<script src="'.JS_JQUERY.'jquery.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
-			else print '<script src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
+			if (defined('JS_JQUERY') && constant('JS_JQUERY')) print '<script src="'.JS_JQUERY.'jquery.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
+			else print '<script src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
 			/*if (! empty($conf->global->MAIN_FEATURES_LEVEL) && ! defined('JS_JQUERY_MIGRATE_DISABLED'))
 			{
 				if (defined('JS_JQUERY_MIGRATE') && constant('JS_JQUERY_MIGRATE')) print '<script src="'.JS_JQUERY_MIGRATE.'jquery-migrate.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
 				else print '<script src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-migrate.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
 			}*/
-			if (defined('JS_JQUERY_UI') && constant('JS_JQUERY_UI')) print '<script src="'.JS_JQUERY_UI.'jquery-ui.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
-			else print '<script src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-ui.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
-			if (! defined('DISABLE_JQUERY_TABLEDND')) print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/tablednd/jquery.tablednd.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
+			if (defined('JS_JQUERY_UI') && constant('JS_JQUERY_UI')) print '<script src="'.JS_JQUERY_UI.'jquery-ui.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
+			else print '<script src="'.DOL_URL_ROOT.'/includes/jquery/js/jquery-ui.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
+			if (!defined('DISABLE_JQUERY_TABLEDND')) print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/tablednd/jquery.tablednd.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
 			// jQuery jnotify
-			if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && ! defined('DISABLE_JQUERY_JNOTIFY'))
+			if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && !defined('DISABLE_JQUERY_JNOTIFY'))
 			{
-				print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jnotify/jquery.jnotify.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
+				print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jnotify/jquery.jnotify.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
 			}
 			// Flot
-			if (empty($conf->global->MAIN_DISABLE_JQUERY_FLOT) && ! defined('DISABLE_JQUERY_FLOT'))
+			if (empty($conf->global->MAIN_DISABLE_JQUERY_FLOT) && !defined('DISABLE_JQUERY_FLOT'))
 			{
 				if (constant('JS_JQUERY_FLOT'))
 				{
-					print '<script src="'.JS_JQUERY_FLOT.'jquery.flot.js'.($ext?'?'.$ext:'').'"></script>'."\n";
-					print '<script src="'.JS_JQUERY_FLOT.'jquery.flot.pie.js'.($ext?'?'.$ext:'').'"></script>'."\n";
-					print '<script src="'.JS_JQUERY_FLOT.'jquery.flot.stack.js'.($ext?'?'.$ext:'').'"></script>'."\n";
+					print '<script src="'.JS_JQUERY_FLOT.'jquery.flot.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
+					print '<script src="'.JS_JQUERY_FLOT.'jquery.flot.pie.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
+					print '<script src="'.JS_JQUERY_FLOT.'jquery.flot.stack.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
 				}
 				else
 				{
-					print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
-					print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.pie.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
-					print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.stack.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";
+					print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
+					print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.pie.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
+					print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/flot/jquery.flot.stack.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
 				}
 			}
 			// jQuery jeditable
-			if (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && ! defined('DISABLE_JQUERY_JEDITABLE'))
+			if (!empty($conf->global->MAIN_USE_JQUERY_JEDITABLE) && !defined('DISABLE_JQUERY_JEDITABLE'))
 			{
 				print '<!-- JS to manage editInPlace feature -->'."\n";
-				print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.js'.($ext?'?'.$ext:'').'"></script>'."\n";
-				print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.ui-datepicker.js'.($ext?'?'.$ext:'').'"></script>'."\n";
-				print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.ui-autocomplete.js'.($ext?'?'.$ext:'').'"></script>'."\n";
+				print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
+				print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.ui-datepicker.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
+				print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.ui-autocomplete.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
 				print '<script>'."\n";
 				print 'var urlSaveInPlace = \''.DOL_URL_ROOT.'/core/ajax/saveinplace.php\';'."\n";
 				print 'var urlLoadInPlace = \''.DOL_URL_ROOT.'/core/ajax/loadinplace.php\';'."\n";
-				print 'var tooltipInPlace = \''.$langs->transnoentities('ClickToEdit').'\';'."\n";	// Added in title attribute of span
-				print 'var placeholderInPlace = \'&nbsp;\';'."\n";	// If we put another string than $langs->trans("ClickToEdit") here, nothing is shown. If we put empty string, there is error, Why ?
+				print 'var tooltipInPlace = \''.$langs->transnoentities('ClickToEdit').'\';'."\n"; // Added in title attribute of span
+				print 'var placeholderInPlace = \'&nbsp;\';'."\n"; // If we put another string than $langs->trans("ClickToEdit") here, nothing is shown. If we put empty string, there is error, Why ?
 				print 'var cancelInPlace = \''.$langs->trans('Cancel').'\';'."\n";
 				print 'var submitInPlace = \''.$langs->trans('Ok').'\';'."\n";
 				print 'var indicatorInPlace = \'<img src="'.DOL_URL_ROOT."/theme/".$conf->theme."/img/working.gif".'">\';'."\n";
-				print 'var withInPlace = 300;';		// width in pixel for default string edit
+				print 'var withInPlace = 300;'; // width in pixel for default string edit
 				print '</script>'."\n";
-				print '<script src="'.DOL_URL_ROOT.'/core/js/editinplace.js'.($ext?'?'.$ext:'').'"></script>'."\n";
-				print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.ckeditor.js'.($ext?'?'.$ext:'').'"></script>'."\n";
+				print '<script src="'.DOL_URL_ROOT.'/core/js/editinplace.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
+				print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/jeditable/jquery.jeditable.ckeditor.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
 			}
             // jQuery Timepicker
-            if (! empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER'))
+            if (!empty($conf->global->MAIN_USE_JQUERY_TIMEPICKER) || defined('REQUIRE_JQUERY_TIMEPICKER'))
             {
-            	print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.js'.($ext?'?'.$ext:'').'"></script>'."\n";
-            	print '<script src="'.DOL_URL_ROOT.'/core/js/timepicker.js.php?lang='.$langs->defaultlang.($ext?'&amp;'.$ext:'').'"></script>'."\n";
+            	print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/timepicker/jquery-ui-timepicker-addon.js'.($ext ? '?'.$ext : '').'"></script>'."\n";
+            	print '<script src="'.DOL_URL_ROOT.'/core/js/timepicker.js.php?lang='.$langs->defaultlang.($ext ? '&amp;'.$ext : '').'"></script>'."\n";
             }
-            if (! defined('DISABLE_SELECT2') && (! empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')))     // jQuery plugin "mutiselect", "multiple-select", "select2", ...
+            if (!defined('DISABLE_SELECT2') && (!empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) || defined('REQUIRE_JQUERY_MULTISELECT')))     // jQuery plugin "mutiselect", "multiple-select", "select2", ...
             {
-            	$tmpplugin=empty($conf->global->MAIN_USE_JQUERY_MULTISELECT)?constant('REQUIRE_JQUERY_MULTISELECT'):$conf->global->MAIN_USE_JQUERY_MULTISELECT;
-            	print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/'.$tmpplugin.'/dist/js/'.$tmpplugin.'.full.min.js'.($ext?'?'.$ext:'').'"></script>'."\n";	// We include full because we need the support of containerCssClass
+            	$tmpplugin = empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) ?constant('REQUIRE_JQUERY_MULTISELECT') : $conf->global->MAIN_USE_JQUERY_MULTISELECT;
+            	print '<script src="'.DOL_URL_ROOT.'/includes/jquery/plugins/'.$tmpplugin.'/dist/js/'.$tmpplugin.'.full.min.js'.($ext ? '?'.$ext : '').'"></script>'."\n"; // We include full because we need the support of containerCssClass
             }
 		}
 
-        if (! $disablejs && ! empty($conf->use_javascript_ajax))
+        if (!$disablejs && !empty($conf->use_javascript_ajax))
         {
             // CKEditor
-            if (! empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') && ! defined('DISABLE_CKEDITOR'))
+            if (!empty($conf->fckeditor->enabled) && (empty($conf->global->FCKEDITOR_EDITORNAME) || $conf->global->FCKEDITOR_EDITORNAME == 'ckeditor') && !defined('DISABLE_CKEDITOR'))
             {
                 print '<!-- Includes JS for CKEditor -->'."\n";
-                $pathckeditor = DOL_URL_ROOT . '/includes/ckeditor/ckeditor/';
-                $jsckeditor='ckeditor.js';
+                $pathckeditor = DOL_URL_ROOT.'/includes/ckeditor/ckeditor/';
+                $jsckeditor = 'ckeditor.js';
                 if (constant('JS_CKEDITOR'))	// To use external ckeditor 4 js lib
                 {
-                	$pathckeditor=constant('JS_CKEDITOR');
+                	$pathckeditor = constant('JS_CKEDITOR');
                 }
                 print '<script><!-- enable ckeditor by main.inc.php -->';
                 print 'var CKEDITOR_BASEPATH = \''.$pathckeditor.'\';'."\n";
-                print 'var ckeditorConfig = \''.dol_buildpath($themesubdir.'/theme/'.$conf->theme.'/ckeditor/config.js'.($ext?'?'.$ext:''), 1).'\';'."\n";		// $themesubdir='' in standard usage
+                print 'var ckeditorConfig = \''.dol_buildpath($themesubdir.'/theme/'.$conf->theme.'/ckeditor/config.js'.($ext ? '?'.$ext : ''), 1).'\';'."\n"; // $themesubdir='' in standard usage
                 print 'var ckeditorFilebrowserBrowseUrl = \''.DOL_URL_ROOT.'/core/filemanagerdol/browser/default/browser.php?Connector='.DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php\';'."\n";
                 print 'var ckeditorFilebrowserImageBrowseUrl = \''.DOL_URL_ROOT.'/core/filemanagerdol/browser/default/browser.php?Type=Image&Connector='.DOL_URL_ROOT.'/core/filemanagerdol/connectors/php/connector.php\';'."\n";
                 print '</script>'."\n";
-                print '<script src="'.$pathckeditor.$jsckeditor.($ext?'?'.$ext:'').'"></script>'."\n";
+                print '<script src="'.$pathckeditor.$jsckeditor.($ext ? '?'.$ext : '').'"></script>'."\n";
                 print '<script>';
                 if (GETPOST('mode', 'aZ09') == 'Full_inline')
                 {

+ 40 - 40
htdocs/mrp/mo_agenda.php

@@ -33,32 +33,32 @@ dol_include_once('/mrp/lib/mrp_mo.lib.php');
 
 
 // Load translation files required by the page
-$langs->loadLangs(array("mrp","other"));
+$langs->loadLangs(array("mrp", "other"));
 
 // Get parameters
-$id			= GETPOST('id', 'int');
+$id = GETPOST('id', 'int');
 $ref        = GETPOST('ref', 'alpha');
-$action		= GETPOST('action', 'alpha');
+$action = GETPOST('action', 'alpha');
 $cancel     = GETPOST('cancel', 'aZ09');
 $backtopage = GETPOST('backtopage', 'alpha');
 
 if (GETPOST('actioncode', 'array'))
 {
-    $actioncode=GETPOST('actioncode', 'array', 3);
-    if (! count($actioncode)) $actioncode='0';
+    $actioncode = GETPOST('actioncode', 'array', 3);
+    if (!count($actioncode)) $actioncode = '0';
 }
 else
 {
-    $actioncode=GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
+    $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
 }
-$search_agenda_label=GETPOST('search_agenda_label');
+$search_agenda_label = GETPOST('search_agenda_label');
 
 // Security check - Protection if external user
 //if ($user->socid > 0) accessforbidden();
 //if ($user->socid > 0) $socid = $user->socid;
 //$result = restrictedArea($user, 'mrp', $id);
 
-$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
 $sortfield = GETPOST("sortfield", 'alpha');
 $sortorder = GETPOST("sortorder", 'alpha');
 $page = GETPOST("page", 'int');
@@ -66,21 +66,21 @@ if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined,
 $offset = $limit * $page;
 $pageprev = $page - 1;
 $pagenext = $page + 1;
-if (! $sortfield) $sortfield='a.datep,a.id';
-if (! $sortorder) $sortorder='DESC';
+if (!$sortfield) $sortfield = 'a.datep,a.id';
+if (!$sortorder) $sortorder = 'DESC';
 
 // Initialize technical objects
-$object=new Mo($db);
+$object = new Mo($db);
 $extrafields = new ExtraFields($db);
-$diroutputmassaction=$conf->mrp->dir_output . '/temp/massgeneration/'.$user->id;
-$hookmanager->initHooks(array('moagenda','globalcard'));     // Note that conf->hooks_modules contains array
+$diroutputmassaction = $conf->mrp->dir_output.'/temp/massgeneration/'.$user->id;
+$hookmanager->initHooks(array('moagenda', 'globalcard')); // Note that conf->hooks_modules contains array
 
 // Fetch optionals attributes and labels
 $extrafields->fetch_name_optionals_label($object->table_element);
 
 // Load object
-include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php';  // Must be include, not include_once  // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
-if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity] . "/" . $object->id;
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once  // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
+if ($id > 0 || !empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object->entity]."/".$object->id;
 
 
 
@@ -88,14 +88,14 @@ if ($id > 0 || ! empty($ref)) $upload_dir = $conf->mrp->multidir_output[$object-
  *	Actions
  */
 
-$parameters=array('id'=>$socid);
-$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action);    // Note that $action and $object may have been modified by some hooks
+$parameters = array('id'=>$socid);
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
 
 if (empty($reshook))
 {
     // Cancel
-    if (GETPOST('cancel', 'alpha') && ! empty($backtopage))
+    if (GETPOST('cancel', 'alpha') && !empty($backtopage))
     {
         header("Location: ".$backtopage);
         exit;
@@ -104,8 +104,8 @@ if (empty($reshook))
     // Purge search criteria
     if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
     {
-        $actioncode='';
-        $search_agenda_label='';
+        $actioncode = '';
+        $search_agenda_label = '';
     }
 }
 
@@ -121,12 +121,12 @@ $form = new Form($db);
 
 if ($object->id > 0)
 {
-	$title=$langs->trans("Agenda");
+	$title = $langs->trans("Agenda");
 	//if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
 	$help_url = '';
 	llxHeader('', $title, $help_url);
 
-	if (! empty($conf->notification->enabled)) $langs->load("mails");
+	if (!empty($conf->notification->enabled)) $langs->load("mails");
 	$head = moPrepareHead($object);
 
 
@@ -134,9 +134,9 @@ if ($object->id > 0)
 
 	// Object card
 	// ------------------------------------------------------------
-	$linkback = '<a href="' .dol_buildpath('/mrp/mo_list.php', 1) . '?restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
+	$linkback = '<a href="'.dol_buildpath('/mrp/mo_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
 
-	$morehtmlref='<div class="refidno">';
+	$morehtmlref = '<div class="refidno">';
 	/*
 	 // Ref customer
 	 $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, 0, 'string', '', 0, 1);
@@ -176,7 +176,7 @@ if ($object->id > 0)
 	 	}
 	 	}
 	 	}*/
-	$morehtmlref.='</div>';
+	$morehtmlref .= '</div>';
 
 
 	dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@@ -195,16 +195,16 @@ if ($object->id > 0)
 
 	// Actions buttons
 
-    $objthirdparty=$object;
-    $objcon=new stdClass();
+    $objthirdparty = $object;
+    $objcon = new stdClass();
 
-    $out='&origin='.$object->element.'&originid='.$object->id;
-    $permok=$user->rights->agenda->myactions->create;
-    if ((! empty($objthirdparty->id) || ! empty($objcon->id)) && $permok)
+    $out = '&origin='.$object->element.'&originid='.$object->id;
+    $permok = $user->rights->agenda->myactions->create;
+    if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok)
     {
         //$out.='<a href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create';
-        if (get_class($objthirdparty) == 'Societe') $out.='&amp;socid='.$objthirdparty->id;
-        $out.=(! empty($objcon->id)?'&amp;contactid='.$objcon->id:'').'&amp;backtopage=1&amp;percentage=-1';
+        if (get_class($objthirdparty) == 'Societe') $out .= '&amp;socid='.$objthirdparty->id;
+        $out .= (!empty($objcon->id) ? '&amp;contactid='.$objcon->id : '').'&amp;backtopage=1&amp;percentage=-1';
     	//$out.=$langs->trans("AddAnAction").' ';
     	//$out.=img_picto($langs->trans("AddAnAction"),'filenew');
     	//$out.="</a>";
@@ -213,9 +213,9 @@ if ($object->id > 0)
 
 	print '<div class="tabsAction">';
 
-    if (! empty($conf->agenda->enabled))
+    if (!empty($conf->agenda->enabled))
     {
-    	if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create))
+    	if (!empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create))
     	{
         	print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>';
     	}
@@ -227,18 +227,18 @@ if ($object->id > 0)
 
     print '</div>';
 
-    if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
+    if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
     {
-        $param='&id='.$object->id.'&socid='.$socid;
-        if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
-        if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
+        $param = '&id='.$object->id.'&socid='.$socid;
+        if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
+        if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
 
 
 		//print load_fiche_titre($langs->trans("ActionsOnMo"), '', '');
 
         // List of all actions
-		$filters=array();
-        $filters['search_agenda_label']=$search_agenda_label;
+		$filters = array();
+        $filters['search_agenda_label'] = $search_agenda_label;
 
         // TODO Replace this with same code than into list.php
         //show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder);

+ 93 - 93
htdocs/product/class/api_products.class.php

@@ -171,40 +171,40 @@ class Products extends DolibarrApi
         $socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : '';
 
         $sql = "SELECT t.rowid, t.ref, t.ref_ext";
-        $sql.= " FROM ".MAIN_DB_PREFIX."product as t";
+        $sql .= " FROM ".MAIN_DB_PREFIX."product as t";
         if ($category > 0) {
-            $sql.= ", ".MAIN_DB_PREFIX."categorie_product as c";
+            $sql .= ", ".MAIN_DB_PREFIX."categorie_product as c";
         }
-        $sql.= ' WHERE t.entity IN ('.getEntity('product').')';
+        $sql .= ' WHERE t.entity IN ('.getEntity('product').')';
         // Select products of given category
         if ($category > 0) {
-            $sql.= " AND c.fk_categorie = ".$db->escape($category);
-            $sql.= " AND c.fk_product = t.rowid ";
+            $sql .= " AND c.fk_categorie = ".$db->escape($category);
+            $sql .= " AND c.fk_product = t.rowid ";
         }
         if ($mode == 1) {
             // Show only products
-            $sql.= " AND t.fk_product_type = 0";
+            $sql .= " AND t.fk_product_type = 0";
         } elseif ($mode == 2) {
             // Show only services
-            $sql.= " AND t.fk_product_type = 1";
+            $sql .= " AND t.fk_product_type = 1";
         }
         // Add sql filters
         if ($sqlfilters) {
-            if (! DolibarrApi::_checkFilters($sqlfilters)) {
+            if (!DolibarrApi::_checkFilters($sqlfilters)) {
                 throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
             }
-            $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
-            $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
+            $regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
+            $sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
         }
 
-        $sql.= $db->order($sortfield, $sortorder);
+        $sql .= $db->order($sortfield, $sortorder);
         if ($limit) {
             if ($page < 0) {
                 $page = 0;
             }
             $offset = $limit * $page;
 
-            $sql.= $db->plimit($limit + 1, $offset);
+            $sql .= $db->plimit($limit + 1, $offset);
         }
 
         $result = $db->query($sql);
@@ -216,7 +216,7 @@ class Products extends DolibarrApi
             {
                 $obj = $db->fetch_object($result);
                 $product_static = new Product($db);
-                if($product_static->fetch($obj->rowid)) {
+                if ($product_static->fetch($obj->rowid)) {
                     $obj_ret[] = $this->_cleanObjectDatas($product_static);
                 }
                 $i++;
@@ -225,7 +225,7 @@ class Products extends DolibarrApi
         else {
             throw new RestException(503, 'Error when retrieve product list : '.$db->lasterror());
         }
-        if(! count($obj_ret)) {
+        if (!count($obj_ret)) {
             throw new RestException(404, 'No product found');
         }
         return $obj_ret;
@@ -239,13 +239,13 @@ class Products extends DolibarrApi
      */
     public function post($request_data = null)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->creer) {
+        if (!DolibarrApiAccess::$user->rights->produit->creer) {
             throw new RestException(401);
         }
         // Check mandatory fields
         $result = $this->_validate($request_data);
 
-        foreach($request_data as $field => $value) {
+        foreach ($request_data as $field => $value) {
             $this->product->$field = $value;
         }
         if ($this->product->create(DolibarrApiAccess::$user) < 0) {
@@ -271,22 +271,22 @@ class Products extends DolibarrApi
     {
         global $conf;
 
-        if(! DolibarrApiAccess::$user->rights->produit->creer) {
+        if (!DolibarrApiAccess::$user->rights->produit->creer) {
             throw new RestException(401);
         }
 
         $result = $this->product->fetch($id);
-        if(! $result ) {
+        if (!$result) {
             throw new RestException(404, 'Product not found');
         }
 
-        if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) {
+        if (!DolibarrApi::_checkAccessToResource('product', $this->product->id)) {
             throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
         }
 
         $oldproduct = dol_clone($this->product, 0);
 
-        foreach($request_data as $field => $value) {
+        foreach ($request_data as $field => $value) {
             if ($field == 'id') { continue;
             }
             $this->product->$field = $value;
@@ -300,7 +300,7 @@ class Products extends DolibarrApi
         $result = $this->product->update($id, DolibarrApiAccess::$user, 1, 'update', $updatetype);
 
         // If price mode is 1 price per product
-        if ($result > 0 && ! empty($conf->global->PRODUCT_PRICE_UNIQ)) {
+        if ($result > 0 && !empty($conf->global->PRODUCT_PRICE_UNIQ)) {
             // We update price only if it was changed
             $pricemodified = false;
             if ($this->product->price_base_type != $oldproduct->price_base_type) { $pricemodified = true;
@@ -359,15 +359,15 @@ class Products extends DolibarrApi
      */
     public function delete($id)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->supprimer) {
+        if (!DolibarrApiAccess::$user->rights->produit->supprimer) {
             throw new RestException(401);
         }
         $result = $this->product->fetch($id);
-        if(! $result ) {
+        if (!$result) {
             throw new RestException(404, 'Product not found');
         }
 
-        if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) {
+        if (!DolibarrApi::_checkAccessToResource('product', $this->product->id)) {
             throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
         }
 
@@ -392,11 +392,11 @@ class Products extends DolibarrApi
      */
     public function getSubproducts($id)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->lire) {
+        if (!DolibarrApiAccess::$user->rights->produit->lire) {
             throw new RestException(401);
         }
 
-        if(! DolibarrApi::_checkAccessToResource('product', $id)) {
+        if (!DolibarrApi::_checkAccessToResource('product', $id)) {
             throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
         }
 
@@ -430,11 +430,11 @@ class Products extends DolibarrApi
      */
     public function addSubproducts($id, $subproduct_id, $qty, $incdec = 1)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->creer) {
+        if (!DolibarrApiAccess::$user->rights->produit->creer) {
             throw new RestException(401);
         }
 
-        if(! DolibarrApi::_checkAccessToResource('product', $id)) {
+        if (!DolibarrApi::_checkAccessToResource('product', $id)) {
             throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
         }
 
@@ -462,11 +462,11 @@ class Products extends DolibarrApi
      */
     public function delSubproducts($id, $subproduct_id)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->creer) {
+        if (!DolibarrApiAccess::$user->rights->produit->creer) {
             throw new RestException(401);
         }
 
-        if(! DolibarrApi::_checkAccessToResource('product', $id)) {
+        if (!DolibarrApi::_checkAccessToResource('product', $id)) {
             throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
         }
 
@@ -493,7 +493,7 @@ class Products extends DolibarrApi
      */
     public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
     {
-        if (! DolibarrApiAccess::$user->rights->categorie->lire) {
+        if (!DolibarrApiAccess::$user->rights->categorie->lire) {
             throw new RestException(401);
         }
 
@@ -525,7 +525,7 @@ class Products extends DolibarrApi
     {
         global $conf;
 
-        if (! DolibarrApiAccess::$user->rights->produit->lire) {
+        if (!DolibarrApiAccess::$user->rights->produit->lire) {
             throw new RestException(401);
         }
 
@@ -534,7 +534,7 @@ class Products extends DolibarrApi
         }
 
         $result = $this->product->fetch($id);
-        if (! $result ) {
+        if (!$result) {
             throw new RestException(404, 'Product not found');
         }
 
@@ -567,7 +567,7 @@ class Products extends DolibarrApi
     {
         global $conf;
 
-        if (! DolibarrApiAccess::$user->rights->produit->lire) {
+        if (!DolibarrApiAccess::$user->rights->produit->lire) {
             throw new RestException(401);
         }
 
@@ -576,12 +576,12 @@ class Products extends DolibarrApi
         }
 
         $result = $this->product->fetch($id);
-        if (! $result ) {
+        if (!$result) {
             throw new RestException(404, 'Product not found');
         }
 
         if ($result > 0) {
-			require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
+			require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
 			$prodcustprice = new Productcustomerprice($this->db);
 			$filter = array();
 			$filter['t.fk_product'] .= $id;
@@ -589,7 +589,7 @@ class Products extends DolibarrApi
 			$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
         }
 
-        if ( empty($prodcustprice->lines)) {
+        if (empty($prodcustprice->lines)) {
             throw new RestException(404, 'Prices not found');
         }
 
@@ -609,7 +609,7 @@ class Products extends DolibarrApi
     {
         global $conf;
 
-        if (! DolibarrApiAccess::$user->rights->produit->lire) {
+        if (!DolibarrApiAccess::$user->rights->produit->lire) {
             throw new RestException(401);
         }
 
@@ -618,7 +618,7 @@ class Products extends DolibarrApi
         }
 
         $result = $this->product->fetch($id);
-        if (! $result ) {
+        if (!$result) {
             throw new RestException(404, 'Product not found');
         }
 
@@ -627,7 +627,7 @@ class Products extends DolibarrApi
         }
 
         return array(
-        'prices_by_qty'=>$this->product->prices_by_qty[0],                // 1 if price by quantity was activated for the product
+        'prices_by_qty'=>$this->product->prices_by_qty[0], // 1 if price by quantity was activated for the product
         'prices_by_qty_list'=>$this->product->prices_by_qty_list[0]
         );
     }
@@ -648,15 +648,15 @@ class Products extends DolibarrApi
      */
     public function deletePurchasePrice($id, $priceid)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->supprimer) {
+        if (!DolibarrApiAccess::$user->rights->produit->supprimer) {
             throw new RestException(401);
         }
         $result = $this->product->fetch($id);
-        if(! $result ) {
+        if (!$result) {
             throw new RestException(404, 'Product not found');
         }
 
-        if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) {
+        if (!DolibarrApi::_checkAccessToResource('product', $this->product->id)) {
             throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
         }
         $resultsupplier = 0;
@@ -691,45 +691,45 @@ class Products extends DolibarrApi
     	$obj_ret = array();
     	$socid = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : '';
     	$sql = "SELECT t.rowid, t.ref, t.ref_ext";
-    	$sql.= " FROM ".MAIN_DB_PREFIX."product as t";
+    	$sql .= " FROM ".MAIN_DB_PREFIX."product as t";
     	if ($category > 0) {
-    		$sql.= ", ".MAIN_DB_PREFIX."categorie_product as c";
+    		$sql .= ", ".MAIN_DB_PREFIX."categorie_product as c";
     	}
-    	$sql.= ", ".MAIN_DB_PREFIX."product_fournisseur_price as s";
+    	$sql .= ", ".MAIN_DB_PREFIX."product_fournisseur_price as s";
 
-    	$sql.= ' WHERE t.entity IN ('.getEntity('product').')';
+    	$sql .= ' WHERE t.entity IN ('.getEntity('product').')';
 
     	if ($supplier > 0) {
-    		$sql.= " AND s.fk_soc = ".$db->escape($supplier);
+    		$sql .= " AND s.fk_soc = ".$db->escape($supplier);
     	}
-    	$sql.= " AND s.fk_product = t.rowid ";
+    	$sql .= " AND s.fk_product = t.rowid ";
     	// Select products of given category
     	if ($category > 0) {
-    		$sql.= " AND c.fk_categorie = ".$db->escape($category);
-    		$sql.= " AND c.fk_product = t.rowid ";
+    		$sql .= " AND c.fk_categorie = ".$db->escape($category);
+    		$sql .= " AND c.fk_product = t.rowid ";
     	}
     	if ($mode == 1) {
     		// Show only products
-    		$sql.= " AND t.fk_product_type = 0";
+    		$sql .= " AND t.fk_product_type = 0";
     	} elseif ($mode == 2) {
     		// Show only services
-    		$sql.= " AND t.fk_product_type = 1";
+    		$sql .= " AND t.fk_product_type = 1";
     	}
     	// Add sql filters
     	if ($sqlfilters) {
-    		if (! DolibarrApi::_checkFilters($sqlfilters)) {
+    		if (!DolibarrApi::_checkFilters($sqlfilters)) {
     			throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
     		}
-    		$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
-    		$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
+    		$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
+    		$sql .= " AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
     	}
-    	$sql.= $db->order($sortfield, $sortorder);
+    	$sql .= $db->order($sortfield, $sortorder);
     	if ($limit) {
     		if ($page < 0) {
     			$page = 0;
     		}
     		$offset = $limit * $page;
-    		$sql.= $db->plimit($limit + 1, $offset);
+    		$sql .= $db->plimit($limit + 1, $offset);
     	}
     	$result = $db->query($sql);
     	if ($result) {
@@ -740,7 +740,7 @@ class Products extends DolibarrApi
     		{
     			$obj = $db->fetch_object($result);
     			$product_static = new Product($db);
-    			if($product_static->fetch($obj->rowid)) {
+    			if ($product_static->fetch($obj->rowid)) {
     				$obj_ret[] = $this->_cleanObjectDatas($product_static);
     			}
     			$i++;
@@ -749,7 +749,7 @@ class Products extends DolibarrApi
     	else {
     		throw new RestException(503, 'Error when retrieve product list : '.$db->lasterror());
     	}
-    	if(! count($obj_ret)) {
+    	if (!count($obj_ret)) {
     		throw new RestException(404, 'No product found');
     	}
     	return $obj_ret;
@@ -814,7 +814,7 @@ class Products extends DolibarrApi
      */
     public function getAttributes()
     {
-        if(! DolibarrApiAccess::$user->rights->produit->lire) {
+        if (!DolibarrApiAccess::$user->rights->produit->lire) {
             throw new RestException(401);
         }
 
@@ -836,14 +836,14 @@ class Products extends DolibarrApi
      */
     public function getAttributeById($id)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->lire) {
+        if (!DolibarrApiAccess::$user->rights->produit->lire) {
             throw new RestException(401);
         }
 
         $prodattr = new ProductAttribute($this->db);
         $result = $prodattr->fetch((int) $id);
 
-        if($result < 0) {
+        if ($result < 0) {
             throw new RestException(404, "Attribute not found");
         }
 
@@ -863,11 +863,11 @@ class Products extends DolibarrApi
      */
     public function getAttributesByRef($ref)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->lire) {
+        if (!DolibarrApiAccess::$user->rights->produit->lire) {
             throw new RestException(401);
         }
 
-        $sql = "SELECT rowid, ref, label, rang FROM ".MAIN_DB_PREFIX."product_attribute WHERE ref LIKE '". trim($ref) ."' AND entity IN (".getEntity('product').")";
+        $sql = "SELECT rowid, ref, label, rang FROM ".MAIN_DB_PREFIX."product_attribute WHERE ref LIKE '".trim($ref)."' AND entity IN (".getEntity('product').")";
 
         $query = $this->db->query($sql);
 
@@ -900,7 +900,7 @@ class Products extends DolibarrApi
      */
     public function addAttributes($ref, $label)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->creer) {
+        if (!DolibarrApiAccess::$user->rights->produit->creer) {
             throw new RestException(401);
         }
 
@@ -930,7 +930,7 @@ class Products extends DolibarrApi
      */
     public function putAttributes($id, $request_data = null)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->creer) {
+        if (!DolibarrApiAccess::$user->rights->produit->creer) {
             throw new RestException(401);
         }
 
@@ -943,7 +943,7 @@ class Products extends DolibarrApi
             throw new RestException(500, "Error fetching attribute");
         }
 
-        foreach($request_data as $field => $value) {
+        foreach ($request_data as $field => $value) {
             if ($field == 'rowid') { continue;
             }
             $prodattr->$field = $value;
@@ -975,7 +975,7 @@ class Products extends DolibarrApi
      */
     public function deleteAttributes($id)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->supprimer) {
+        if (!DolibarrApiAccess::$user->rights->produit->supprimer) {
             throw new RestException(401);
         }
 
@@ -1003,7 +1003,7 @@ class Products extends DolibarrApi
      */
     public function getAttributeValueById($id)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->lire) {
+        if (!DolibarrApiAccess::$user->rights->produit->lire) {
             throw new RestException(401);
         }
 
@@ -1044,11 +1044,11 @@ class Products extends DolibarrApi
      */
     public function getAttributeValueByRef($id, $ref)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->lire) {
+        if (!DolibarrApiAccess::$user->rights->produit->lire) {
             throw new RestException(401);
         }
 
-        $sql = "SELECT rowid, fk_product_attribute, ref, value FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '". trim($ref) ."' AND fk_product_attribute = ". (int) $id ." AND entity IN (".getEntity('product').")";
+        $sql = "SELECT rowid, fk_product_attribute, ref, value FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '".trim($ref)."' AND fk_product_attribute = ".(int) $id." AND entity IN (".getEntity('product').")";
 
         $query = $this->db->query($sql);
 
@@ -1085,11 +1085,11 @@ class Products extends DolibarrApi
      */
     public function deleteAttributeValueByRef($id, $ref)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->supprimer) {
+        if (!DolibarrApiAccess::$user->rights->produit->supprimer) {
             throw new RestException(401);
         }
 
-        $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '". trim($ref) ."' AND fk_product_attribute = ". (int) $id;
+        $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_attribute_value WHERE ref LIKE '".trim($ref)."' AND fk_product_attribute = ".(int) $id;
 
         if ($this->db->query($sql)) {
             return 1;
@@ -1111,7 +1111,7 @@ class Products extends DolibarrApi
      */
     public function getAttributeValues($id)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->lire) {
+        if (!DolibarrApiAccess::$user->rights->produit->lire) {
             throw new RestException(401);
         }
 
@@ -1132,7 +1132,7 @@ class Products extends DolibarrApi
      */
     public function getAttributeValuesByRef($ref)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->lire) {
+        if (!DolibarrApiAccess::$user->rights->produit->lire) {
             throw new RestException(401);
         }
 
@@ -1140,7 +1140,7 @@ class Products extends DolibarrApi
 
         $sql = 'SELECT ';
         $sql .= 'v.fk_product_attribute, v.rowid, v.ref, v.value FROM '.MAIN_DB_PREFIX.'product_attribute_value v ';
-        $sql .= "WHERE v.fk_product_attribute = ( SELECT rowid FROM ".MAIN_DB_PREFIX."product_attribute WHERE ref LIKE '". strtoupper(trim($ref)) ."' LIMIT 1)";
+        $sql .= "WHERE v.fk_product_attribute = ( SELECT rowid FROM ".MAIN_DB_PREFIX."product_attribute WHERE ref LIKE '".strtoupper(trim($ref))."' LIMIT 1)";
 
         $query = $this->db->query($sql);
 
@@ -1172,7 +1172,7 @@ class Products extends DolibarrApi
      */
     public function addAttributeValue($id, $ref, $value)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->creer) {
+        if (!DolibarrApiAccess::$user->rights->produit->creer) {
             throw new RestException(401);
         }
 
@@ -1205,7 +1205,7 @@ class Products extends DolibarrApi
      */
     public function putAttributeValue($id, $request_data)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->creer) {
+        if (!DolibarrApiAccess::$user->rights->produit->creer) {
             throw new RestException(401);
         }
 
@@ -1218,7 +1218,7 @@ class Products extends DolibarrApi
             throw new RestException(500, "Error fetching attribute value");
         }
 
-        foreach($request_data as $field => $value) {
+        foreach ($request_data as $field => $value) {
             if ($field == 'rowid') { continue;
             }
             $objectval->$field = $value;
@@ -1250,7 +1250,7 @@ class Products extends DolibarrApi
      */
     public function deleteAttributeValueById($id)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->supprimer) {
+        if (!DolibarrApiAccess::$user->rights->produit->supprimer) {
             throw new RestException(401);
         }
 
@@ -1276,7 +1276,7 @@ class Products extends DolibarrApi
      */
     public function getVariants($id)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->lire) {
+        if (!DolibarrApiAccess::$user->rights->produit->lire) {
             throw new RestException(401);
         }
 
@@ -1304,12 +1304,12 @@ class Products extends DolibarrApi
      */
     public function getVariantsByProdRef($ref)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->lire) {
+        if (!DolibarrApiAccess::$user->rights->produit->lire) {
             throw new RestException(401);
         }
 
         $result = $this->product->fetch('', $ref);
-        if(! $result ) {
+        if (!$result) {
             throw new RestException(404, 'Product not found');
         }
 
@@ -1344,7 +1344,7 @@ class Products extends DolibarrApi
      */
     public function addVariant($id, $weight_impact, $price_impact, $price_impact_is_percent, $features)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->creer) {
+        if (!DolibarrApiAccess::$user->rights->produit->creer) {
             throw new RestException(401);
         }
 
@@ -1367,12 +1367,12 @@ class Products extends DolibarrApi
         }
 
         $result = $this->product->fetch((int) $id);
-        if(! $result ) {
+        if (!$result) {
             throw new RestException(404, 'Product not found');
         }
 
         $prodcomb = new ProductCombination($this->db);
-        if (! $prodcomb->fetchByProductCombination2ValuePairs($id, $features))
+        if (!$prodcomb->fetchByProductCombination2ValuePairs($id, $features))
         {
             $result = $prodcomb->createProductCombination(DolibarrApiAccess::$user, $this->product, $features, array(), $price_impact_is_percent, $price_impact, $weight_impact);
             if ($result > 0)
@@ -1406,7 +1406,7 @@ class Products extends DolibarrApi
      */
     public function addVariantByProductRef($ref, $weight_impact, $price_impact, $price_impact_is_percent, $features)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->creer) {
+        if (!DolibarrApiAccess::$user->rights->produit->creer) {
             throw new RestException(401);
         }
 
@@ -1429,12 +1429,12 @@ class Products extends DolibarrApi
         }
 
         $result = $this->product->fetch('', trim($ref));
-        if(! $result ) {
+        if (!$result) {
             throw new RestException(404, 'Product not found');
         }
 
         $prodcomb = new ProductCombination($this->db);
-        if (! $prodcomb->fetchByProductCombination2ValuePairs($this->product->id, $features))
+        if (!$prodcomb->fetchByProductCombination2ValuePairs($this->product->id, $features))
         {
             $result = $prodcomb->createProductCombination(DolibarrApiAccess::$user, $this->product, $features, array(), $price_impact_is_percent, $price_impact, $weight_impact);
             if ($result > 0)
@@ -1462,14 +1462,14 @@ class Products extends DolibarrApi
      */
     public function putVariant($id, $request_data = null)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->creer) {
+        if (!DolibarrApiAccess::$user->rights->produit->creer) {
             throw new RestException(401);
         }
 
         $prodcomb = new ProductCombination($this->db);
         $prodcomb->fetch((int) $id);
 
-        foreach($request_data as $field => $value) {
+        foreach ($request_data as $field => $value) {
             if ($field == 'rowid') { continue;
             }
             $prodcomb->$field = $value;
@@ -1496,7 +1496,7 @@ class Products extends DolibarrApi
      */
     public function deleteVariant($id)
     {
-        if(! DolibarrApiAccess::$user->rights->produit->supprimer) {
+        if (!DolibarrApiAccess::$user->rights->produit->supprimer) {
             throw new RestException(401);
         }
 

+ 29 - 29
htdocs/product/inventory/inventory.php

@@ -27,15 +27,15 @@ include_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php';
 include_once DOL_DOCUMENT_ROOT.'/product/inventory/lib/inventory.lib.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("stocks","other"));
+$langs->loadLangs(array("stocks", "other"));
 
 // Get parameters
-$id			= GETPOST('id', 'int');
+$id = GETPOST('id', 'int');
 $ref        = GETPOST('ref', 'alpha');
-$action		= GETPOST('action', 'aZ09');
+$action = GETPOST('action', 'aZ09');
 $confirm    = GETPOST('confirm', 'alpha');
 $cancel     = GETPOST('cancel', 'aZ09');
-$contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'myobjectcard';   // To manage different context of search
+$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectcard'; // To manage different context of search
 $backtopage = GETPOST('backtopage', 'alpha');
 
 if (empty($conf->global->MAIN_USE_ADVANCED_PERMS))
@@ -48,28 +48,28 @@ else
 }
 
 // Initialize technical objects
-$object=new Inventory($db);
+$object = new Inventory($db);
 $extrafields = new ExtraFields($db);
-$diroutputmassaction=$conf->stock->dir_output . '/temp/massgeneration/'.$user->id;
-$hookmanager->initHooks(array('inventorycard'));     // Note that conf->hooks_modules contains array
+$diroutputmassaction = $conf->stock->dir_output.'/temp/massgeneration/'.$user->id;
+$hookmanager->initHooks(array('inventorycard')); // Note that conf->hooks_modules contains array
 
 // Fetch optionals attributes and labels
 $extrafields->fetch_name_optionals_label($object->table_element);
 
-$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
+$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
 
 // Initialize array of search criterias
-$search_all=trim(GETPOST("search_all", 'alpha'));
-$search=array();
-foreach($object->fields as $key => $val)
+$search_all = trim(GETPOST("search_all", 'alpha'));
+$search = array();
+foreach ($object->fields as $key => $val)
 {
-    if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha');
+    if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
 }
 
-if (empty($action) && empty($id) && empty($ref)) $action='view';
+if (empty($action) && empty($id) && empty($ref)) $action = 'view';
 
 // Load object
-include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php';  // Must be include, not include_once.
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
 
 // Security check - Protection if external user
 //if ($user->socid > 0) accessforbidden();
@@ -92,13 +92,13 @@ else
  * Actions
  */
 
-$parameters=array();
-$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action);    // Note that $action and $object may have been modified by some hooks
+$parameters = array();
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
 
 if (empty($reshook))
 {
-	$error=0;
+	$error = 0;
 
 	$backurlforlist = DOL_URL_ROOT.'/product/inventory/list.php';
 
@@ -132,7 +132,7 @@ if (empty($reshook))
  * View
  */
 
-$form=new Form($db);
+$form = new Form($db);
 
 llxHeader('', $langs->trans('Inventory'), '');
 
@@ -164,7 +164,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 
 	// Confirmation to delete
 	if ($action == 'delete') {
-	    $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteInventory'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1);
+	    $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteInventory'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1);
 	}
 	// Confirmation to delete line
 	if ($action == 'deleteline')
@@ -176,14 +176,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 	if ($action == 'clone') {
 		// Create an array for form
 		$formquestion = array();
-		$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMyObject', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
+		$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMyObject', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
 	}
 
 	// Call Hook formConfirm
 	$parameters = array('lineid' => $lineid);
 	$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
-	if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
-	elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
+	if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
+	elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
 
 	// Print form confirm
 	print $formconfirm;
@@ -191,9 +191,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 
 	// Object card
 	// ------------------------------------------------------------
-	$linkback = '<a href="' . DOL_URL_ROOT . '/product/inventory/list.php' . (! empty($socid) ? '?socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
+	$linkback = '<a href="'.DOL_URL_ROOT.'/product/inventory/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
 
-	$morehtmlref='<div class="refidno">';
+	$morehtmlref = '<div class="refidno">';
 	/*
 	// Ref bis
 	$morehtmlref.=$form->editfieldkey("RefBis", 'ref_client', $object->ref_client, $object, $user->rights->inventory->creer, 'string', '', 0, 1);
@@ -233,7 +233,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 	    }
 	}
 	*/
-	$morehtmlref.='</div>';
+	$morehtmlref .= '</div>';
 
 
 	dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
@@ -245,10 +245,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 	print '<table class="border centpercent">'."\n";
 
 	// Common attributes
-	include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
+	include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
 
 	// Other attributes. Fields from hook formObjectOptions and Extrafields.
-	include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
+	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
 
 	print '</table>';
 	print '</div>';
@@ -262,8 +262,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 	// Buttons for actions
 	if ($action != 'presend' && $action != 'editline') {
     	print '<div class="tabsAction">'."\n";
-    	$parameters=array();
-    	$reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action);    // Note that $action and $object may have been modified by hook
+    	$parameters = array();
+    	$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
     	if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
 
     	if (empty($reshook))

+ 10 - 10
htdocs/takepos/admin/setup.php

@@ -81,7 +81,7 @@ if (GETPOST('action', 'alpha') == 'set')
 	$res = dolibarr_set_const($db, "TAKEPOS_DIRECT_PAYMENT", GETPOST('TAKEPOS_DIRECT_PAYMENT', 'int'), 'int', 0, '', $conf->entity);
 	$res = dolibarr_set_const($db, "TAKEPOS_CUSTOM_RECEIPT", GETPOST('TAKEPOS_CUSTOM_RECEIPT', 'int'), 'int', 0, '', $conf->entity);
     $res = dolibarr_set_const($db, "TAKEPOS_EMAIL_TEMPLATE_INVOICE", GETPOST('TAKEPOS_EMAIL_TEMPLATE_INVOICE', 'alpha'), 'chaine', 0, '', $conf->entity);
-	if (! empty($conf->global->TAKEPOS_ENABLE_SUMUP)) {
+	if (!empty($conf->global->TAKEPOS_ENABLE_SUMUP)) {
 		$res = dolibarr_set_const($db, "TAKEPOS_SUMUP_AFFILIATE", GETPOST('TAKEPOS_SUMUP_AFFILIATE', 'alpha'), 'chaine', 0, '', $conf->entity);
 		$res = dolibarr_set_const($db, "TAKEPOS_SUMUP_APPID", GETPOST('TAKEPOS_SUMUP_APPID', 'alpha'), 'chaine', 0, '', $conf->entity);
 	}
@@ -249,12 +249,12 @@ if ($conf->global->TAKEPOS_ENABLE_SUMUP) {
 	print '<tr class="oddeven"><td>';
 	print $langs->trans("SumupAffiliate");
 	print '<td colspan="2">';
-	print '<input type="text" name="TAKEPOS_SUMUP_AFFILIATE" value="' . $conf->global->TAKEPOS_SUMUP_AFFILIATE . '"></input>';
+	print '<input type="text" name="TAKEPOS_SUMUP_AFFILIATE" value="'.$conf->global->TAKEPOS_SUMUP_AFFILIATE.'"></input>';
 	print "</td></tr>\n";
 	print '<tr class="oddeven"><td>';
 	print $langs->trans("SumupAppId");
 	print '<td colspan="2">';
-	print '<input type="text" name="TAKEPOS_SUMUP_APPID" value="' . $conf->global->TAKEPOS_SUMUP_APPID . '"></input>';
+	print '<input type="text" name="TAKEPOS_SUMUP_APPID" value="'.$conf->global->TAKEPOS_SUMUP_APPID.'"></input>';
 	print "</td></tr>\n";
 }
 
@@ -271,17 +271,17 @@ print $langs->trans('EmailTemplate');
 print '<td colspan="2">';
 include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
 $formmail = new FormMail($db);
-$nboftemplates = $formmail->fetchAllEMailTemplate('facture_send', $user, null, -1);	// We set lang=null to get in priority record with no lang
+$nboftemplates = $formmail->fetchAllEMailTemplate('facture_send', $user, null, -1); // We set lang=null to get in priority record with no lang
 //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, '');
-$arrayofmessagename=array();
+$arrayofmessagename = array();
 if (is_array($formmail->lines_model)) {
-    foreach($formmail->lines_model as $modelmail) {
+    foreach ($formmail->lines_model as $modelmail) {
         //var_dump($modelmail);
-        $moreonlabel='';
-        if (! empty($arrayofmessagename[$modelmail->label])) {
-            $moreonlabel=' <span class="opacitymedium">('.$langs->trans("SeveralLangugeVariatFound").')</span>';
+        $moreonlabel = '';
+        if (!empty($arrayofmessagename[$modelmail->label])) {
+            $moreonlabel = ' <span class="opacitymedium">('.$langs->trans("SeveralLangugeVariatFound").')</span>';
         }
-        $arrayofmessagename[$modelmail->label]=$langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)).$moreonlabel;
+        $arrayofmessagename[$modelmail->label] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)).$moreonlabel;
     }
 }
 //var_dump($arraydefaultmessage);

+ 37 - 37
htdocs/takepos/admin/terminal.php

@@ -22,16 +22,16 @@
  *	\brief      Setup page for TakePos module
  */
 
-require '../../main.inc.php';	// Load $user and permissions
+require '../../main.inc.php'; // Load $user and permissions
 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
 require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php";
 
-$terminal=GETPOST('terminal', 'int');
+$terminal = GETPOST('terminal', 'int');
 // If socid provided by ajax company selector
-if (! empty($_REQUEST['CASHDESK_ID_THIRDPARTY'.$terminal.'_id']))
+if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY'.$terminal.'_id']))
 {
 	$_GET['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha');
 	$_POST['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha');
@@ -46,9 +46,9 @@ $langs->loadLangs(array("admin", "cashdesk"));
 global $db;
 
 $sql = "SELECT code, libelle as label FROM ".MAIN_DB_PREFIX."c_paiement";
-$sql.= " WHERE entity IN (".getEntity('c_paiement').")";
-$sql.= " AND active = 1";
-$sql.= " ORDER BY libelle";
+$sql .= " WHERE entity IN (".getEntity('c_paiement').")";
+$sql .= " AND active = 1";
+$sql .= " ORDER BY libelle";
 $resql = $db->query($sql);
 $paiements = array();
 if ($resql) {
@@ -67,19 +67,19 @@ $terminaltouse = $terminal;
 if (GETPOST('action', 'alpha') == 'set')
 {
 	$db->begin();
-	if (GETPOST('socid', 'int') < 0) $_POST["socid"]='';
+	if (GETPOST('socid', 'int') < 0) $_POST["socid"] = '';
 
 	$res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY".$terminaltouse, (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity);
 
 	$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
 	$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CHEQUE".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
 	$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CB".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
-	if (! empty($conf->global->TAKEPOS_ENABLE_SUMUP)) {
+	if (!empty($conf->global->TAKEPOS_ENABLE_SUMUP)) {
 		$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_SUMUP".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
 	}
-	foreach($paiements as $modep) {
+	foreach ($paiements as $modep) {
         if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) continue;
-        $name="CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse;
+        $name = "CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse;
 		$res = dolibarr_set_const($db, $name, (GETPOST($name, 'alpha') > 0 ? GETPOST($name, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
     }
     $res = dolibarr_set_const($db, "CASHDESK_ID_WAREHOUSE".$terminaltouse, (GETPOST('CASHDESK_ID_WAREHOUSE'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_WAREHOUSE'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
@@ -90,9 +90,9 @@ if (GETPOST('action', 'alpha') == 'set')
 
 	dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha'));
 
-	if (! $res > 0) $error++;
+	if (!$res > 0) $error++;
 
- 	if (! $error)
+ 	if (!$error)
     {
         $db->commit();
 	    setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@@ -109,12 +109,12 @@ if (GETPOST('action', 'alpha') == 'set')
  * View
  */
 
-$form=new Form($db);
-$formproduct=new FormProduct($db);
+$form = new Form($db);
+$formproduct = new FormProduct($db);
 
 llxHeader('', $langs->trans("CashDeskSetup"));
 
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
 print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup');
 $head = takepos_prepare_head();
 dol_fiche_head($head, 'terminal'.$terminal, 'TakePOS', -1);
@@ -122,7 +122,7 @@ print '<br>';
 
 
 // Mode
-print '<form action="'.$_SERVER["PHP_SELF"].'?terminal='.(empty($terminal)?1:$terminal).'" method="post">';
+print '<form action="'.$_SERVER["PHP_SELF"].'?terminal='.(empty($terminal) ? 1 : $terminal).'" method="post">';
 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 print '<input type="hidden" name="action" value="set">';
 
@@ -137,46 +137,46 @@ print $form->select_company($conf->global->{'CASHDESK_ID_THIRDPARTY'.$terminalto
 print '</td></tr>';
 
 $atleastonefound = 0;
-if (! empty($conf->banque->enabled))
+if (!empty($conf->banque->enabled))
 {
     print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSell").'</td>';
 	print '<td>';
 	$form->select_comptes($conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse}, 'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 0, "courant=2", 1);
-	if (! empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse})) $atleastonefound++;
+	if (!empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse})) $atleastonefound++;
 	print '</td></tr>';
 	print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCheque").'</td>';
 	print '<td>';
 	$form->select_comptes($conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse}, 'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 0, "courant=1", 1);
-	if (! empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse})) $atleastonefound++;
+	if (!empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse})) $atleastonefound++;
 	print '</td></tr>';
 	print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCB").'</td>';
 	print '<td>';
 	$form->select_comptes($conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse}, 'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 0, "courant=1", 1);
-	if (! empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse})) $atleastonefound++;
+	if (!empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse})) $atleastonefound++;
 	print '</td></tr>';
 	if ($conf->global->TAKEPOS_ENABLE_SUMUP) {
-		print '<tr class="oddeven"><td>' . $langs->trans("CashDeskBankAccountForSumup") . '</td>';
+		print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSumup").'</td>';
 		print '<td>';
-		$form->select_comptes($conf->global->{'CASHDESK_ID_BANKACCOUNT_SUMUP' . $terminaltouse}, 'CASHDESK_ID_BANKACCOUNT_SUMUP' . $terminaltouse, 0, "courant=1", 1);
-		if (!empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_SUMUP' . $terminaltouse})) $atleastonefound++;
+		$form->select_comptes($conf->global->{'CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse}, 'CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 0, "courant=1", 1);
+		if (!empty($conf->global->{'CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse})) $atleastonefound++;
 		print '</td></tr>';
 	}
 
-	foreach($paiements as $modep) {
-        if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) continue;	// Already managed before
-        $name="CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse;
+	foreach ($paiements as $modep) {
+        if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) continue; // Already managed before
+        $name = "CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse;
 		print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountFor").' '.$langs->trans($modep->label).'</td>';
 		print '<td>';
-		if (! empty($conf->global->$name)) $atleastonefound++;
-		$cour=preg_match('/^LIQ.*/', $modep->code)?2:1;
+		if (!empty($conf->global->$name)) $atleastonefound++;
+		$cour = preg_match('/^LIQ.*/', $modep->code) ? 2 : 1;
 		$form->select_comptes($conf->global->$name, $name, 0, "courant=".$cour, 1);
 		print '</td></tr>';
 	}
 }
 
-if (! empty($conf->stock->enabled))
+if (!empty($conf->stock->enabled))
 {
-	print '<tr class="oddeven"><td>'.$langs->trans("CashDeskDoNotDecreaseStock").'</td>';	// Force warehouse (this is not a default value)
+	print '<tr class="oddeven"><td>'.$langs->trans("CashDeskDoNotDecreaseStock").'</td>'; // Force warehouse (this is not a default value)
 	print '<td>';
 	if (empty($conf->productbatch->enabled)) {
 	    print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK'.$terminal, $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$terminal}, 1);
@@ -191,12 +191,12 @@ if (! empty($conf->stock->enabled))
 	}
 	print '</td></tr>';
 
-	$disabled=$conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$terminal};
+	$disabled = $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$terminal};
 
 
-	print '<tr class="oddeven"><td>'.$langs->trans("CashDeskIdWareHouse").'</td>';	// Force warehouse (this is not a default value)
+	print '<tr class="oddeven"><td>'.$langs->trans("CashDeskIdWareHouse").'</td>'; // Force warehouse (this is not a default value)
 	print '<td>';
-	if (! $disabled)
+	if (!$disabled)
 	{
 		print $formproduct->selectWarehouses($conf->global->{'CASHDESK_ID_WAREHOUSE'.$terminal}, 'CASHDESK_ID_WAREHOUSE'.$terminal, '', 1, $disabled);
 		print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">('.$langs->trans("Create").')</a>';
@@ -217,7 +217,7 @@ if (! empty($conf->stock->enabled))
 		}
 		print '<tr class="oddeven"><td>'.$langs->trans("TakeposTerminalPrinterToUse").'</td>';
 		print '<td>';
-		print $form->selectarray('TAKEPOS_PRINTER_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_PRINTER_TO_USE'.$terminal})?'0':$conf->global->{'TAKEPOS_PRINTER_TO_USE'.$terminal}), 1);
+		print $form->selectarray('TAKEPOS_PRINTER_TO_USE'.$terminal, $printers, (empty($conf->global->{'TAKEPOS_PRINTER_TO_USE'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_PRINTER_TO_USE'.$terminal}), 1);
 		print '</td></tr>';
 		$printer->listPrintersTemplates();
 		$templates = array();
@@ -226,18 +226,18 @@ if (! empty($conf->stock->enabled))
 		}
 		print '<tr class="oddeven"><td>'.$langs->trans("TakeposTerminalTemplateToUseForInvoicesTicket").'</td>';
 		print '<td>';
-		print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal, $templates, (empty($conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal})?'0':$conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal}), 1);
+		print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal, $templates, (empty($conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal}), 1);
 		print '</td></tr>';
 		print '<tr class="oddeven"><td>'.$langs->trans("TakeposTerminalTemplateToUseForOrdersTicket").'</td>';
 		print '<td>';
-		print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal, $templates, (empty($conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal})?'0':$conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal}), 1);
+		print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal, $templates, (empty($conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal}) ? '0' : $conf->global->{'TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal}), 1);
 		print '</td></tr>';
 	}
 }
 
 print '</table>';
 
-if ($atleastonefound == 0 && ! empty($conf->banque->enabled))
+if ($atleastonefound == 0 && !empty($conf->banque->enabled))
 {
 	print info_admin($langs->trans("AtLeastOneDefaultBankAccountMandatory"), 0, 0, 'error');
 }

+ 33 - 33
htdocs/takepos/pay.php

@@ -25,16 +25,16 @@
 //if (! defined('NOREQUIREDB'))		define('NOREQUIREDB', '1');		// Not disabled cause need to load personalized language
 //if (! defined('NOREQUIRESOC'))		define('NOREQUIRESOC', '1');
 //if (! defined('NOREQUIRETRAN'))		define('NOREQUIRETRAN', '1');
-if (! defined('NOCSRFCHECK'))		define('NOCSRFCHECK', '1');
-if (! defined('NOTOKENRENEWAL'))	define('NOTOKENRENEWAL', '1');
-if (! defined('NOREQUIREMENU'))		define('NOREQUIREMENU', '1');
-if (! defined('NOREQUIREHTML'))		define('NOREQUIREHTML', '1');
-if (! defined('NOREQUIREAJAX'))		define('NOREQUIREAJAX', '1');
+if (!defined('NOCSRFCHECK'))		define('NOCSRFCHECK', '1');
+if (!defined('NOTOKENRENEWAL'))	define('NOTOKENRENEWAL', '1');
+if (!defined('NOREQUIREMENU'))		define('NOREQUIREMENU', '1');
+if (!defined('NOREQUIREHTML'))		define('NOREQUIREHTML', '1');
+if (!defined('NOREQUIREAJAX'))		define('NOREQUIREAJAX', '1');
 
-require '../main.inc.php';	// Load $user and permissions
-require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
+require '../main.inc.php'; // Load $user and permissions
+require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
 
-$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0);   // $place is id of table for Ba or Restaurant
+$place = (GETPOST('place', 'int') > 0 ? GETPOST('place', 'int') : 0); // $place is id of table for Ba or Restaurant
 
 $invoiceid = GETPOST('invoiceid', 'int');
 
@@ -50,16 +50,16 @@ if ($invoiceid > 0)
 }
 else
 {
-    $sql="SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'";
+    $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture where ref='(PROV-POS".$_SESSION["takeposterminal"]."-".$place.")'";
     $resql = $db->query($sql);
     $obj = $db->fetch_object($resql);
     if ($obj)
     {
         $invoiceid = $obj->rowid;
     }
-    if (! $invoiceid)
+    if (!$invoiceid)
     {
-        $invoiceid=0; // Invoice does not exist yet
+        $invoiceid = 0; // Invoice does not exist yet
     }
     else
     {
@@ -84,8 +84,8 @@ if ($resql) {
         if ($paycode == 'CB')  $paycode = 'CB';
         if ($paycode == 'CHQ') $paycode = 'CHEQUE';
 
-        $accountname="CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION["takeposterminal"];
-		if (! empty($conf->global->$accountname) && $conf->global->$accountname > 0) array_push($paiements, $obj);
+        $accountname = "CASHDESK_ID_BANKACCOUNT_".$paycode.$_SESSION["takeposterminal"];
+		if (!empty($conf->global->$accountname) && $conf->global->$accountname > 0) array_push($paiements, $obj);
 	}
 }
 ?>
@@ -171,7 +171,7 @@ else print "var received=0;";
 			amountpayed = <?php echo $invoice->total_ttc; ?>;
 		}
 		console.log("We click on the payment mode to pay amount = "+amountpayed);
-		parent.$("#poslines").load("invoice.php?place=<?php echo $place;?>&action=valid&pay="+payment+"&amount="+amountpayed+"&invoiceid="+invoiceid, function() {
+		parent.$("#poslines").load("invoice.php?place=<?php echo $place; ?>&action=valid&pay="+payment+"&amount="+amountpayed+"&invoiceid="+invoiceid, function() {
 		    if (amountpayed > <?php echo $remaintopay; ?> || amountpayed == <?php echo $remaintopay; ?> || amountpayed==0 ) parent.$.colorbox.close();
 			else location.reload();
 		});
@@ -192,7 +192,7 @@ else print "var received=0;";
             $.ajax('/takepos/smpcb.php?status').done(function (data) {
                 console.log(data);
                 if (data === "SUCCESS") {
-                    parent.$("#poslines").load("invoice.php?place=<?php echo $place;?>&action=valid&pay=CB&amount=" + amountpayed + "&invoiceid=" + invoiceid, function () {
+                    parent.$("#poslines").load("invoice.php?place=<?php echo $place; ?>&action=valid&pay=CB&amount=" + amountpayed + "&invoiceid=" + invoiceid, function () {
                         //parent.$("#poslines").scrollTop(parent.$("#poslines")[0].scrollHeight);
                         parent.$.colorbox.close();
                         //parent.setFocusOnSearchField();	// This does not have effect
@@ -210,11 +210,11 @@ else print "var received=0;";
 <div style="position:absolute; top:2%; left:5%; height:30%; width:91%;">
 <center>
 <div class="paymentbordline paymentbordlinetotal">
-<center><span style='font-family: verdana,arial,helvetica; font-size: 200%;'><font color="white"><?php echo $langs->trans('TotalTTC');?>: </font><span id="totaldisplay" class="colorwhite"><?php echo price($invoice->total_ttc, 1, '', 1, -1, -1) ?></span></font></span></center>
+<center><span style='font-family: verdana,arial,helvetica; font-size: 200%;'><font color="white"><?php echo $langs->trans('TotalTTC'); ?>: </font><span id="totaldisplay" class="colorwhite"><?php echo price($invoice->total_ttc, 1, '', 1, -1, -1) ?></span></font></span></center>
 </div>
 <?php if ($remaintopay != $invoice->total_ttc) { ?>
 <div class="paymentbordline paymentbordlineremain">
-<center><span style='font-family: verdana,arial,helvetica; font-size: 200%;'><font color="white"><?php echo $langs->trans('RemainToPay');?>: </font><span id="remaintopaydisplay" class="colorwhite"><?php echo price($remaintopay, 1, '', 1, -1, -1) ?></span></font></span></center>
+<center><span style='font-family: verdana,arial,helvetica; font-size: 200%;'><font color="white"><?php echo $langs->trans('RemainToPay'); ?>: </font><span id="remaintopaydisplay" class="colorwhite"><?php echo price($remaintopay, 1, '', 1, -1, -1) ?></span></font></span></center>
 </div>
 <?php } ?>
 <div class="paymentbordline paymentbordlinereceived">
@@ -270,11 +270,11 @@ $numpad = $conf->global->TAKEPOS_NUMPAD;
 <?php } else {
     $button = array_pop($action_buttons);
     ?>
-	<button type="button" class="calcbutton2" onclick="<?php echo $button["function"];?>"><span <?php echo $button["span"];?>><?php echo $button["text"];?></span></button>
+	<button type="button" class="calcbutton2" onclick="<?php echo $button["function"]; ?>"><span <?php echo $button["span"]; ?>><?php echo $button["text"]; ?></span></button>
 <?php } ?>
-<button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad==0) print "1"; else print "0.10";?>);"><?php if ($numpad==0) print "1"; else print "0.10";?></button>
-<button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad==0) print "2"; else print "0.20";?>);"><?php if ($numpad==0) print "2"; else print "0.20";?></button>
-<button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad==0) print "3"; else print "0.50";?>);"><?php if ($numpad==0) print "3"; else print "0.50";?></button>
+<button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad == 0) print "1"; else print "0.10"; ?>);"><?php if ($numpad == 0) print "1"; else print "0.10"; ?></button>
+<button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad == 0) print "2"; else print "0.20"; ?>);"><?php if ($numpad == 0) print "2"; else print "0.20"; ?></button>
+<button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad == 0) print "3"; else print "0.50"; ?>);"><?php if ($numpad == 0) print "3"; else print "0.50"; ?></button>
 <?php if (count($paiements) > 2) {
     $paycode = $paiements[2]->code;
     if ($paycode == 'LIQ') $paycode = 'cash';
@@ -285,31 +285,31 @@ $numpad = $conf->global->TAKEPOS_NUMPAD;
 <?php } else {
     $button = array_pop($action_buttons);
     ?>
-	<button type="button" class="calcbutton2" onclick="<?php echo $button["function"];?>"><span <?php echo $button["span"];?>><?php echo $button["text"];?></span></button>
+	<button type="button" class="calcbutton2" onclick="<?php echo $button["function"]; ?>"><span <?php echo $button["span"]; ?>><?php echo $button["text"]; ?></span></button>
 <?php } ?>
-<button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad==0) print "0"; else print "0.01";?>);"><?php if ($numpad==0) print "0"; else print "0.01";?></button>
-<button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad==0) print "'000'"; else print "0.02";?>);"><?php if ($numpad==0) print "000"; else print "0.02";?></button>
-<button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad==0) print "'.'"; else print "0.05";?>);"><?php if ($numpad==0) print "."; else print "0.05";?></button>
+<button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad == 0) print "0"; else print "0.01"; ?>);"><?php if ($numpad == 0) print "0"; else print "0.01"; ?></button>
+<button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad == 0) print "'000'"; else print "0.02"; ?>);"><?php if ($numpad == 0) print "000"; else print "0.02"; ?></button>
+<button type="button" class="calcbutton" onclick="addreceived(<?php if ($numpad == 0) print "'.'"; else print "0.05"; ?>);"><?php if ($numpad == 0) print "."; else print "0.05"; ?></button>
 <?php
-$i=3;
-while($i < count($paiements)){
+$i = 3;
+while ($i < count($paiements)) {
     ?>
 <button type="button" class="calcbutton2" onclick="Validate('<?php echo $langs->trans($paiements[$i]->code); ?>');"><?php echo $langs->trans("PaymentTypeShort".$paiements[$i]->code); ?></button>
     <?php
-	$i=$i+1;
+	$i = $i + 1;
 }
 
-if($conf->global->TAKEPOS_ENABLE_SUMUP && !empty(dolibarr_get_const($db, "CASHDESK_ID_BANKACCOUNT_SUMUP".$_SESSION["takeposterminal"]))) {
+if ($conf->global->TAKEPOS_ENABLE_SUMUP && !empty(dolibarr_get_const($db, "CASHDESK_ID_BANKACCOUNT_SUMUP".$_SESSION["takeposterminal"]))) {
 	?>
 	<button type="button" class="calcbutton2" onclick="ValidateSumup();">Sumup</button>
 	<?php
 }
 
-$class=($i==3)?"calcbutton3":"calcbutton2";
-foreach($action_buttons as $button){
-    $newclass = $class.($button["class"]?" ".$button["class"]:"");
+$class = ($i == 3) ? "calcbutton3" : "calcbutton2";
+foreach ($action_buttons as $button) {
+    $newclass = $class.($button["class"] ? " ".$button["class"] : "");
     ?>
-	<button type="button" class="<?php echo $newclass;?>" onclick="<?php echo $button["function"];?>"><span <?php echo $button["span"];?>><?php echo $button["text"];?></span></button>
+	<button type="button" class="<?php echo $newclass; ?>" onclick="<?php echo $button["function"]; ?>"><span <?php echo $button["span"]; ?>><?php echo $button["text"]; ?></span></button>
     <?php
 }
 ?>

+ 2 - 2
htdocs/takepos/smpcb.php

@@ -1,11 +1,11 @@
 <?php
     require '../main.inc.php';
 
-if(isset($_GET['status'])) {
+if (isset($_GET['status'])) {
 	die(strtoupper($_SESSION['SMP_CURRENT_PAYMENT']));
 }
 
-if($_GET['smp-status']) {
+if ($_GET['smp-status']) {
 	print '<html lang="en">
 <head>
     <meta charset="utf-8">

+ 8 - 8
htdocs/zapier/hook_agenda.php

@@ -45,32 +45,32 @@ dol_include_once('/mymodule/lib/mymodule_myobject.lib.php');
 
 
 // Load translation files required by the page
-$langs->loadLangs(array("mymodule@mymodule","other"));
+$langs->loadLangs(array("mymodule@mymodule", "other"));
 
 // Get parameters
-$id			= GETPOST('id', 'int');
+$id = GETPOST('id', 'int');
 $ref        = GETPOST('ref', 'alpha');
-$action		= GETPOST('action', 'alpha');
+$action = GETPOST('action', 'alpha');
 $cancel     = GETPOST('cancel', 'aZ09');
 $backtopage = GETPOST('backtopage', 'alpha');
 
 if (GETPOST('actioncode', 'array'))
 {
-    $actioncode=GETPOST('actioncode', 'array', 3);
-    if (! count($actioncode)) $actioncode='0';
+    $actioncode = GETPOST('actioncode', 'array', 3);
+    if (!count($actioncode)) $actioncode = '0';
 }
 else
 {
-    $actioncode=GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
+    $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
 }
-$search_agenda_label=GETPOST('search_agenda_label');
+$search_agenda_label = GETPOST('search_agenda_label');
 
 // Security check - Protection if external user
 //if ($user->socid > 0) accessforbidden();
 //if ($user->socid > 0) $socid = $user->socid;
 //$result = restrictedArea($user, 'mymodule', $id);
 
-$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
+$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
 $sortfield = GETPOST("sortfield", 'alpha');
 $sortorder = GETPOST("sortorder", 'alpha');
 $page = GETPOST("page", 'int');