diff --git a/ChangeLog b/ChangeLog index 1ce34b5e87a..6fdbcfcd899 100644 --- a/ChangeLog +++ b/ChangeLog @@ -29,6 +29,7 @@ Following changes may create regressions for some external modules, but were nec * All properties 'labelstatusshort' and 'labelstatut_short' were renamed into 'labelStatusShort'. * All properties 'type_libelle' were renamed into 'type_label'. * Renamed property of thirdparty "statut_commercial" into "status_prospect_label" +* The jquery plugin/dependency multiselect has been removed. It was not used by Dolibarr core. ***** ChangeLog for 10.0.3 compared to 10.0.2 ***** IMPORTANT : This version fixes a serious bug in saving the units of weight, size, surface and volume on product card. diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 02174ea2524..86ec1162832 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; // Load translation files required by the page $langs->loadLangs(array("accountancy")); -$page = GETPOST("page"); +$page = GETPOST("page", 'int'); $sortorder = GETPOST("sortorder", 'alpha'); $sortfield = GETPOST("sortfield", 'alpha'); $action = GETPOST('action', 'aZ09'); diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index d898be2b208..0db4c7b6c24 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -575,8 +575,8 @@ if ($action == 'delmouv') { } if ($action == 'delbookkeepingyear') { $form_question = array(); - $delyear = GETPOST('delyear'); - $deljournal = GETPOST('deljournal'); + $delyear = GETPOST('delyear', 'int'); + $deljournal = GETPOST('deljournal', 'alpha'); if (empty($delyear)) { $delyear = dol_print_date(dol_now(), '%Y'); diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 43d0731c434..6bd27da529b 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -75,7 +75,7 @@ if (empty($action) && empty($id) && empty($ref)) $action = 'view'; 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) access_forbidden(); +//if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; //$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0); //$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); @@ -418,10 +418,25 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (function_exists('imap_open')) { $connectstringserver = $object->getConnectStringIMAP(); - $connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir); - $connectstringtarget = $connectstringserver.imap_utf7_encode($targetdir); - $connection = imap_open($connectstringsource, $object->login, $object->password); + try { + if ($sourcedir) { + //$connectstringsource = $connectstringserver.imap_utf7_encode($sourcedir); + $connectstringsource = $connectstringserver.$object->getEncodedUtf7($sourcedir); + } + if ($targetdir) { + //$connectstringtarget = $connectstringserver.imap_utf7_encode($targetdir); + $connectstringtarget = $connectstringserver.$object->getEncodedUtf7($targetdir); + } + + $connection = imap_open($connectstringsource, $object->login, $object->password); + } + catch(Exception $e) + { + print $e->getMessage(); + } + + $morehtml .= $form->textwithpicto('', 'connect string '.$connectstringserver); } else { @@ -509,11 +524,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea else { jQuery("#rulevalue").prop("disabled", false); } jQuery("#rulevalue").attr("placeholder", (jQuery("#filtertype option:selected").attr("data-placeholder"))); '; - $noparam = array(); + /*$noparam = array(); foreach ($arrayoftypes as $key => $value) { if ($value['noparam']) $noparam[] = $key; - } + }*/ print '})'; print ''."\n"; diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index f0b0218c0e5..5f6d52e1169 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -43,7 +43,7 @@ $type='contract'; if (empty($conf->global->HOLIDAY_ADDON)) { - $conf->global->HOLIDAY_ADDON='mod_holiday_madona'; + $conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna'; } diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index c52f899a03f..5f59a198fa4 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -315,7 +315,7 @@ if ($action == 'edit') // SuperAdministrator access only if (empty($conf->multicompany->enabled) || ($user->admin && ! $user->entity)) { - print ''; + print ''; print ''; print ''.$langs->trans("SeeLocalSendMailSetup").''; } @@ -384,11 +384,13 @@ if ($action == 'edit') 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:''); - print ''.$langs->trans("MAIN_MAIL_SMTPS_PW").''; + print ''; + print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_PW"), $langs->trans("WithGMailYouCanCreateADedicatedPassword")); + print ''; // SuperAdministrator access only if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) { - print ''; + print ''; } else { diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index c5201adedeb..e287db9c7c9 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -135,6 +135,10 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { + // Actions cancel, add, update, delete or clone + $backurlforlist = $_SERVER["PHP_SELF"].'?action=list'; + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; @@ -344,7 +348,7 @@ print '
'; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; @@ -354,7 +358,7 @@ $newcardbutton = ''; if ($action != 'create') { $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $_SERVER['PHP_SELF'].'?action=create', '', $permissiontoadd); } else { - print ''; + /*print ''; if ($optioncss != '') print ''; print ''; print ''; @@ -362,13 +366,18 @@ if ($action != 'create') { print ''; print ''; print ''; + */ print ''; print ''; print ''; - print ''; - print ''; + print ''; + print ''; print ''; print '
'.$langs->trans("Label").'
'.$langs->trans("Email").'
'.$langs->trans("Signature").'
'.$langs->trans("Position").'
'.$langs->trans("Signature").''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('signature', GETPOST('signature'), '', 138, 'dolibarr_notes', 'In', true, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%'); + print $doleditor->Create(1); + print '
'.$langs->trans("Position").'
'.$langs->trans("Status").''; - print ''; + print $form->selectyesno('active', GETPOST('active', 'int'), 1); print '
'; print '
'; @@ -377,7 +386,7 @@ if ($action != 'create') { print '   '; print ''; print ''; - print '
'; + //print ''; } print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit); diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 448f5d15ed9..4785ab78174 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -79,7 +79,7 @@ class Documents extends DolibarrApi } //--- Finds and returns the document - $entity=$conf->entity; + $entity = $conf->entity; $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'read'); $accessallowed = $check_access['accessallowed']; @@ -94,16 +94,16 @@ class Documents extends DolibarrApi } $filename = basename($original_file); - $original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset + $original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset - if (! file_exists($original_file_osencoded)) + if (!file_exists($original_file_osencoded)) { dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING); throw new RestException(404, 'File not found'); } - $file_content=file_get_contents($original_file_osencoded); - return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'encoding'=>'base64' ); + $file_content = file_get_contents($original_file_osencoded); + return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'encoding'=>'base64'); } @@ -141,12 +141,12 @@ class Documents extends DolibarrApi $outputlangs = $langs; if ($langcode && $langs->defaultlang != $langcode) { - $outputlangs=new Translate('', $conf); + $outputlangs = new Translate('', $conf); $outputlangs->setDefaultLang($langcode); } //--- Finds and returns the document - $entity=$conf->entity; + $entity = $conf->entity; $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'write'); $accessallowed = $check_access['accessallowed']; @@ -165,20 +165,20 @@ class Documents extends DolibarrApi $hidedesc = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 0 : 1; $hideref = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 0 : 1; - $templateused=''; + $templateused = ''; if ($modulepart == 'facture' || $modulepart == 'invoice') { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $this->invoice = new Facture($this->db); $result = $this->invoice->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file))); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Invoice not found'); } - $templateused = $doctemplate?$doctemplate:$this->invoice->modelpdf; + $templateused = $doctemplate ? $doctemplate : $this->invoice->modelpdf; $result = $this->invoice->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref); - if( $result <= 0 ) { + if ($result <= 0) { throw new RestException(500, 'Error generating document'); } } @@ -187,12 +187,12 @@ class Documents extends DolibarrApi require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; $this->order = new Commande($this->db); $result = $this->order->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file))); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Order not found'); } - $templateused = $doctemplate?$doctemplate:$this->order->modelpdf; + $templateused = $doctemplate ? $doctemplate : $this->order->modelpdf; $result = $this->order->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref); - if( $result <= 0 ) { + if ($result <= 0) { throw new RestException(500, 'Error generating document'); } } @@ -201,12 +201,12 @@ class Documents extends DolibarrApi require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; $this->propal = new Propal($this->db); $result = $this->propal->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file))); - if( ! $result ) { + if (!$result) { throw new RestException(404, 'Proposal not found'); } - $templateused = $doctemplate?$doctemplate:$this->propal->modelpdf; + $templateused = $doctemplate ? $doctemplate : $this->propal->modelpdf; $result = $this->propal->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref); - if( $result <= 0 ) { + if ($result <= 0) { throw new RestException(500, 'Error generating document'); } } @@ -216,15 +216,15 @@ class Documents extends DolibarrApi } $filename = basename($original_file); - $original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset + $original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset - if (! file_exists($original_file_osencoded)) + if (!file_exists($original_file_osencoded)) { throw new RestException(404, 'File not found'); } - $file_content=file_get_contents($original_file_osencoded); - return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'langcode'=>$outputlangs->defaultlang, 'template'=>$templateused, 'encoding'=>'base64' ); + $file_content = file_get_contents($original_file_osencoded); + return array('filename'=>$filename, 'content-type' => dol_mimetype($filename), 'filesize'=>filesize($original_file), 'content'=>base64_encode($file_content), 'langcode'=>$outputlangs->defaultlang, 'template'=>$templateused, 'encoding'=>'base64'); } /** @@ -257,7 +257,7 @@ class Documents extends DolibarrApi throw new RestException(400, 'bad value for parameter id or ref'); } - $id = (empty($id)?0:$id); + $id = (empty($id) ? 0 : $id); if ($modulepart == 'societe' || $modulepart == 'thirdparty') { @@ -268,12 +268,12 @@ class Documents extends DolibarrApi } $object = new Societe($this->db); - $result=$object->fetch($id, $ref); - if ( ! $result ) { + $result = $object->fetch($id, $ref); + if (!$result) { throw new RestException(404, 'Thirdparty not found'); } - $upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id; + $upload_dir = $conf->societe->multidir_output[$object->entity]."/".$object->id; } elseif ($modulepart == 'adherent' || $modulepart == 'member') { @@ -284,12 +284,12 @@ class Documents extends DolibarrApi } $object = new Adherent($this->db); - $result=$object->fetch($id, $ref); - if ( ! $result ) { + $result = $object->fetch($id, $ref); + if (!$result) { throw new RestException(404, 'Member not found'); } - $upload_dir = $conf->adherent->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'member'); + $upload_dir = $conf->adherent->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'member'); } elseif ($modulepart == 'propal' || $modulepart == 'proposal') { @@ -300,12 +300,12 @@ class Documents extends DolibarrApi } $object = new Propal($this->db); - $result=$object->fetch($id, $ref); - if ( ! $result ) { + $result = $object->fetch($id, $ref); + if (!$result) { throw new RestException(404, 'Proposal not found'); } - $upload_dir = $conf->propal->multidir_output[$object->entity] . "/" . get_exdir(0, 0, 0, 1, $object, 'propal'); + $upload_dir = $conf->propal->multidir_output[$object->entity]."/".get_exdir(0, 0, 0, 1, $object, 'propal'); } elseif ($modulepart == 'commande' || $modulepart == 'order') { @@ -316,12 +316,12 @@ class Documents extends DolibarrApi } $object = new Commande($this->db); - $result=$object->fetch($id, $ref); - if ( ! $result ) { + $result = $object->fetch($id, $ref); + if (!$result) { throw new RestException(404, 'Order not found'); } - $upload_dir = $conf->commande->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'commande'); + $upload_dir = $conf->commande->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'commande'); } elseif ($modulepart == 'shipment' || $modulepart == 'expedition') { @@ -332,12 +332,12 @@ class Documents extends DolibarrApi } $object = new Expedition($this->db); - $result=$object->fetch($id, $ref); - if ( ! $result ) { + $result = $object->fetch($id, $ref); + if (!$result) { throw new RestException(404, 'Shipment not found'); } - $upload_dir = $conf->expedition->dir_output . "/sending/" . get_exdir(0, 0, 0, 1, $object, 'shipment'); + $upload_dir = $conf->expedition->dir_output."/sending/".get_exdir(0, 0, 0, 1, $object, 'shipment'); } elseif ($modulepart == 'facture' || $modulepart == 'invoice') { @@ -348,12 +348,12 @@ class Documents extends DolibarrApi } $object = new Facture($this->db); - $result=$object->fetch($id, $ref); - if ( ! $result ) { + $result = $object->fetch($id, $ref); + if (!$result) { throw new RestException(404, 'Invoice not found'); } - $upload_dir = $conf->facture->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'invoice'); + $upload_dir = $conf->facture->dir_output."/".get_exdir(0, 0, 0, 1, $object, 'invoice'); } elseif ($modulepart == 'produit' || $modulepart == 'product') { @@ -364,8 +364,8 @@ class Documents extends DolibarrApi } $object = new Product($this->db); - $result=$object->fetch($id, $ref); - if ( ! $result ) { + $result = $object->fetch($id, $ref); + if (!$result) { throw new RestException(404, 'Product not found'); } @@ -380,8 +380,8 @@ class Documents extends DolibarrApi } $object = new ActionComm($this->db); - $result=$object->fetch($id, $ref); - if ( ! $result ) { + $result = $object->fetch($id, $ref); + if (!$result) { throw new RestException(404, 'Event not found'); } @@ -392,9 +392,9 @@ class Documents extends DolibarrApi throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); } - $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); + $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1); if (empty($filearray)) { - throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(! empty($object->Ref)?' or Ref '.$object->ref:'').' does not return any document.'); + throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(!empty($object->Ref) ? ' or Ref '.$object->ref : '').' does not return any document.'); } return $filearray; @@ -447,7 +447,7 @@ class Documents extends DolibarrApi var_dump($filecontent); exit;*/ - if(empty($modulepart)) + if (empty($modulepart)) { throw new RestException(400, 'Modulepart not provided.'); } @@ -467,11 +467,11 @@ class Documents extends DolibarrApi $entity = DolibarrApiAccess::$user->entity; if ($ref) { - $tmpreldir=''; + $tmpreldir = ''; if ($modulepart == 'facture' || $modulepart == 'invoice') { - $modulepart='facture'; + $modulepart = 'facture'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $object = new Facture($this->db); @@ -491,11 +491,11 @@ class Documents extends DolibarrApi $task_result = $object->fetch('', $ref); // Fetching the tasks project is required because its out_dir might be a sub-directory of the project - if($task_result > 0) + if ($task_result > 0) { $project_result = $object->fetch_projet(); - if($project_result >= 0) + if ($project_result >= 0) { $tmpreldir = dol_sanitizeFileName($object->project->ref).'/'; } @@ -516,11 +516,11 @@ class Documents extends DolibarrApi throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); } - if(is_object($object)) + if (is_object($object)) { $result = $object->fetch('', $ref); - if($result == 0) + if ($result == 0) { throw new RestException(404, "Object with ref '".$ref."' was not found."); } @@ -530,7 +530,7 @@ class Documents extends DolibarrApi } } - if (! ($object->id > 0)) + if (!($object->id > 0)) { throw new RestException(404, 'The object '.$modulepart." with ref '".$ref."' was not found."); } @@ -538,7 +538,7 @@ class Documents extends DolibarrApi $relativefile = $tmpreldir.dol_sanitizeFileName($object->ref); $tmp = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, $ref, 'write'); - $upload_dir = $tmp['original_file']; // No dirname here, tmp['original_file'] is already the dir because dol_check_secure_access_document was called with param original_file that is only the dir + $upload_dir = $tmp['original_file']; // No dirname here, tmp['original_file'] is already the dir because dol_check_secure_access_document was called with param original_file that is only the dir if (empty($upload_dir) || $upload_dir == '/') { @@ -547,12 +547,12 @@ class Documents extends DolibarrApi } else { - if ($modulepart == 'invoice') $modulepart ='facture'; + if ($modulepart == 'invoice') $modulepart = 'facture'; $relativefile = $subdir; $tmp = dol_check_secure_access_document($modulepart, $relativefile, $entity, DolibarrApiAccess::$user, '', 'write'); - $upload_dir = $tmp['original_file']; // No dirname here, tmp['original_file'] is already the dir because dol_check_secure_access_document was called with param original_file that is only the dir + $upload_dir = $tmp['original_file']; // No dirname here, tmp['original_file'] is already the dir because dol_check_secure_access_document was called with param original_file that is only the dir if (empty($upload_dir) || $upload_dir == '/') { @@ -568,8 +568,8 @@ class Documents extends DolibarrApi throw new RestException(500, 'Error while trying to create directory.'); } - $destfile = $upload_dir . '/' . $original_file; - $destfiletmp = DOL_DATA_ROOT.'/admin/temp/' . $original_file; + $destfile = $upload_dir.'/'.$original_file; + $destfiletmp = DOL_DATA_ROOT.'/admin/temp/'.$original_file; dol_delete_file($destfiletmp); //var_dump($original_file);exit; @@ -577,7 +577,7 @@ class Documents extends DolibarrApi throw new RestException(401, 'Directory not exists : '.dirname($destfile)); } - if (! $overwriteifexists && dol_is_file($destfile)) + if (!$overwriteifexists && dol_is_file($destfile)) { throw new RestException(500, "File with name '".$original_file."' already exists."); } @@ -595,7 +595,7 @@ class Documents extends DolibarrApi } $result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1); - if (! $result) + if (!$result) { throw new RestException(500, "Failed to move file into '".$destfile."'"); } @@ -629,7 +629,7 @@ class Documents extends DolibarrApi } //--- Finds and returns the document - $entity=$conf->entity; + $entity = $conf->entity; $check_access = dol_check_secure_access_document($modulepart, $original_file, $entity, DolibarrApiAccess::$user, '', 'read'); $accessallowed = $check_access['accessallowed']; @@ -644,9 +644,9 @@ class Documents extends DolibarrApi } $filename = basename($original_file); - $original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset + $original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset - if (! file_exists($original_file_osencoded)) + if (!file_exists($original_file_osencoded)) { dol_syslog("Try to download not found file ".$original_file_osencoded, LOG_WARNING); throw new RestException(404, 'File not found'); diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index 1f6966fcd15..b23bf03f29b 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -60,7 +60,7 @@ foreach ($object->fields as $key => $val) if (empty($action) && empty($id) && empty($ref)) $action = 'view'; // Security check - Protection if external user -//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'asset', $id); diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php index 3c91c91a675..c6488f9e0be 100644 --- a/htdocs/asset/document.php +++ b/htdocs/asset/document.php @@ -40,7 +40,7 @@ $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')) $ref = GETPOST('ref', 'alpha'); // Security check - Protection if external user -//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'asset', $id); diff --git a/htdocs/asset/note.php b/htdocs/asset/note.php index 79e80518557..9af78befa0b 100644 --- a/htdocs/asset/note.php +++ b/htdocs/asset/note.php @@ -46,7 +46,7 @@ $hookmanager->initHooks(array('assetnote')); // Note that conf->hooks_modules co $extrafields->fetch_name_optionals_label($object->table_element); // Security check - Protection if external user -//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'asset', $id); diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index d0cf2995081..8e0afc77d0a 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -53,7 +53,7 @@ else $search_agenda_label=GETPOST('search_agenda_label'); // Security check - Protection if external user -//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'bom', $id); diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 38ccb13b6b5..252caa8da10 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -70,16 +70,16 @@ if (empty($action) && empty($id) && empty($ref)) $action = 'view'; 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) access_forbidden(); +//if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; //$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0); //$result = restrictedArea($user, 'bom', $object->id, '', '', 'fk_soc', 'rowid', $isdraft); -$permissionnote=$user->rights->bom->write; // Used by the include of actions_setnotes.inc.php -$permissiondellink=$user->rights->bom->write; // Used by the include of actions_dellink.inc.php -$permissiontoadd=$user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php +$permissionnote = $user->rights->bom->write; // Used by the include of actions_setnotes.inc.php +$permissiondellink = $user->rights->bom->write; // Used by the include of actions_dellink.inc.php +$permissiontoadd = $user->rights->bom->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php $permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT); -$upload_dir = $conf->bom->multidir_output[isset($object->entity)?$object->entity:1]; +$upload_dir = $conf->bom->multidir_output[isset($object->entity) ? $object->entity : 1]; /* @@ -521,29 +521,29 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea * Lines */ - if (! empty($object->table_element_line)) + if (!empty($object->table_element_line)) { // Show object lines $result = $object->getLinesArray(); - print '
- - + print ' + + - + '; - if (! empty($conf->use_javascript_ajax) && $object->status == 0) { - include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; + if (!empty($conf->use_javascript_ajax) && $object->status == 0) { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; } print '
'; - if (! empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { print ''; } - if (! empty($object->lines)) + if (!empty($object->lines)) { $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl'); } @@ -561,7 +561,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } } - if (! empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) + if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline')) { print '
'; } @@ -613,11 +613,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { if (is_array($object->lines) && count($object->lines) > 0) { - print '' . $langs->trans("Validate") . ''; + print ''.$langs->trans("Validate").''; } else { - print '' . $langs->trans("Validate") . ''; + print ''.$langs->trans("Validate").''; } } } diff --git a/htdocs/bom/bom_document.php b/htdocs/bom/bom_document.php index 9c2280e889b..6ac836fdcae 100644 --- a/htdocs/bom/bom_document.php +++ b/htdocs/bom/bom_document.php @@ -41,7 +41,7 @@ $id = (GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int')) $ref = GETPOST('ref', 'alpha'); // Security check - Protection if external user -//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'bom', $id); diff --git a/htdocs/bom/bom_note.php b/htdocs/bom/bom_note.php index e37a64d0f28..8d4e2241e97 100644 --- a/htdocs/bom/bom_note.php +++ b/htdocs/bom/bom_note.php @@ -47,7 +47,7 @@ $hookmanager->initHooks(array('bomnote', 'globalcard')); // Note that conf->hook $extrafields->fetch_name_optionals_label($object->table_element); // Security check - Protection if external user -//if ($user->socid > 0) access_forbidden(); +//if ($user->socid > 0) accessforbidden(); //if ($user->socid > 0) $socid = $user->socid; //$result = restrictedArea($user, 'bom', $id); diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index afd71d59932..dc3a84234b0 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1467,7 +1467,7 @@ if ($id > 0) // related contact print ''.$langs->trans("ActionOnContact").''; print '
'; - print $form->selectcontacts($object->socid, array_keys($object->socpeopleassigned), 'socpeopleassigned[]', 1, '', '', 0, 'quatrevingtpercent', false, 0, 0, array(), 'multiple', 'contactid'); + print $form->selectcontacts($object->socid, array_keys($object->socpeopleassigned), 'socpeopleassigned[]', 1, '', '', 1, 'quatrevingtpercent', false, 0, 0, array(), 'multiple', 'contactid'); print '
'; print ''; print ''; diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 9c589c4ae3d..08736a3d268 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -294,7 +294,6 @@ class FormAdvTargetEmailing extends Form $options_array = array(); - $sql = "SELECT rowid, code, label as civilite, active FROM ".MAIN_DB_PREFIX."c_civility"; $sql .= " WHERE active = 1"; @@ -312,7 +311,6 @@ class FormAdvTargetEmailing extends Form // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut $label = ($langs->trans("Civility".$obj->code) != "Civility".$obj->code ? $langs->trans("Civility".$obj->code) : ($obj->civilite != '-' ? $obj->civilite : '')); - $options_array[$obj->code] = $label; $i++; diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index b38a796d3c7..cbd0c244bb3 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -271,6 +271,12 @@ if ($result) print "\n"; $i++; } + if (empty($num)) { + $colspan = 6; + if (!$filteremail) $colspan++; + print ''.$langs->trans("NoRecordFound").''; + } + print ''; print '
'; print '
'; diff --git a/htdocs/comm/remx.php b/htdocs/comm/remx.php index ac79c1fe0a7..47a31f11a72 100644 --- a/htdocs/comm/remx.php +++ b/htdocs/comm/remx.php @@ -736,35 +736,34 @@ if ($socid > 0) // Discount linked to invoice lines $sql = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx, rc.multicurrency_amount_ht, rc.multicurrency_amount_tva, rc.multicurrency_amount_ttc,"; - $sql .= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,"; $sql .= " rc.fk_facture_source,"; $sql .= " u.login, u.rowid as user_id,"; - $sql .= " f.rowid, f.ref,"; - $sql .= " fa.ref as ref, fa.type as type"; + $sql .= " f.rowid as invoiceid, f.ref,"; + $sql .= " fa.ref as invoice_source_ref, fa.type as type"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " , ".MAIN_DB_PREFIX."user as u"; $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"; $sql .= " AND rc.discount_type = 0"; // Eliminate supplier discounts $sql .= " ORDER BY dc DESC"; //$sql.= " UNION "; - // Remises liees a factures + // Discount linked to invoices $sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,"; $sql2 .= " rc.datec as dc, rc.description, rc.fk_facture_line, rc.fk_facture,"; $sql2 .= " rc.fk_facture_source,"; $sql2 .= " u.login, u.rowid as user_id,"; - $sql2 .= " f.rowid, f.ref,"; - $sql2 .= " fa.ref as ref, fa.type as type"; + $sql2 .= " f.rowid as invoiceid, f.ref,"; + $sql2 .= " fa.ref as invoice_source_ref, fa.type as type"; $sql2 .= " FROM ".MAIN_DB_PREFIX."facture as f"; $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 @@ -833,7 +832,7 @@ if ($socid > 0) { print ''; $facturestatic->id = $obj->fk_facture_source; - $facturestatic->ref = $obj->ref; + $facturestatic->ref = $obj->invoice_source_ref; $facturestatic->type = $obj->type; print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; @@ -842,7 +841,7 @@ if ($socid > 0) { print ''; $facturestatic->id = $obj->fk_facture_source; - $facturestatic->ref = $obj->ref; + $facturestatic->ref = $obj->invoice_source_ref; $facturestatic->type = $obj->type; print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; @@ -851,7 +850,7 @@ if ($socid > 0) { print ''; $facturestatic->id = $obj->fk_facture_source; - $facturestatic->ref = $obj->ref; + $facturestatic->ref = $obj->invoice_source_ref; $facturestatic->type = $obj->type; print preg_replace('/\(EXCESS RECEIVED\)/', $langs->trans("Invoice"), $obj->description).' '.$facturestatic->getNomURl(1); print ''; @@ -862,7 +861,12 @@ if ($socid > 0) print $obj->description; print ''; } - print ''.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.''; + print ''; + if ($obj->invoiceid) + { + print ''.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.''; + } + print ''; print ''.price($obj->amount_ht).''; if (!empty($conf->multicurrency->enabled)) { @@ -909,32 +913,32 @@ if ($socid > 0) $sql .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; $sql .= " rc.fk_invoice_supplier_source,"; $sql .= " u.login, u.rowid as user_id,"; - $sql .= " f.rowid, f.ref as ref,"; - $sql .= " fa.ref, fa.type as type"; + $sql .= " f.rowid as invoiceid, f.ref as ref,"; + $sql .= " fa.ref as invoice_source_ref, fa.type as type"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $sql .= " , ".MAIN_DB_PREFIX."user as u"; $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"; $sql .= " AND rc.discount_type = 1"; // Eliminate customer discounts $sql .= " ORDER BY dc DESC"; //$sql.= " UNION "; - // Remises liees a factures + // Discount linked to invoices $sql2 = "SELECT rc.rowid, rc.amount_ht, rc.amount_tva, rc.amount_ttc, rc.tva_tx,"; $sql2 .= " rc.datec as dc, rc.description, rc.fk_invoice_supplier_line, rc.fk_invoice_supplier,"; $sql2 .= " rc.fk_invoice_supplier_source,"; $sql2 .= " u.login, u.rowid as user_id,"; - $sql2 .= " f.rowid, f.ref as ref,"; - $sql2 .= " fa.ref, fa.type as type"; + $sql2 .= " f.rowid as invoiceid, f.ref as ref,"; + $sql2 .= " fa.ref as invoice_source_ref, fa.type as type"; $sql2 .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; $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 @@ -1003,7 +1007,7 @@ if ($socid > 0) { print ''; $facturefournstatic->id = $obj->fk_invoice_supplier_source; - $facturefournstatic->ref = $obj->ref; + $facturefournstatic->ref = $obj->invoice_source_ref; $facturefournstatic->type = $obj->type; print preg_replace('/\(CREDIT_NOTE\)/', $langs->trans("CreditNote"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; @@ -1012,7 +1016,7 @@ if ($socid > 0) { print ''; $facturefournstatic->id = $obj->fk_invoice_supplier_source; - $facturefournstatic->ref = $obj->ref; + $facturefournstatic->ref = $obj->invoice_source_ref; $facturefournstatic->type = $obj->type; print preg_replace('/\(DEPOSIT\)/', $langs->trans("InvoiceDeposit"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; @@ -1021,7 +1025,7 @@ if ($socid > 0) { print ''; $facturefournstatic->id = $obj->fk_invoice_supplier_source; - $facturefournstatic->ref = $obj->ref; + $facturefournstatic->ref = $obj->invoice_source_ref; $facturefournstatic->type = $obj->type; print preg_replace('/\(EXCESS PAID\)/', $langs->trans("Invoice"), $obj->description).' '.$facturefournstatic->getNomURl(1); print ''; @@ -1032,7 +1036,11 @@ if ($socid > 0) print $obj->description; print ''; } - print ''.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.''; + print ''; + if ($obj->invoiceid) { + print ''.img_object($langs->trans("ShowBill"), 'bill').' '.$obj->ref.''; + } + print ''; print ''.price($obj->amount_ht).''; if (!empty($conf->multicurrency->enabled)) { diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index b6d91b235ba..5069135dd88 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -76,7 +76,7 @@ class Orders extends DolibarrApi * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id * @return array|mixed data without useless information * - * @url GET byRef/{ref} + * @url GET ref/{ref} * * @throws RestException */ @@ -94,7 +94,7 @@ class Orders extends DolibarrApi * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id * @return array|mixed data without useless information * - * @url GET byRefExt/{ref_ext} + * @url GET ref_ext/{ref_ext} * * @throws RestException */ diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 0c093d561c0..ef15d983d20 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -977,35 +977,22 @@ class Commande extends CommonOrder $sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='".$this->db->escape($initialref)."' WHERE rowid=".$this->id; if ($this->db->query($sql)) { - if ($this->id) + $this->ref = $initialref; + + if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects { - $this->ref = $initialref; + $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds + } - if (!empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects + // Add object linked + if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) + { + foreach ($this->linked_objects as $origin => $tmp_origin_id) { - $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds - } - - // Add object linked - if (!$error && $this->id && is_array($this->linked_objects) && !empty($this->linked_objects)) - { - foreach ($this->linked_objects as $origin => $tmp_origin_id) + if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) { - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + foreach ($tmp_origin_id as $origin_id) { - foreach ($tmp_origin_id as $origin_id) - { - $ret = $this->add_object_linked($origin, $origin_id); - if (!$ret) - { - $this->error = $this->db->lasterror(); - $error++; - } - } - } - else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) - { - $origin_id = $tmp_origin_id; $ret = $this->add_object_linked($origin, $origin_id); if (!$ret) { @@ -1014,44 +1001,54 @@ class Commande extends CommonOrder } } } + else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1)) + { + $origin_id = $tmp_origin_id; + $ret = $this->add_object_linked($origin, $origin_id); + if (!$ret) + { + $this->error = $this->db->lasterror(); + $error++; + } + } } + } - if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object + if (!$error && $this->id && !empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && !empty($this->origin) && !empty($this->origin_id)) // Get contact from origin object + { + $originforcontact = $this->origin; + $originidforcontact = $this->origin_id; + if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order { - $originforcontact = $this->origin; - $originidforcontact = $this->origin_id; - if ($originforcontact == 'shipping') // shipment and order share the same contacts. If creating from shipment we take data of order + require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; + $exp = new Expedition($this->db); + $exp->fetch($this->origin_id); + $exp->fetchObjectLinked(); + if (count($exp->linkedObjectsIds['commande']) > 0) { - require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; - $exp = new Expedition($this->db); - $exp->fetch($this->origin_id); - $exp->fetchObjectLinked(); - if (count($exp->linkedObjectsIds['commande']) > 0) + foreach ($exp->linkedObjectsIds['commande'] as $key => $value) { - foreach ($exp->linkedObjectsIds['commande'] as $key => $value) - { - $originforcontact = 'commande'; - if (is_object($value)) $originidforcontact = $value->id; - else $originidforcontact = $value; - break; // We take first one - } + $originforcontact = 'commande'; + if (is_object($value)) $originidforcontact = $value->id; + else $originidforcontact = $value; + break; // We take first one } } - - $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; - $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; - - $resqlcontact = $this->db->query($sqlcontact); - if ($resqlcontact) - { - while ($objcontact = $this->db->fetch_object($resqlcontact)) - { - //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; - $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object - } - } - else dol_print_error($resqlcontact); } + + $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; + $sqlcontact .= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'"; + + $resqlcontact = $this->db->query($sqlcontact); + if ($resqlcontact) + { + while ($objcontact = $this->db->fetch_object($resqlcontact)) + { + //print $objcontact->code.'-'.$objcontact->source.'-'.$objcontact->fk_socpeople."\n"; + $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object + } + } + else dol_print_error($resqlcontact); } if (!$error) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 1de1e64e0c7..9e34c745fab 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -80,7 +80,7 @@ $search_total_ttc = GETPOST('search_total_ttc', 'alpha'); $search_categ_cus = trim(GETPOST("search_categ_cus", 'int')); $optioncss = GETPOST('optioncss', 'alpha'); $billed = GETPOST('billed', 'int'); -$viewstatut = GETPOST('viewstatut'); +$viewstatut = GETPOST('viewstatut', 'int'); $search_btn = GETPOST('button_search', 'alpha'); $search_remove_btn = GETPOST('button_removefilter', 'alpha'); $search_project_ref = GETPOST('search_project_ref', 'alpha'); 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/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index bfbafc93bd5..eeb662c6168 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -698,10 +698,7 @@ if ($resql) print ' '; print ''.$langs->trans("Type").''; print ''.$langs->trans("Numero").''; - //if (! $search_account > 0) - //{ - print ''.$langs->trans("BankAccount").''; - //} + print ''.$langs->trans("BankAccount").''; print ''.$langs->trans("Debit").''; print ''.$langs->trans("Credit").''; /*if (! empty($conf->accounting->enabled)) @@ -824,19 +821,21 @@ if ($resql) $moreforfilter = ''; $moreforfilter .= '
'; - $moreforfilter .= $langs->trans('DateOperationShort').' : '; - $moreforfilter .= '
'.$langs->trans('From').' '; + $moreforfilter .= $langs->trans('DateOperationShort').' :'; + $moreforfilter .= ($conf->browser->layout == 'phone' ? '
' : ' '); + $moreforfilter .= '
'.$langs->trans('From').' '; $moreforfilter .= $form->selectDate($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0).'
'; //$moreforfilter .= ' - '; - $moreforfilter .= '
'.$langs->trans('to').' '.$form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0).'
'; + $moreforfilter .= '
'.$langs->trans('to').' '.$form->selectDate($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0).'
'; $moreforfilter .= '
'; $moreforfilter .= '
'; $moreforfilter .= $langs->trans('DateValueShort').' : '; - $moreforfilter .= '
'.$langs->trans('From').' '; + $moreforfilter .= ($conf->browser->layout == 'phone' ? '
' : ' '); + $moreforfilter .= '
'.$langs->trans('From').' '; $moreforfilter .= $form->selectDate($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0).'
'; //$moreforfilter .= ' - '; - $moreforfilter .= '
'.$langs->trans('to').' '.$form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0).'
'; + $moreforfilter .= '
'.$langs->trans('to').' '.$form->selectDate($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0).'
'; $moreforfilter .= '
'; if (!empty($conf->categorie->enabled)) diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index ab93b2f0f97..72226f18cd6 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -283,7 +283,7 @@ if ($action == 'create') // Label print ''; print $form->editfieldkey('Label', 'label', '', $object, 0, 'string', '', 1).''; - print ''; + print ''; print ''; // Sens @@ -296,7 +296,7 @@ if ($action == 'create') // Amount print ''; print $form->editfieldkey('Amount', 'amount', '', $object, 0, 'string', '', 1).''; - print ''; + print ''; print ''; // Bank @@ -321,7 +321,7 @@ if ($action == 'create') print ''; - print ''."\n"; + print ''."\n"; } // Project @@ -358,13 +358,13 @@ if ($action == 'create') // TODO Remove the fieldrequired and allow instead to edit a various payment to enter accounting code print ''.$langs->trans("AccountAccounting").''; print ''; - print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1, ''); + print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1); print ''; } else // For external software { print ''.$langs->trans("AccountAccounting").''; - print ''; + print ''; print ''; } @@ -379,14 +379,14 @@ if ($action == 'create') } else { - print ''; + print ''; } print ''; } else // For external software { print ''.$langs->trans("SubledgerAccount").''; - print ''; + print ''; print ''; } 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/contact/card.php b/htdocs/contact/card.php index 23e0befc4c5..f374dc89e23 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -622,9 +622,14 @@ else // Name print ''; - print 'lastname).'" autofocus="autofocus">'; - print ''; - print 'firstname).'">'; + print 'lastname).'" autofocus="autofocus">'; + print ''; + + print ''; + print ''; + print 'firstname).'">'; + print ''; // Company if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) @@ -715,19 +720,24 @@ else // Phone / Fax print ''.img_picto('', 'object_phoning').' '.$form->editfieldkey('PhonePro', 'phone_pro', '', $object, 0).''; print ''; + if ($conf->browser->layout == 'phone') print ''; print ''.img_picto('', 'object_phoning').' '.$form->editfieldkey('PhonePerso', 'phone_perso', '', $object, 0).''; print ''; print ''.img_picto('', 'object_phoning_mobile').' '.$form->editfieldkey('PhoneMobile', 'phone_mobile', '', $object, 0).''; print ''; + if ($conf->browser->layout == 'phone') print ''; print ''.img_picto('', 'object_phoning_fax').' '.$form->editfieldkey('Fax', 'fax', '', $object, 0).''; - print ''; + print ''; + print ''; if (($objsoc->typent_code == 'TE_PRIVATE' || !empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) && dol_strlen(trim($object->email)) == 0) $object->email = $objsoc->email; // Predefined with third party // Email print ''.img_picto('', 'object_email').' '.$form->editfieldkey('EMail', 'email', '', $object, 0, 'string', '').''; print ''; + print ''; + if (!empty($conf->mailing->enabled)) { $noemail = ''; @@ -743,12 +753,10 @@ else } } + print ''; print ''; print ''.$form->selectyesno('no_email', (GETPOSTISSET("no_email") ?GETPOST("no_email", 'alpha') : $noemail), 1).''; - } - else - { - print ' '; + print ''; } print ''; @@ -842,7 +850,7 @@ else print ''; // Date To Birth - print ''; - print ''; + print ''; } else { - print ''; + print ''; } + print ''; print ''; print "
'; + print '
'; $form = new Form($db); if ($object->birthday) { @@ -854,15 +862,16 @@ else } print ': '; + print ': '; if ($object->birthday_alert) { - print '
"; diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index ee4208cd65e..0d718c2abc2 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -75,6 +75,7 @@ if ($action == 'add' && !empty($permissiontoadd)) if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value = ''; // This is an implicit foreign key field if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') $value = ''; // This is an explicit foreign key field + //var_dump($key.' '.$value.' '.$object->fields[$key]['type']); $object->$key = $value; if ($val['notnull'] > 0 && $object->$key == '' && !is_null($val['default']) && $val['default'] == '(PROV)') { 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/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 335c1b50111..eb15710eb7c 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -626,6 +626,7 @@ class CMailFile } // Force parameters + //dol_syslog("CMailFile::sendfile conf->global->".$keyforsmtpserver."=".$conf->global->$keyforsmtpserver." cpnf->global->".$keyforsmtpport."=".$conf->global->$keyforsmtpport, LOG_DEBUG); if (!empty($conf->global->$keyforsmtpserver)) ini_set('SMTP', $conf->global->$keyforsmtpserver); if (!empty($conf->global->$keyforsmtpport)) ini_set('smtp_port', $conf->global->$keyforsmtpport); @@ -776,7 +777,7 @@ class CMailFile else { if (empty($this->error)) $this->error = $result; - dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR); + dol_syslog("CMailFile::sendfile: mail end error with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport."
".$this->error, LOG_ERR); $res = false; } } diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1fb0fe17a75..bbd11c8f522 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6571,7 +6571,8 @@ abstract class CommonObject /** - * Function to show lines of extrafields with output datas + * Function to show lines of extrafields with output datas. + * This function is responsible to output the and according to correct number of columns received into $params['colspan'] * * @param Extrafields $extrafields Extrafield Object * @param string $mode Show output (view) or input (edit) for extrafield diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index b65d72332e0..41a0d485ce0 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -56,19 +56,28 @@ class EmailSenderProfile extends CommonObject public $picto = 'emailsenderprofile@monmodule'; + const STATUS_DISABLED = 0; + const STATUS_ENABLED = 1; + + /** - * 'type' if the field format. - * 'label' the translation key. - * 'enabled' is a condition when the filed must be managed. - * 'visible' says if field is visible in list (-1 means not shown by default but can be added into list to be viewed). - * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). - * 'index' if we want an index in database. - * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). - * 'position' is the sort order of field. - * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. - * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). - * 'help' is a string visible as a tooltip on field - * 'comment' is not used. You can store here any text of your choice. + * 'type' if the field format ('integer', 'integer:Class:pathtoclass', 'varchar(x)', 'double(24,8)', 'text', 'html', 'datetime', 'timestamp', 'float') + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed. + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only, 3=Visible on create/update/view form only (not list), 4=Visible on list and update/view form only (not create). Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'noteditable' says if field is not editable (1 or 0) + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'default' is a default value for creation (can still be replaced by the global setup of default values) + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'position' is the sort order of field. + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' is the CSS style to use on field. For example: 'maxwidth200' + * 'help' is a string visible as a tooltip on field + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") */ // BEGIN MODULEBUILDER PROPERTIES @@ -78,7 +87,7 @@ class EmailSenderProfile extends CommonObject 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), + 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>1), 'email' => array('type'=>'varchar(255)', 'label'=>'Email', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1), //'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), //'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>-1,), @@ -86,7 +95,7 @@ class EmailSenderProfile extends CommonObject 'position' => array('type'=>'integer', 'label'=>'Position', 'visible'=>1, 'enabled'=>1, 'position'=>405, 'notnull'=>-1, 'index'=>1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), - 'active' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1), + 'active' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'default'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1), ); /** diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index cac859c53b5..d70993be51d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6521,6 +6521,7 @@ class Form elseif ($addjscombo == 2) { // Add other js lib + // TODO external lib multiselect/jquery.multi-select.js must have been loaded to use this multiselect plugin // ... $out .= '$(document).ready(function () { $(\'#'.$htmlname.'\').multiSelect({ diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 00ca3f3d45f..9faa3762111 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3911,9 +3911,9 @@ function dol_print_error($db = '', $error = '', $errors = null) } if (empty($dolibarr_main_prod)) print $out; - else + else // This should not happen, except if there is a bug somewhere. Enabled and check log in such case. { - print 'This website is currently temporarly offline. This may be due to a maintenance operation. Current status of operation are on next line...

'."\n"; + print 'This website is currently temporarly offline.

This may be due to a maintenance operation. Current status of operation are on next line...

'."\n"; $langs->load("errors"); print $langs->trans("DolibarrHasDetectedError").'. '; print $langs->trans("YouCanSetOptionDolibarrMainProdToZero"); diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index d5226bb7e3d..7a3102e8aca 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -422,7 +422,8 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f if (! empty($objectid) && $objectid > 0) { $ok = checkUserAccessToObject($user, $featuresarray, $objectid, $tableandshare, $feature2, $dbt_keyfield, $dbt_select); - return $ok ? 1 : accessforbidden(); + $params=array('objectid' => $objectid, 'features' => join(',', $featuresarray), 'features2' => $feature2); + return $ok ? 1 : accessforbidden('', 1, 1, 0, $params); } return 1; @@ -660,13 +661,14 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand * Show a message to say access is forbidden and stop program * Calling this function terminate execution of PHP. * - * @param string $message Force error message - * @param int $printheader Show header before - * @param int $printfooter Show footer after - * @param int $showonlymessage Show only message parameter. Otherwise add more information. + * @param string $message Force error message + * @param int $printheader Show header before + * @param int $printfooter Show footer after + * @param int $showonlymessage Show only message parameter. Otherwise add more information. + * @param array|null $params Send params * @return void */ -function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0) +function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $showonlymessage = 0, $params = null) { global $conf, $db, $user, $langs, $hookmanager; if (! is_object($langs)) @@ -697,7 +699,7 @@ function accessforbidden($message = '', $printheader = 1, $printfooter = 1, $sho // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('main')); } - $parameters = array('message'=>$message); + $parameters = array('message'=>$message, 'params'=>$params); $reshook=$hookmanager->executeHooks('getAccessForbiddenMessage', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks print $hookmanager->resPrint; if (empty($reshook)) diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 68f4a3d5fba..8f99dcc59a1 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -35,7 +35,6 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; */ class modExpedition extends DolibarrModules { - /** * Constructor. Define names, constants, directories, boxes, permissions * @@ -133,7 +132,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(); @@ -187,7 +188,7 @@ class modExpedition extends DolibarrModules $r++; $this->rights[$r][0] = 1101; - $this->rights[$r][1] = 'Lire les bons de livraison'; + $this->rights[$r][1] = 'Read delivery receipts'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'livraison'; @@ -195,7 +196,7 @@ class modExpedition extends DolibarrModules $r++; $this->rights[$r][0] = 1102; - $this->rights[$r][1] = 'Creer modifier les bons de livraison'; + $this->rights[$r][1] = 'Create/modify delivery receipts'; $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'livraison'; @@ -203,7 +204,7 @@ class modExpedition extends DolibarrModules $r++; $this->rights[$r][0] = 1104; - $this->rights[$r][1] = 'Valider les bons de livraison'; + $this->rights[$r][1] = 'Validate delivery receipts'; $this->rights[$r][2] = 'd'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'livraison_advance'; @@ -211,7 +212,7 @@ class modExpedition extends DolibarrModules $r++; $this->rights[$r][0] = 1109; - $this->rights[$r][1] = 'Supprimer les bons de livraison'; + $this->rights[$r][1] = 'Delete delivery receipts'; $this->rights[$r][2] = 'd'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'livraison'; diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 081149be51d..917da8fec25 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -269,4 +269,45 @@ class modHoliday extends DolibarrModules // $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_facture'; // $r++; } + + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + global $conf; + + // Permissions + $this->remove($options); + + //ODT template + /*$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/holiday/template_holiday.odt'; + $dirodt=DOL_DATA_ROOT.'/doctemplates/holiday'; + $dest=$dirodt.'/template_order.odt'; + + 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); + if ($result < 0) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest); + return 0; + } + } + + $sql = array( + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'holiday' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','holiday',".$conf->entity.")" + );*/ + + return $this->_init($sql, $options); + } } diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index e74f76669cf..6ea964bbc66 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -91,7 +91,7 @@ $(document).ready(function () {
- + diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index efdb3ea5d3b..6556590c076 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -667,22 +667,56 @@ class EmailCollector extends CommonObject /** * Return the connectstring to use with IMAP connection function * + * @param int $ssl Add /ssl tag + * @param int $norsh Add /norsh to connectstring * @return string */ - public function getConnectStringIMAP() + public function getConnectStringIMAP($ssl = 1, $norsh = 0) { + global $conf; + // Connect to IMAP $flags = '/service=imap'; // IMAP - $flags .= '/ssl'; // '/tls' + if ($ssl) $flags .= '/ssl'; // '/tls' $flags .= '/novalidate-cert'; //$flags.='/readonly'; //$flags.='/debug'; + if ($norsh || ! empty($conf->global->IMPA_FORCE_NORSH)) $flags .= '/norsh'; $connectstringserver = '{'.$this->host.':993'.$flags.'}'; return $connectstringserver; } + /** + * Convert str to UTF-7 imap default mailbox names + * + * @param string $str String to encode + * @return string Encode string + */ + public function getEncodedUtf7($str) + { + if (function_exists('mb_convert_encoding')) { + // change spaces by entropy because mb_convert fail with spaces + $str=preg_replace("/ /", "xyxy", $str); + // if mb_convert work + if ($str = mb_convert_encoding($str, "UTF-7")) { + // change characters + $str=preg_replace("/\+A/", "&A", $str); + // change to spaces again + $str=preg_replace("/xyxy/", " ", $str); + return $str; + } else { + // print error and return false + $this->error = "error: is not possible to encode this string '".$str."'"; + return false; + } + } + else { + return $str; + } + } + /** * Action executed by scheduler * CAN BE A CRON TASK. In such a case, paramerts come from the schedule job setup field 'Parameters' @@ -854,7 +888,7 @@ class EmailCollector extends CommonObject dol_syslog("EmailCollector::doCollectOneCollector start", LOG_DEBUG); - $langs->loadLangs(array("project", "companies", "mails", "errors", "ticket")); + $langs->loadLangs(array("project", "companies", "mails", "errors", "ticket", "agenda")); $error = 0; $this->output = ''; @@ -1060,7 +1094,6 @@ class EmailCollector extends CommonObject // If there is a filter on trackid if ($searchfilterdoltrackid > 0) { - //if (empty($headers['X-Dolibarr-TRACKID'])) continue; if (empty($headers['References']) || !preg_match('/@'.preg_quote($host, '/').'/', $headers['References'])) { $nbemailprocessed++; @@ -1074,7 +1107,6 @@ class EmailCollector extends CommonObject $nbemailprocessed++; continue; } - //if (! empty($headers['X-Dolibarr-TRACKID']) continue; } $thirdpartystatic = new Societe($this->db); @@ -1090,11 +1122,30 @@ class EmailCollector extends CommonObject $this->db->begin(); + // GET Email meta datas $overview = imap_fetch_overview($connection, $imapemail, 0); dol_syslog("** Process email - msgid=".$overview[0]->message_id." date=".dol_print_date($overview[0]->udate, 'dayrfc', 'gmt')." subject=".$overview[0]->subject); + // Decode $overview[0]->subject according to RFC2047 + // Can use also imap_mime_header_decode($str) + // Can use also mb_decode_mimeheader($str) + // Can use also iconv_mime_decode($str, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8') + if (function_exists('imap_mime_header_decode')) { + $elements = imap_mime_header_decode($overview[0]->subject); + $newstring = ''; + if (! empty($elements)) { + for ($i = 0; $i < count($elements); $i++) { + $newstring .= ($newstring ? ' ' : '').$elements[$i]->text; + } + $overview[0]->subject = $newstring; + } + } + elseif (function_exists('mb_decode_mimeheader')) { + $overview[0]->subject = mb_decode_mimeheader($overview[0]->subject); + } + // Parse IMAP email structure global $htmlmsg, $plainmsg, $charset, $attachments; $this->getmsg($connection, $imapemail); @@ -1459,78 +1510,85 @@ class EmailCollector extends CommonObject // Create event elseif ($operation['type'] == 'recordevent') { - if ($projectstatic->id > 0) - { - if ($projectfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Project found from '.$projectfoundby); - } - if ($thirdpartystatic->id > 0) - { - if ($thirdpartyfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); - } - if ($contactstatic->id > 0) - { - if ($contactfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); - } + $alreadycreated = 0; + // TODO Check if $msg ID already in database for $conf->entity - $description = $descriptiontitle; - $description = dol_concatdesc($description, "-----"); - $description = dol_concatdesc($description, $descriptionmeta); - $description = dol_concatdesc($description, "-----"); - $description = dol_concatdesc($description, $messagetext); - $descriptionfull = $description; - $descriptionfull = dol_concatdesc($descriptionfull, "----- Header"); - $descriptionfull = dol_concatdesc($descriptionfull, $header); + if (! $alreadycreated) + { + if ($projectstatic->id > 0) + { + if ($projectfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Project found from '.$projectfoundby); + } + if ($thirdpartystatic->id > 0) + { + if ($thirdpartyfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Third party found from '.$thirdpartyfoundby); + } + if ($contactstatic->id > 0) + { + if ($contactfoundby) $descriptionmeta = dol_concatdesc($descriptionmeta, 'Contact/address found from '.$contactfoundby); + } - // Insert record of emails sent - $actioncomm = new ActionComm($this->db); - $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) - $actioncomm->code = 'AC_'.$actioncode; - $actioncomm->label = $langs->trans("ActionAC_".$actioncode).' - '.$langs->trans("MailFrom").' '.$from; - $actioncomm->note_private= $descriptionfull; - $actioncomm->fk_project = $projectstatic->id; - $actioncomm->datep = $date; - $actioncomm->datef = $date; - $actioncomm->percentage = -1; // Not applicable - $actioncomm->socid = $thirdpartystatic->id; - $actioncomm->contactid = $contactstatic->id; - $actioncomm->socpeopleassigned = (!empty($contactstatic->id) ? array($contactstatic->id => '') : array()); - $actioncomm->authorid = $user->id; // User saving action - $actioncomm->userownerid = $user->id; // Owner of action - // Fields when action is an email (content should be added into note) - $actioncomm->email_msgid = $msgid; - $actioncomm->email_from = $fromstring; - $actioncomm->email_sender= $sender; - $actioncomm->email_to = $to; - $actioncomm->email_tocc = $sendtocc; - $actioncomm->email_tobcc = $sendtobcc; - $actioncomm->email_subject = $subject; - $actioncomm->errors_to = ''; + $description = $descriptiontitle; + $description = dol_concatdesc($description, "-----"); + $description = dol_concatdesc($description, $descriptionmeta); + $description = dol_concatdesc($description, "-----"); + $description = dol_concatdesc($description, $messagetext); - if (! in_array($fk_element_type, array('societe','contact','project','user'))) - { - $actioncomm->fk_element = $fk_element_id; - $actioncomm->elementtype = $fk_element_type; - } + $descriptionfull = $description; + $descriptionfull = dol_concatdesc($descriptionfull, "----- Header"); + $descriptionfull = dol_concatdesc($descriptionfull, $header); - //$actioncomm->extraparams = $extraparams; + // Insert record of emails sent + $actioncomm = new ActionComm($this->db); + $actioncomm->type_code = 'AC_OTH_AUTO'; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...) + $actioncomm->code = 'AC_'.$actioncode; + $actioncomm->label = $langs->trans("ActionAC_".$actioncode).' - '.$langs->trans("MailFrom").' '.$from; + $actioncomm->note_private= $descriptionfull; + $actioncomm->fk_project = $projectstatic->id; + $actioncomm->datep = $date; + $actioncomm->datef = $date; + $actioncomm->percentage = -1; // Not applicable + $actioncomm->socid = $thirdpartystatic->id; + $actioncomm->contactid = $contactstatic->id; + $actioncomm->socpeopleassigned = (!empty($contactstatic->id) ? array($contactstatic->id => '') : array()); + $actioncomm->authorid = $user->id; // User saving action + $actioncomm->userownerid = $user->id; // Owner of action + // Fields when action is an email (content should be added into note) + $actioncomm->email_msgid = $msgid; + $actioncomm->email_from = $fromstring; + $actioncomm->email_sender= $sender; + $actioncomm->email_to = $to; + $actioncomm->email_tocc = $sendtocc; + $actioncomm->email_tobcc = $sendtobcc; + $actioncomm->email_subject = $subject; + $actioncomm->errors_to = ''; - // Overwrite values with values extracted from source email - $errorforthisaction = $this->overwritePropertiesOfObject($actioncomm, $operation['actionparam'], $messagetext, $subject, $header); + if (! in_array($fk_element_type, array('societe','contact','project','user'))) + { + $actioncomm->fk_element = $fk_element_id; + $actioncomm->elementtype = $fk_element_type; + } - if ($errorforthisaction) - { - $errorforactions++; - } - else - { - $result = $actioncomm->create($user); - if ($result <= 0) - { - $errorforactions++; - $this->errors = $actioncomm->errors; - } - } + //$actioncomm->extraparams = $extraparams; + + // Overwrite values with values extracted from source email + $errorforthisaction = $this->overwritePropertiesOfObject($actioncomm, $operation['actionparam'], $messagetext, $subject, $header); + + if ($errorforthisaction) + { + $errorforactions++; + } + else + { + $result = $actioncomm->create($user); + if ($result <= 0) + { + $errorforactions++; + $this->errors = $actioncomm->errors; + } + } + } } // Create event elseif ($operation['type'] == 'project') diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 3f7abd4b4e5..ca543f5f2d5 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -2459,10 +2459,10 @@ elseif ($id || $ref) if (!empty($conf->productbatch->enabled)) $colspan++; if (!empty($conf->stock->enabled)) $colspan++; - $lines[$i]->fetch_optionals($lines[$i]->id); + $line = $lines[$i]; + $line->fetch_optionals($line->id); - print ''; - if ($action == 'editline' && $lines[$i]->id == $line_id) + if ($action == 'editline' && $line->id == $line_id) { print $lines[$i]->showOptionals($extrafields, 'edit', array('colspan'=>$colspan), $indiceAsked); } @@ -2470,7 +2470,6 @@ elseif ($id || $ref) { print $lines[$i]->showOptionals($extrafields, 'view', array('colspan'=>$colspan), $indiceAsked); } - print ''; } } } 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/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 6a5e29892d2..a4a7964ca5a 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2674,11 +2674,14 @@ else else $calculationrule = (empty($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND) ? 'totalofround' : 'roundoftotal'); if ($calculationrule == 'totalofround') $calculationrulenum = 1; else $calculationrulenum = 2; - $s = $langs->trans("ReCalculate").' '; - $s .= ''.$langs->trans("Mode1").''; - $s .= ' / '; - $s .= ''.$langs->trans("Mode2").''; - print $form->textwithtooltip($s, $langs->trans("CalculationRuleDesc", $calculationrulenum).'
'.$langs->trans("CalculationRuleDescSupplier"), 2, 1, img_picto('', 'help')); + // Show link for "recalculate" + if ($object->getVentilExportCompta() == 0) { + $s = $langs->trans("ReCalculate").' '; + $s .= ''.$langs->trans("Mode1").''; + $s .= ' / '; + $s .= ''.$langs->trans("Mode2").''; + print $form->textwithtooltip($s, $langs->trans("CalculationRuleDesc", $calculationrulenum).'
'.$langs->trans("CalculationRuleDescSupplier"), 2, 1, img_picto('', 'help')); + } print '
'; // Amount Local Taxes diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index c44c588b335..e1ba230fe38 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -304,12 +304,31 @@ class Holiday extends CommonObject { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."holiday"); - if (!$notrigger) + if ($this->id) { - // Call trigger - $result = $this->call_trigger('HOLIDAY_CREATE', $user); - if ($result < 0) { $error++; } - // End call triggers + // update ref + $initialref = '(PROV'.$this->id.')'; + if (!empty($this->ref)) $initialref = $this->ref; + + $sql = 'UPDATE '.MAIN_DB_PREFIX."holiday SET ref='".$this->db->escape($initialref)."' WHERE rowid=".$this->id; + if ($this->db->query($sql)) + { + $this->ref = $initialref; + + if (!$error) + { + $result = $this->insertExtraFields(); + if ($result < 0) $error++; + } + + if (!$error && !$notrigger) + { + // Call trigger + $result = $this->call_trigger('HOLIDAY_CREATE', $user); + if ($result < 0) { $error++; } + // End call triggers + } + } } } @@ -337,7 +356,7 @@ class Holiday extends CommonObject * * @param int $id Id object * @param string $ref Ref object - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, 0 if not found, >0 if OK */ public function fetch($id, $ref = '') { @@ -402,12 +421,17 @@ class Holiday extends CommonObject $this->fk_user_create = $obj->fk_user_create; $this->fk_type = $obj->fk_type; $this->entity = $obj->entity; + + $this->fetch_optionals(); + + $result = 1; + } + else { + $result = 0; } $this->db->free($resql); - $this->fetch_optionals(); - - return 1; + return $result; } else { diff --git a/htdocs/includes/jquery/plugins/multiselect/jquery.multi-select.js b/htdocs/includes/jquery/plugins/multiselect/jquery.multi-select.js deleted file mode 100644 index ee62d1f588d..00000000000 --- a/htdocs/includes/jquery/plugins/multiselect/jquery.multi-select.js +++ /dev/null @@ -1,360 +0,0 @@ -// jquery.multi-select.js -// by mySociety -// https://github.com/mysociety/jquery-multi-select - -;(function($) { - - "use strict"; - - var pluginName = "multiSelect", - defaults = { - 'containerHTML': '
', - 'menuHTML': '
', - 'buttonHTML': '', - 'menuItemsHTML': '
', - 'menuItemHTML': '