diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php index 1b69e035fba..a593e10adf4 100644 --- a/htdocs/commande/tpl/linkedobjectblock.tpl.php +++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php @@ -18,7 +18,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) { +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; } @@ -36,14 +36,14 @@ $langs->load("orders"); $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); -$total=0; -$ilink=0; -foreach($linkedObjectBlock as $key => $objectlink) +$total = 0; +$ilink = 0; +foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; - $trclass='oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; + $trclass = 'oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; echo ''; echo ''.$langs->trans("CustomerOrder"); if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { @@ -62,14 +62,14 @@ foreach($linkedObjectBlock as $key => $objectlink) echo ''.$objectlink->getLibStatut(3).''; echo ''; // For now, shipments must stay linked to order, so link is not deletable - if($object->element != 'shipping') { + if ($object->element != 'shipping') { echo ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; } echo ''; echo "\n"; } if (count($linkedObjectBlock) > 1) { - echo ''; + echo ''; echo ''.$langs->trans("Total").''; echo ''; echo ''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 0d39cda6513..f0854eabde2 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1216,7 +1216,7 @@ if (empty($reshook)) // Si facture standard $object->socid = GETPOST('socid', 'int'); $object->type = GETPOST('type'); - $object->ref = $_POST['ref']; + $object->ref = $_POST['ref']; $object->date = $dateinvoice; $object->date_pointoftax = $date_pointoftax; $object->note_public = trim(GETPOST('note_public', 'none')); diff --git a/htdocs/core/boxes/box_shipments.php b/htdocs/core/boxes/box_shipments.php new file mode 100644 index 00000000000..957c738ad22 --- /dev/null +++ b/htdocs/core/boxes/box_shipments.php @@ -0,0 +1,190 @@ + + * Copyright (C) 2004-2009 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2019 Alexandre Spangaro + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/core/boxes/box_shipments.php + * \ingroup shipment + * \brief Module for generating the display of the shipment box + */ + +include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; + + +/** + * Class to manage the box to show last shipments + */ +class box_shipments extends ModeleBoxes +{ + public $boxcode="lastcustomershipments"; + public $boximg="sending"; + public $boxlabel="BoxLastCustomerShipments"; + public $depends = array("expedition"); + + /** + * @var DoliDB Database handler. + */ + public $db; + + public $param; + + public $info_box_head = array(); + public $info_box_contents = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param string $param More parameters + */ + public function __construct($db, $param) + { + global $user; + + $this->db=$db; + + $this->hidden=! ($user->rights->expedition->lire); + } + + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $user, $langs, $conf; + $langs->loadLangs(array('orders', 'sendings')); + + $this->max = $max; + + include_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; + include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; + + $shipmentstatic = new Expedition($this->db); + $orderstatic = new Commande($this->db); + $societestatic = new Societe($this->db); + + $this->info_box_head = array('text' => $langs->trans("BoxTitleLastCustomerShipments", $max)); + + 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); + + $result = $this->db->query($sql); + if ($result) { + $num = $this->db->num_rows($result); + + $line = 0; + + while ($line < $num) { + $objp = $this->db->fetch_object($result); + + $shipmentstatic->id = $objp->rowid; + $shipmentstatic->ref = $objp->ref; + $shipmentstatic->ref_customer = $objp->ref_customer; + + $orderstatic->id= $objp->commande_id; + $orderstatic->ref=$objp->commande_ref; + + $societestatic->id = $objp->socid; + $societestatic->name = $objp->name; + $societestatic->email = $objp->email; + $societestatic->code_client = $objp->code_client; + $societestatic->logo = $objp->logo; + + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $shipmentstatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"', + 'text' => $societestatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => '', + 'text' => $orderstatic->getNomUrl(1), + 'asis' => 1, + ); + + $this->info_box_contents[$line][] = array( + 'td' => 'class="right" width="18"', + 'text' => $shipmentstatic->LibStatut($objp->fk_statut, 3), + ); + + $line++; + } + + if ($num==0) $this->info_box_contents[$line][0] = array('td' => 'class="center"','text'=>$langs->trans("NoRecordedShipments")); + + $this->db->free($result); + } else { + $this->info_box_contents[0][0] = array( + 'td' => '', + 'maxlength'=>500, + 'text' => ($this->db->error().' sql='.$sql), + ); + } + } else { + $this->info_box_contents[0][0] = array( + 'td' => 'class="nohover opacitymedium left"', + 'text' => $langs->trans("ReadPermissionNotAllowed") + ); + } + } + + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } +} diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 68f4a3d5fba..d8225a1b2a5 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -133,7 +133,9 @@ class modExpedition extends DolibarrModules $r++; // Boxes - $this->boxes = array(); + $this->boxes = array( + 0=>array('file'=>'box_shipments.php','enabledbydefaulton'=>'Home'), + ); // Permissions $this->rights = array(); diff --git a/htdocs/expedition/tpl/linkedobjectblock.tpl.php b/htdocs/expedition/tpl/linkedobjectblock.tpl.php index 1cc0e30934d..fbc1763beb3 100644 --- a/htdocs/expedition/tpl/linkedobjectblock.tpl.php +++ b/htdocs/expedition/tpl/linkedobjectblock.tpl.php @@ -17,7 +17,7 @@ */ // Protection to avoid direct call of template -if (empty($conf) || ! is_object($conf)) +if (empty($conf) || !is_object($conf)) { print "Error, template page can't be called as URL"; exit; @@ -35,14 +35,14 @@ $linkedObjectBlock = $GLOBALS['linkedObjectBlock']; // Load translation files required by the page $langs->load("sendings"); -$total=0; -$ilink=0; -foreach($linkedObjectBlock as $key => $objectlink) +$total = 0; +$ilink = 0; +foreach ($linkedObjectBlock as $key => $objectlink) { $ilink++; - $trclass='oddeven'; - if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass.=' liste_sub_total'; + $trclass = 'oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total'; ?> trans("Shipment"); ?> @@ -58,7 +58,7 @@ foreach($linkedObjectBlock as $key => $objectlink) element != 'commande') { + if ($object->element != 'commande') { ?> ">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?> $objectlink) } if (count($linkedObjectBlock) > 1) { ?> - + trans("Total"); ?> diff --git a/htdocs/langs/en_US/boxes.lang b/htdocs/langs/en_US/boxes.lang index a55a0194632..8fe1f84b149 100644 --- a/htdocs/langs/en_US/boxes.lang +++ b/htdocs/langs/en_US/boxes.lang @@ -97,3 +97,6 @@ BoxSuspenseAccount=Count accountancy operation with suspense account BoxTitleSuspenseAccount=Number of unallocated lines NumberOfLinesInSuspenseAccount=Number of line in suspense account SuspenseAccountNotDefined=Suspense account isn't defined +BoxLastCustomerShipments=Last customer shipments +BoxTitleLastCustomerShipments=Latest %s customer shipments +NoRecordedShipments=No recorded customer shipment diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 2fe3dbc140a..6b17bb6f947 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -89,28 +89,28 @@ function testSqlAndScriptInject($val, $type) $inj += preg_match('/'."\n"; + print ''."\n"; } } // Global js function print ''."\n"; - print ''."\n"; + print ''."\n"; // JS forced by modules (relative url starting with /) - if (! empty($conf->modules_parts['js'])) // $conf->modules_parts['js'] is array('module'=>array('file1','file2')) + if (!empty($conf->modules_parts['js'])) // $conf->modules_parts['js'] is array('module'=>array('file1','file2')) { - $arrayjs=(array) $conf->modules_parts['js']; - foreach($arrayjs as $modjs => $filesjs) + $arrayjs = (array) $conf->modules_parts['js']; + foreach ($arrayjs as $modjs => $filesjs) { - $filesjs=(array) $filesjs; // To be sure filejs is an array - foreach($filesjs as $jsfile) + $filesjs = (array) $filesjs; // To be sure filejs is an array + foreach ($filesjs as $jsfile) { // jsfile is a relative path - print ''."\n".''."\n"; + print ''."\n".''."\n"; } } } @@ -1613,15 +1613,15 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead // Add login user link - $toprightmenu.=''."\n"; - $toprightmenu.=''; print $toprightmenu; - print "\n"; // end div class="login_block" + print "\n"; // end div class="login_block" print ''; @@ -1752,94 +1752,94 @@ function top_menu_user() global $menumanager; $userImage = $userDropDownImage = ''; - if (! empty($user->photo)) + if (!empty($user->photo)) { $userImage = Form::showphoto('userphoto', $user, 0, 0, 0, 'photouserphoto userphoto', 'small', 0, 1); $userDropDownImage = Form::showphoto('userphoto', $user, 0, 0, 0, 'dropdown-user-image', 'small', 0, 1); } else { - $nophoto='/public/theme/common/user_anonymous.png'; - if ($user->gender == 'man') $nophoto='/public/theme/common/user_man.png'; - if ($user->gender == 'woman') $nophoto='/public/theme/common/user_woman.png'; + $nophoto = '/public/theme/common/user_anonymous.png'; + if ($user->gender == 'man') $nophoto = '/public/theme/common/user_man.png'; + if ($user->gender == 'woman') $nophoto = '/public/theme/common/user_woman.png'; $userImage = 'No photo'; $userDropDownImage = 'No photo'; } $dropdownBody = ''; - $dropdownBody.= ' '.$langs->trans("ShowMoreInfos").''; - $dropdownBody.= '
'; + $dropdownBody .= ' '.$langs->trans("ShowMoreInfos").''; + $dropdownBody .= '
'; // login infos - if (! empty($user->admin)) { - $dropdownBody.= '
' . $langs->trans("Administrator").': '.yn($user->admin); + if (!empty($user->admin)) { + $dropdownBody .= '
'.$langs->trans("Administrator").': '.yn($user->admin); } - if (! empty($user->socid)) // Add thirdparty for external users + if (!empty($user->socid)) // Add thirdparty for external users { $thirdpartystatic = new Societe($db); $thirdpartystatic->fetch($user->socid); - $companylink = ' '.$thirdpartystatic->getNomUrl(2); // picto only of company - $company=' ('.$langs->trans("Company").': '.$thirdpartystatic->name.')'; + $companylink = ' '.$thirdpartystatic->getNomUrl(2); // picto only of company + $company = ' ('.$langs->trans("Company").': '.$thirdpartystatic->name.')'; } - $type=($user->socid?$langs->trans("External").$company:$langs->trans("Internal")); - $dropdownBody.= '
' . $langs->trans("Type") . ': ' . $type; - $dropdownBody.= '
' . $langs->trans("Status").': '.$user->getLibStatut(0); - $dropdownBody.= '
'; + $type = ($user->socid ? $langs->trans("External").$company : $langs->trans("Internal")); + $dropdownBody .= '
'.$langs->trans("Type").': '.$type; + $dropdownBody .= '
'.$langs->trans("Status").': '.$user->getLibStatut(0); + $dropdownBody .= '
'; - $dropdownBody.= '
'.$langs->trans("Session").''; - $dropdownBody.= '
'.$langs->trans("IPAddress").': '.dol_escape_htmltag($_SERVER["REMOTE_ADDR"]); - if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $dropdownBody.= '
'.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$user->entity.')'; - $dropdownBody.= '
'.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"].(empty($dolibarr_main_demo)?'':' (demo)'); - $dropdownBody.= '
'.$langs->trans("ConnectedSince").': '.dol_print_date($user->datelastlogin, "dayhour", 'tzuser'); - $dropdownBody.= '
'.$langs->trans("PreviousConnexion").': '.dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); - $dropdownBody.= '
'.$langs->trans("CurrentTheme").': '.$conf->theme; - $dropdownBody.= '
'.$langs->trans("CurrentMenuManager").': '.$menumanager->name; - $langFlag=picto_from_langcode($langs->getDefaultLang()); - $dropdownBody.= '
'.$langs->trans("CurrentUserLanguage").': '.($langFlag?$langFlag.' ':'').$langs->getDefaultLang(); - $dropdownBody.= '
'.$langs->trans("Browser").': '.$conf->browser->name.($conf->browser->version?' '.$conf->browser->version:'').' ('.dol_escape_htmltag($_SERVER['HTTP_USER_AGENT']).')'; - $dropdownBody.= '
'.$langs->trans("Layout").': '.$conf->browser->layout; - $dropdownBody.= '
'.$langs->trans("Screen").': '.$_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']; - if ($conf->browser->layout == 'phone') $dropdownBody.= '
'.$langs->trans("Phone").': '.$langs->trans("Yes"); - if (! empty($_SESSION["disablemodules"])) $dropdownBody.= '
'.$langs->trans("DisabledModules").':
'.join(', ', explode(',', $_SESSION["disablemodules"])); - $dropdownBody.= '
'; + $dropdownBody .= '
'.$langs->trans("Session").''; + $dropdownBody .= '
'.$langs->trans("IPAddress").': '.dol_escape_htmltag($_SERVER["REMOTE_ADDR"]); + if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $dropdownBody .= '
'.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$user->entity.')'; + $dropdownBody .= '
'.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"].(empty($dolibarr_main_demo) ? '' : ' (demo)'); + $dropdownBody .= '
'.$langs->trans("ConnectedSince").': '.dol_print_date($user->datelastlogin, "dayhour", 'tzuser'); + $dropdownBody .= '
'.$langs->trans("PreviousConnexion").': '.dol_print_date($user->datepreviouslogin, "dayhour", 'tzuser'); + $dropdownBody .= '
'.$langs->trans("CurrentTheme").': '.$conf->theme; + $dropdownBody .= '
'.$langs->trans("CurrentMenuManager").': '.$menumanager->name; + $langFlag = picto_from_langcode($langs->getDefaultLang()); + $dropdownBody .= '
'.$langs->trans("CurrentUserLanguage").': '.($langFlag ? $langFlag.' ' : '').$langs->getDefaultLang(); + $dropdownBody .= '
'.$langs->trans("Browser").': '.$conf->browser->name.($conf->browser->version ? ' '.$conf->browser->version : '').' ('.dol_escape_htmltag($_SERVER['HTTP_USER_AGENT']).')'; + $dropdownBody .= '
'.$langs->trans("Layout").': '.$conf->browser->layout; + $dropdownBody .= '
'.$langs->trans("Screen").': '.$_SESSION['dol_screenwidth'].' x '.$_SESSION['dol_screenheight']; + if ($conf->browser->layout == 'phone') $dropdownBody .= '
'.$langs->trans("Phone").': '.$langs->trans("Yes"); + if (!empty($_SESSION["disablemodules"])) $dropdownBody .= '
'.$langs->trans("DisabledModules").':
'.join(', ', explode(',', $_SESSION["disablemodules"])); + $dropdownBody .= '
'; // Execute hook - $parameters=array('user'=>$user, 'langs' => $langs); - $result=$hookmanager->executeHooks('printTopRightMenuLoginDropdownBody', $parameters); // Note that $action and $object may have been modified by some hooks + $parameters = array('user'=>$user, 'langs' => $langs); + $result = $hookmanager->executeHooks('printTopRightMenuLoginDropdownBody', $parameters); // Note that $action and $object may have been modified by some hooks if (is_numeric($result)) { - if ($result == 0){ - $dropdownBody.= $hookmanager->resPrint; // add + if ($result == 0) { + $dropdownBody .= $hookmanager->resPrint; // add } - else{ - $dropdownBody = $hookmanager->resPrint; // replace + else { + $dropdownBody = $hookmanager->resPrint; // replace } } - $logoutLink =' '.$langs->trans("Logout").''; - $profilLink =' '.$langs->trans("Card").''; + $logoutLink = ' '.$langs->trans("Logout").''; + $profilLink = ' '.$langs->trans("Card").''; $profilName = $user->getFullName($langs).' ('.$user->login.')'; - if (! empty($user->admin)) { + if (!empty($user->admin)) { $profilName = ' '.$profilName; } // Define version to show - $appli=constant('DOL_APPLICATION_TITLE'); - if (! empty($conf->global->MAIN_APPLICATION_TITLE)) + $appli = constant('DOL_APPLICATION_TITLE'); + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { - $appli=$conf->global->MAIN_APPLICATION_TITLE; + $appli = $conf->global->MAIN_APPLICATION_TITLE; if (preg_match('/\d\.\d/', $appli)) { - if (! preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli.=" (".DOL_VERSION.")"; // If new title contains a version that is different than core + if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core } - else $appli.=" ".DOL_VERSION; + else $appli .= " ".DOL_VERSION; } - else $appli.=" ".DOL_VERSION; + else $appli .= " ".DOL_VERSION; $btnUser = ' '; - if (! defined('JS_JQUERY_DISABLE_DROPDOWN')) // This may be set by some pages that use different jquery version to avoid errors + if (!defined('JS_JQUERY_DISABLE_DROPDOWN')) // This may be set by some pages that use different jquery version to avoid errors { $btnUser .= ' @@ -1919,12 +1919,12 @@ function top_menu_bookmark() $html = ''; // Define $bookmarks - if (! empty($conf->bookmark->enabled) && $user->rights->bookmark->lire) + if (!empty($conf->bookmark->enabled) && $user->rights->bookmark->lire) { include_once DOL_DOCUMENT_ROOT.'/bookmarks/bookmarks.lib.php'; $langs->load("bookmarks"); - $html.= ' + $html .= '