diff --git a/ChangeLog b/ChangeLog index c64735981e1..63e3cc58bd1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,21 +22,51 @@ Following changes may create regressions for some external modules, but were nec FIX: #10381 FIX: #10460 compatibility with MariaDB 10.4 FIX: #10485 +FIX: #10638 +FIX: Accountancy - Adding transaction with multicompany uses all the time 1st entity +FIX: actioncomm export: ORDER BY clause is in wrong export property + event type filter does not work FIX: add fk_unit on addline action +FIX: adding css by page if url is externam +FIX: Bad link in menu manager FIX: better test on fetch +FIX: can't add lines on invoices +FIX: Check for old picture name if the new one was not found +FIX: could not create several superadmin in transversal mode +FIX: creation of menu entry with parent id not int +FIX: creation of new left menu entry FIX: Default language of company is not set +FIX: error on setup of password if pass generators have a .old file. FIX: error report not returned FIX: expedition: reset status on rollback + replace hardcoded status with const +FIX: fetch module / pos source +FIX: fk_default_warehouse missing in group by +FIX: function sendEmailsReminder isn't completely developed, then MAIN_FEATURES_LEVEL must be 2 to "use" it +FIX: if empty error message, we just see "error" displayed +FIX: label of bank account FIX: line edit template: keep fk_parent_line +FIX: Mark credit note as available for credit note in other currency +FIX: missing access security checking with multicompany +FIX: missing entity filter in function "build_filterField()" (export module) +FIX: missing $ismultientitymanaged for previous/next ref FIX: Missing province in export of invoice FIX: must fetch member in current entity +FIX: positive values creating diff on addline rounding +FIX: positive values IN supplier credit notes creating diff on addline rounding FIX: Price in combo list of service does not use the correct price level -FIX: supplier invoice payment total doesnt care about deposit or credit +FIX: project_title for display of getNomUrl() +FIX: same thing here +FIX: Show button POS Ticket only if invoice was generated by POS +FIX: supplier invoice payment total doesn't care about deposit or credit FIX: supplier invoice product stats total ht is line total not invoice total +FIX: The notes was also copied on invoice +FIX: Transaction on leave approval and decrease ko if setup not complete FIX: Translation not loaded by scheduled jobs +FIX: [URGENT] broken feature, "$usercancreate" is for Dolibarr 9 +FIX: we want to be able to reopen fourn credit note +FIX: wrong feature2 when user rights "group_advance" is used FIX: wrong merged conflict FIX: wrong tests on fetch -NEW: Add protection to avoid packaging if files non indexed exists into +NEW: Add protection to avoid packaging if files non indexed exists ***** ChangeLog for 9.0.0 compared to 8.0.0 ***** For Users: diff --git a/README.md b/README.md index 9dfd1a8a750..ad1702fffe4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # DOLIBARR ERP & CRM -![Downloads per day](https://img.shields.io/sourceforge/dm/dolibarr.svg) +![Downloads per day](https://img.shields.io/sourceforge/dw/dolibarr.svg) [![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com) |6|7|8|9|develop| diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index b6f62aede64..d8fff2265e9 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -428,4 +428,5 @@ + diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 77f3c7200f4..d4b77342c84 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -572,6 +572,22 @@ class Adherent extends CommonObject $sql.= ", fk_user_mod = ".($user->id>0?$user->id:'null'); // Can be null because member can be create by a guest $sql.= " WHERE rowid = ".$this->id; + // If we change the type of membership, we set also label of new type + if (! empty($this->oldcopy) && $this->typeid != $this->oldcopy->typeid) + { + $sql2 = "SELECT libelle as label"; + $sql2.= " FROM ".MAIN_DB_PREFIX."adherent_type"; + $sql2.= " WHERE rowid = ".$this->typeid; + $resql2 = $this->db->query($sql2); + if ($resql2) + { + while ($obj=$this->db->fetch_object($resql2)) + { + $this->type=$obj->label; + } + } + } + dol_syslog(get_class($this)."::update update member", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 6025f2a2985..6948bce1e25 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -288,15 +288,16 @@ class Members extends DolibarrApi return $member; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); // Remove the subscriptions because they are handled as a subresource. diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index 43fd2635fb4..abfaf84993d 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -266,15 +266,16 @@ class MembersTypes extends DolibarrApi return $membertype; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->array_options); diff --git a/htdocs/adherents/stats/byproperties.php b/htdocs/adherents/stats/byproperties.php index 164606431ff..6ba88e7771b 100644 --- a/htdocs/adherents/stats/byproperties.php +++ b/htdocs/adherents/stats/byproperties.php @@ -58,15 +58,16 @@ llxHeader('', $langs->trans("MembersStatisticsByProperties"), '', '', 0, 0, arra $title=$langs->trans("MembersStatisticsByProperties"); -print load_fiche_titre($title, $mesg); +print load_fiche_titre($title, ''); dol_mkdir($dir); $tab='byproperties'; $data = array(); -$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, d.morphy as code"; +$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, d.morphy as code"; $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; +$sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY d.morphy"; @@ -87,7 +88,7 @@ if ($resql) if ($obj->code == 'phy') $foundphy++; if ($obj->code == 'mor') $foundmor++; - $data[]=array('label'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate)); + $data[]=array('label'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate), 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate)); $i++; } @@ -120,22 +121,21 @@ print ''; print ''; print ''; print ''; +print ''; print ''; print ''; -if (! $foundphy) $data[]=array('label'=>'phy','nb'=>'0','lastdate'=>''); -if (! $foundmor) $data[]=array('label'=>'mor','nb'=>'0','lastdate'=>''); +if (! $foundphy) $data[]=array('label'=>'phy','nb'=>'0','lastdate'=>'', 'lastsubscriptiondate'=>''); +if (! $foundmor) $data[]=array('label'=>'mor','nb'=>'0','lastdate'=>'', 'lastsubscriptiondate'=>''); -$oldyear=0; foreach ($data as $val) { - $year = $val['year']; print ''; print ''; print ''; print ''; + print ''; print ''; - $oldyear=$year; } print '
'.$langs->trans("Nature").''.$langs->trans("NbOfMembers").''.$langs->trans("LastMemberDate").''.$langs->trans("LatestSubscriptionDate").'
'.$memberstatic->getmorphylib($val['label']).''.$val['nb'].''.dol_print_date($val['lastdate'], 'dayhour').''.dol_print_date($val['lastsubscriptiondate'], 'dayhour').'
'; diff --git a/htdocs/adherents/stats/geo.php b/htdocs/adherents/stats/geo.php index f5816f46aca..79aa5ab6a82 100644 --- a/htdocs/adherents/stats/geo.php +++ b/htdocs/adherents/stats/geo.php @@ -77,8 +77,10 @@ if ($mode) $tab='statscountry'; $data = array(); - $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.label"; - $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; + $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label"; + $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; + $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY c.label, c.code"; @@ -92,10 +94,12 @@ if ($mode) $tab='statsstate'; $data = array(); - $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, co.code, co.label, c.nom as label2"; // - $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; + $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, c.nom as label2"; // + $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; + $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY co.label, co.code, c.nom"; @@ -108,10 +112,12 @@ if ($mode) $tab='statsregion'; //onglet $data = array(); //tableau de donnée - $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, co.code, co.label, r.nom as label2"; - $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; + $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, co.code, co.label, r.nom as label2"; + $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; + $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_departements as c on d.state_id = c.rowid"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_regions as r on c.fk_region = r.code_region"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as co on d.country = co.rowid"; + $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY co.label, co.code, r.nom"; //+ @@ -124,9 +130,10 @@ if ($mode) $tab='statstown'; $data = array(); - $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, c.code, c.label, d.town as label2"; + $sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, MAX(s.dateadh) as lastsubscriptiondate, c.code, c.label, d.town as label2"; $sql.=" FROM ".MAIN_DB_PREFIX."adherent as d"; $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."c_country as c on d.country = c.rowid"; + $sql.=" LEFT JOIN ".MAIN_DB_PREFIX."subscription as s ON s.fk_adherent = d.rowid"; $sql.=" WHERE d.entity IN (".getEntity('adherent').")"; $sql.=" AND d.statut = 1"; $sql.=" GROUP BY c.label, c.code, d.town"; @@ -154,7 +161,8 @@ if ($mode) 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), 'code'=>$obj->code, 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate) + 'lastdate'=>$db->jdate($obj->lastdate), + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) ); } if ($mode == 'memberbyregion') //+ @@ -164,7 +172,8 @@ if ($mode) 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), 'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")), 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate) + 'lastdate'=>$db->jdate($obj->lastdate), + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) ); } if ($mode == 'memberbystate') @@ -173,7 +182,8 @@ if ($mode) 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), 'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")), 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate) + 'lastdate'=>$db->jdate($obj->lastdate), + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) ); } if ($mode == 'memberbytown') @@ -182,7 +192,8 @@ if ($mode) 'label_en'=>(($obj->code && $langsen->transnoentitiesnoconv("Country".$obj->code)!="Country".$obj->code)?$langsen->transnoentitiesnoconv("Country".$obj->code):($obj->label?$obj->label:$langs->trans("Unknown"))), 'label2'=>($obj->label2?$obj->label2:$langs->trans("Unknown")), 'nb'=>$obj->nb, - 'lastdate'=>$db->jdate($obj->lastdate) + 'lastdate'=>$db->jdate($obj->lastdate), + 'lastsubscriptiondate'=>$db->jdate($obj->lastsubscriptiondate) ); } @@ -289,9 +300,9 @@ if ($mode) if ($label2) print ''.$label2.''; print ''.$langs->trans("NbOfMembers").''; print ''.$langs->trans("LastMemberDate").''; + print ''.$langs->trans("LatestSubscriptionDate").''; print ''; - $oldyear=0; foreach ($data as $val) { $year = $val['year']; @@ -300,8 +311,8 @@ if ($mode) if ($label2) print ''.$val['label2'].''; print ''.$val['nb'].''; print ''.dol_print_date($val['lastdate'], 'dayhour').''; + print ''.dol_print_date($val['lastsubscriptiondate'], 'dayhour').''; print ''; - $oldyear=$year; } print ''; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 11134f70194..541262b2bf5 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -1912,7 +1912,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '') print ''; } elseif ($fieldlist[$field] == 'code' && isset($obj->{$fieldlist[$field]})) { - print ''; + print ''; } elseif ($fieldlist[$field]=='unit') { print ''; diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 9d4d5f88bb9..df2d2b09ee6 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -212,7 +212,7 @@ if (is_resource($handle)) { while (($file = readdir($handle))!==false) { - if (preg_match('/(modGeneratePass[a-z]+)\.class\.php/i', $file, $reg)) + if (preg_match('/(modGeneratePass[a-z]+)\.class\.php$/i', $file, $reg)) { // Charging the numbering class $classname = $reg[1]; @@ -398,7 +398,6 @@ print ''.$langs->trans("Action").''; print ''; // Disable clear password in database - print ''; print ''.$langs->trans("DoNotStoreClearPassword").''; print ''; @@ -413,6 +412,8 @@ if (! $conf->global->DATABASE_PWD_ENCRYPTED) print ''.$langs->trans("Activate").''; print ""; } + +// Database conf file encryption if (! empty($conf->global->DATABASE_PWD_ENCRYPTED)) { print ''; @@ -494,9 +495,21 @@ print ''; print ''; print ''; +print '
'; - -//print ''; +if (GETPOST('info', 'int') > 0) +{ + if (function_exists('password_hash')) + { + print $langs->trans("Note: The function password_hash exists on your PHP")."
\n"; + } + else + { + print $langs->trans("Note: The function password_hash does not exists on your PHP")."
\n"; + } + print 'MAIN_SECURITY_HASH_ALGO = '.$conf->global->MAIN_SECURITY_HASH_ALGO."
\n"; + print 'MAIN_SECURITY_SALT = '.$conf->global->MAIN_SECURITY_SALT."
\n"; +} print ''; diff --git a/htdocs/admin/system/filecheck.php b/htdocs/admin/system/filecheck.php index a110e19b172..94d8909e063 100644 --- a/htdocs/admin/system/filecheck.php +++ b/htdocs/admin/system/filecheck.php @@ -339,8 +339,8 @@ if (! $error && $xml) $out.=''.$i.'' . "\n"; $out.=''.$file['filename']; if (! preg_match('/^win/i', PHP_OS)) { - $htmltext=$langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.'/'.$file['filename']); - $out.=' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'); + $htmltext=$langs->trans("YouCanDeleteFileOnServerWith", 'rm '.DOL_DOCUMENT_ROOT.$file['filename']); // The slash is included int file['filename'] + $out.=' '.$form->textwithpicto('', $htmltext, 1, 'help', '', 0, 2, 'helprm'.$i); } $out.='' . "\n"; $out.=''.$file['expectedmd5'].'' . "\n"; diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index f94117ef747..052e11f1ced 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -19,7 +19,7 @@ /** * \file admin/ticket.php * \ingroup ticket - * \brief This file is a module setup page + * \brief Page to setup module ticket */ require '../main.inc.php'; @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; require_once DOL_DOCUMENT_ROOT."/core/lib/ticket.lib.php"; // Load translation files required by the page -$langs->load("ticket"); +$langs->loadLangs(array("admin", "ticket")); // Access control if (!$user->admin) { @@ -91,16 +91,6 @@ if ($action == 'updateMask') { $error++; } - $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'alpha'); - if (!empty($mail_new_ticket)) { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $langs->trans('TicketMessageMailNewText'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } - $mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'alpha'); if (!empty($mail_intro)) { $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity); @@ -121,36 +111,6 @@ if ($action == 'updateMask') { $error++; } - $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha'); - if (!empty($mail_signature)) { - $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } - - $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'alpha'); - if (!empty($mail_signature)) { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } - - $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'alpha'); - if (!empty($mail_signature)) { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } - $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'alpha'); if (!empty($text_help)) { $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity); @@ -163,26 +123,14 @@ if ($action == 'updateMask') { } if ($action == 'setvarother') { - $param_enable_public_interface = GETPOST('TICKET_ENABLE_PUBLIC_INTERFACE', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', $param_enable_public_interface, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } - $param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha'); $res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity); if (!$res > 0) { $error++; } - $param_disable_email = GETPOST('TICKET_DISABLE_ALL_MAILS', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_DISABLE_ALL_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } - - $param_activate_log_by_email = GETPOST('TICKET_ACTIVATE_LOG_BY_EMAIL', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_ACTIVATE_LOG_BY_EMAIL', $param_activate_log_by_email, 'chaine', 0, '', $conf->entity); + $param_disable_email = GETPOST('TICKET_DISABLE_NOTIFICATION_MAILS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_DISABLE_NOTIFICATION_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); if (!$res > 0) { $error++; } @@ -242,9 +190,7 @@ $head = ticketAdminPrepareHead(); dol_fiche_head($head, 'settings', $langs->trans("Module56000Name"), -1, "ticket"); -print $langs->trans("TicketSetupDictionaries") . ' : ' . dol_buildpath('/admin/dict.php', 2) . '
'; - -print $langs->trans("TicketPublicAccess") . ' : ' . dol_buildpath('/public/ticket/index.php', 2) . ''; +print ''.$langs->trans("TicketSetupDictionaries") . ' : ' . dol_buildpath('/admin/dict.php', 2) . '
'; dol_fiche_end(); @@ -353,80 +299,19 @@ if (!$conf->use_javascript_ajax) { print ''; print ''; } -print load_fiche_titre($langs->trans("TicketParamPublicInterface")); - -print ''; - -// Activate public interface -print ''; -print ''; -print ''; -print ''; - -// Check if email exists -print ''; -print ''; -print ''; -print ''; - -/*if ($conf->global->MAIN_FEATURES_LEVEL >= 2) -{ - // Show logo for module - print ''; - print ''; - print ''; - print ''; -}*/ - -// Show logo for company -print ''; -print ''; -print ''; -print ''; - -print '
' . $langs->trans("TicketsActivatePublicInterface") . ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_ENABLE_PUBLIC_INTERFACE'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_ENABLE_PUBLIC_INTERFACE", $arrval, $conf->global->TICKET_ENABLE_PUBLIC_INTERFACE); -} -print ''; -print $form->textwithpicto('', $langs->trans("TicketsActivatePublicInterfaceHelp"), 1, 'help'); -print '
' . $langs->trans("TicketsEmailMustExist") . ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_EMAIL_MUST_EXISTS", $arrval, $conf->global->TICKET_EMAIL_MUST_EXISTS); -} -print ''; -print $form->textwithpicto('', $langs->trans("TicketsEmailMustExistHelp"), 1, 'help'); -print '
' . $langs->trans("TicketsShowModuleLogo") . ''; - if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_SHOW_MODULE_LOGO'); - } else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_SHOW_MODULE_LOGO", $arrval, $conf->global->TICKET_SHOW_MODULE_LOGO); - } - print ''; - print $form->textwithpicto('', $langs->trans("TicketsShowModuleLogoHelp"), 1, 'help'); - print '
' . $langs->trans("TicketsShowCompanyLogo") . ''; -if ($conf->use_javascript_ajax) { - print ajax_constantonoff('TICKET_SHOW_COMPANY_LOGO'); -} else { - $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("TICKET_SHOW_COMPANY_LOGO", $arrval, $conf->global->TICKET_SHOW_COMPANY_LOGO); -} -print ''; -print $form->textwithpicto('', $langs->trans("TicketsShowCompanyLogoHelp"), 1, 'help'); -print '

'; print load_fiche_titre($langs->trans("TicketParams")); print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + // Activate email notifications -print ''; +/* +print ''; print ''; print ''; // Activate log by email -print ''; +print ''; print ''; print ''; +*/ // Also send to main email address if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { - print ''; + print ''; print ''; +/* +print ''; print ''; print ''; +*/ -if (!$conf->use_javascript_ajax) { +/*if (!$conf->use_javascript_ajax) { print ''; print ''; -} +}*/ // Auto assign ticket at user who created it -print ''; +print ''; print ''; -print ''; -print ''; +print '
'; +print ''; +print '
'; -// Interface topic -$url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC; -print ''; -print ''; -print ''; - -// Texte d'accueil homepage -$public_text_home = $conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome'); -print ''; -print ''; - -// Texte d'aide à la saisie du message -$public_text_help_message = $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'); -print ''; -print ''; - -print ''; -print ''; - -print '
' . $langs->trans("Parameter") . '
' . $langs->trans("TicketsDisableEmail") . '
' . $langs->trans("TicketsDisableEmail") . ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_DISABLE_ALL_MAILS'); @@ -441,7 +326,7 @@ print '
' . $langs->trans("TicketsLogEnableEmail") . '
' . $langs->trans("TicketsLogEnableEmail") . ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_ACTIVATE_LOG_BY_EMAIL'); @@ -454,11 +339,12 @@ print ''; print $form->textwithpicto('', $langs->trans("TicketsLogEnableEmailHelp"), 1, 'help'); print '
' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . '
' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'); @@ -474,7 +360,8 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) } // Limiter la vue des tickets à ceux assignés à l'utilisateur -print '
' . $langs->trans("TicketsLimitViewAssignedOnly") . '
' . $langs->trans("TicketsLimitViewAssignedOnly") . ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_LIMIT_VIEW_ASSIGNED_ONLY'); @@ -487,14 +374,15 @@ print ''; print $form->textwithpicto('', $langs->trans("TicketsLimitViewAssignedOnlyHelp"), 1, 'help'); print '
' . $langs->trans("TicketsAutoAssignTicket") . '
' . $langs->trans("TicketsAutoAssignTicket") . ''; if ($conf->use_javascript_ajax) { print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE'); @@ -515,7 +403,7 @@ if (!$conf->use_javascript_ajax) { } // Admin var of module -print load_fiche_titre($langs->trans("TicketParamMail")); +print load_fiche_titre($langs->trans("Notification")); print ''; @@ -533,17 +421,26 @@ if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { print "\n"; } -// Email d'envoi des notifications -print ''; +// Activate log by email +/*print ''; print ''; +if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_ACTIVATE_LOG_BY_EMAIL'); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_ACTIVATE_LOG_BY_EMAIL", $arrval, $conf->global->TICKET_ACTIVATE_LOG_BY_EMAIL); +} +print ''; print ''; print ''; +*/ + +// @TODO Use module notification instead... // Email de réception des notifications -print ''; +print ''; print ''; print ''; print ''; -// Texte de création d'un ticket -$mail_mesg_new = $conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->trans('TicketNewEmailBody'); -print ''; +// Email d'envoi des notifications +print ''; +print ''; print ''; +print $form->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"), 1, 'help'); +print ''; +print ''; // Texte d'introduction $mail_intro = $conf->global->TICKET_MESSAGE_MAIL_INTRO ? $conf->global->TICKET_MESSAGE_MAIL_INTRO : $langs->trans('TicketMessageMailIntroText'); -print ''; // Texte de signature $mail_signature = $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE ? $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE : $langs->trans('TicketMessageMailSignatureText'); -print ''; -print ''; -print ''; -print "\n"; +print '
' . $langs->trans("TicketEmailNotificationFrom") . '
' . $langs->trans("TicketsLogEnableEmail") . ''; -print ''; -print $form->textwithpicto('', $langs->trans("TicketEmailNotificationFromHelp"), 1, 'help'); +print $form->textwithpicto('', $langs->trans("TicketsLogEnableEmailHelp"), 1, 'help'); print '
' . $langs->trans("TicketEmailNotificationTo") . '
' . $langs->trans("TicketEmailNotificationTo") . ''; print ''; @@ -551,21 +448,18 @@ print $form->textwithpicto('', $langs->trans("TicketEmailNotificationToHelp"), 1 print '
' . $langs->trans("TicketNewEmailBodyLabel") . ''; -print ''; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; -$doleditor = new DolEditor('TICKET_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); -$doleditor->Create(); -print '
' . $langs->trans("TicketEmailNotificationFrom") . ''; +print ''; -print $form->textwithpicto('', $langs->trans("TicketNewEmailBodyHelp"), 1, 'help'); -print '
' . $langs->trans("TicketMessageMailIntroLabelAdmin") . ''; +print '
' . $langs->trans("TicketMessageMailIntroLabelAdmin") . ''; print ''; require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_INTRO', $mail_intro, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); @@ -577,7 +471,7 @@ print '
' . $langs->trans("TicketMessageMailSignatureLabelAdmin") . ''; +print '
' . $langs->trans("TicketMessageMailSignatureLabelAdmin") . ''; print ''; require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); @@ -587,58 +481,12 @@ print ''; print $form->textwithpicto('', $langs->trans("TicketMessageMailSignatureHelpAdmin"), 1, 'help'); print '
' . $langs->trans("PublicInterface") . '
'; -// Url public interface -$url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; -print '
' . $langs->trans("TicketUrlPublicInterfaceLabelAdmin") . ''; -print ''; -print ''; -print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); -print '
' . $langs->trans("TicketPublicInterfaceTopicLabelAdmin") . ''; -print ''; -print ''; -print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTopicHelp"), 1, 'help'); -print '
' . $langs->trans("TicketPublicInterfaceTextHomeLabelAdmin") . ''; -print ''; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; -$doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); -$doleditor->Create(); -print ''; -print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHomeHelpAdmin"), 1, 'help'); -print '
' . $langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin") . ''; -print ''; -require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; -$doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); -$doleditor->Create(); -print ''; -print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHelpMessageHelpAdmin"), 1, 'help'); -print '

'; print ''; // End of page diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php new file mode 100644 index 00000000000..939a357999b --- /dev/null +++ b/htdocs/admin/ticket_public.php @@ -0,0 +1,453 @@ + + * Copyright (C) 2016 Christophe Battarel + * + * 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 admin/ticket_public.php + * \ingroup ticket + * \brief Page to public interface of module Ticket + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; +require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php"; +require_once DOL_DOCUMENT_ROOT."/core/lib/ticket.lib.php"; + +// Load translation files required by the page +$langs->loadLangs(array("admin", "ticket")); + +// Access control +if (!$user->admin) { + accessforbidden(); +} + +// Parameters +$value = GETPOST('value', 'alpha'); +$action = GETPOST('action', 'alpha'); +$label = GETPOST('label', 'alpha'); +$scandir = GETPOST('scandir', 'alpha'); +$type = 'ticket'; + +if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') +{ + if (GETPOST('value')) dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 1, 'chaine', 0, '', $conf->entity); + else dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 0, 'chaine', 0, '', $conf->entity); +} + +if ($action == 'setvar') { + include_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"; + + $notification_email = GETPOST('TICKET_NOTIFICATION_EMAIL_FROM', 'alpha'); + if (!empty($notification_email)) { + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', '', 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + // altairis : differentiate notification email FROM and TO + $notification_email_to = GETPOST('TICKET_NOTIFICATION_EMAIL_TO', 'alpha'); + if (!empty($notification_email_to)) { + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'alpha'); + if (!empty($mail_new_ticket)) { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $langs->trans('TicketMessageMailNewText'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'alpha'); + if (!empty($mail_intro)) { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $langs->trans('TicketMessageMailIntroText'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'alpha'); + if (!empty($mail_signature)) { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $langs->trans('TicketMessageMailSignatureText'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha'); + if (!empty($mail_signature)) { + $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'alpha'); + if (!empty($mail_signature)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'alpha'); + if (!empty($mail_signature)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'alpha'); + if (!empty($text_help)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } +} + +if ($action == 'setvarother') { + $param_enable_public_interface = GETPOST('TICKET_ENABLE_PUBLIC_INTERFACE', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', $param_enable_public_interface, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + + $param_must_exists = GETPOST('TICKET_EMAIL_MUST_EXISTS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_EMAIL_MUST_EXISTS', $param_must_exists, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + + $param_disable_email = GETPOST('TICKET_DISABLE_CUSTOMER_MAILS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_DISABLE_CUSTOMER_MAILS', $param_disable_email, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + $param_show_module_logo = GETPOST('TICKET_SHOW_MODULE_LOGO', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_SHOW_MODULE_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + } + + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + $param_notification_also_main_addressemail = GETPOST('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS', $param_notification_also_main_addressemail, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + } + + $param_limit_view = GETPOST('TICKET_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_LIMIT_VIEW_ASSIGNED_ONLY', $param_limit_view, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } + + $param_auto_assign = GETPOST('TICKET_AUTO_ASSIGN_USER_CREATE', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_AUTO_ASSIGN_USER_CREATE', $param_auto_assign, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } +} + + + +/* + * View + */ + +$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); + +$form = new Form($db); + +$help_url = "FR:Module_Ticket"; +$page_name = "TicketSetup"; +llxHeader('', $langs->trans($page_name), $help_url); + +// Subheader +$linkback = '' . $langs->trans("BackToModuleList") . ''; + +print load_fiche_titre($langs->trans($page_name), $linkback, 'title_setup'); + +// Configuration header +$head = ticketAdminPrepareHead(); + +dol_fiche_head($head, 'public', $langs->trans("Module56000Name"), -1, "ticket"); + +print ''.$langs->trans("TicketPublicAccess") . ' : ' . dol_buildpath('/public/ticket/index.php', 2) . ''; + +dol_fiche_end(); + + +$enabledisablehtml = $langs->trans("TicketsActivatePublicInterface").' '; +if (empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) +{ + // Button off, click to enable + $enabledisablehtml.=''; + $enabledisablehtml.=img_picto($langs->trans("Disabled"), 'switch_off'); + $enabledisablehtml.=''; +} +else +{ + // Button on, click to disable + $enabledisablehtml.=''; + $enabledisablehtml.=img_picto($langs->trans("Activated"), 'switch_on'); + $enabledisablehtml.=''; +} +print $enabledisablehtml; +print ''; + +print '

'; + +if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) +{ + + if (!$conf->use_javascript_ajax) { + print '
'; + print ''; + print ''; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + + // Check if email exists + print ''; + print ''; + print ''; + print ''; + + /*if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + // Show logo for module + print ''; + print ''; + print ''; + print ''; + }*/ + + // Show logo for company + print ''; + print ''; + print ''; + print ''; + + // Also send to main email address + if ($conf->global->MAIN_FEATURES_LEVEL >= 2) + { + print ''; + print ''; + print ''; + print ''; + } + + if (!$conf->use_javascript_ajax) { + print ''; + print ''; + } + + // Auto assign ticket at user who created it + print ''; + print ''; + print ''; + print ''; + + print '
' . $langs->trans("Parameters") . ''; + print ''; + print '
' . $langs->trans("TicketsEmailMustExist") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_EMAIL_MUST_EXISTS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_EMAIL_MUST_EXISTS", $arrval, $conf->global->TICKET_EMAIL_MUST_EXISTS); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsEmailMustExistHelp"), 1, 'help'); + print '
' . $langs->trans("TicketsShowModuleLogo") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_SHOW_MODULE_LOGO'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_SHOW_MODULE_LOGO", $arrval, $conf->global->TICKET_SHOW_MODULE_LOGO); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsShowModuleLogoHelp"), 1, 'help'); + print '
' . $langs->trans("TicketsShowCompanyLogo") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_SHOW_COMPANY_LOGO'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_SHOW_COMPANY_LOGO", $arrval, $conf->global->TICKET_SHOW_COMPANY_LOGO); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsShowCompanyLogoHelp"), 1, 'help'); + print '
' . $langs->trans("TicketsEmailAlsoSendToMainAddress") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS", $arrval, $conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsEmailAlsoSendToMainAddressHelp"), 1, 'help'); + print '
' . $langs->trans("TicketsAutoAssignTicket") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_AUTO_ASSIGN_USER_CREATE'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_AUTO_ASSIGN_USER_CREATE", $arrval, $conf->global->TICKET_AUTO_ASSIGN_USER_CREATE); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsAutoAssignTicketHelp"), 1, 'help'); + print '

'; + + if (!$conf->use_javascript_ajax) { + print '
'; + } + + // Admin var of module + print load_fiche_titre($langs->trans("TicketParamMail")); + + print ''; + + print ''; + print ''; + print ''; + + print ''; + print ''; + print "\n"; + + if (empty($conf->global->FCKEDITOR_ENABLE_MAIL)) { + print ''; + print ''; + print "\n"; + } + + // Url public interface + $url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; + print ''; + print ''; + print ''; + + // Interface topic + $url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC; + print ''; + print ''; + print ''; + + // Texte d'accueil homepage + $public_text_home = $conf->global->TICKET_PUBLIC_TEXT_HOME ? $conf->global->TICKET_PUBLIC_TEXT_HOME : $langs->trans('TicketPublicInterfaceTextHome'); + print ''; + print ''; + + // Texte d'aide à la saisie du message + $public_text_help_message = $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE ? $conf->global->TICKET_PUBLIC_TEXT_HELP_MESSAGE : $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'); + print ''; + print ''; + + // Activate email creation to user + print ''; + print ''; + print ''; + print ''; + + // Texte de création d'un ticket + $mail_mesg_new = $conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->trans('TicketNewEmailBody'); + print ''; + print ''; + + print '
' . $langs->trans("Parameter") . '
' . $langs->trans("TicketCkEditorEmailNotActivated") . '
' . $langs->trans("TicketUrlPublicInterfaceLabelAdmin") . ''; + print ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); + print '
' . $langs->trans("TicketPublicInterfaceTopicLabelAdmin") . ''; + print ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTopicHelp"), 1, 'help'); + print '
' . $langs->trans("TicketPublicInterfaceTextHomeLabelAdmin") . ''; + print ''; + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HOME', $public_text_home, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); + $doleditor->Create(); + print ''; + print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHomeHelpAdmin"), 1, 'help'); + print '
' . $langs->trans("TicketPublicInterfaceTextHelpMessageLabelAdmin") . ''; + print ''; + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $doleditor = new DolEditor('TICKET_PUBLIC_TEXT_HELP_MESSAGE', $public_text_help_message, '100%', 180, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_2, 70); + $doleditor->Create(); + print ''; + print $form->textwithpicto('', $langs->trans("TicketPublicInterfaceTextHelpMessageHelpAdmin"), 1, 'help'); + print '
' . $langs->trans("TicketsDisableCustomerEmail") . ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('TICKET_DISABLE_CUSTOMER_MAILS'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("TICKET_DISABLE_CUSTOMER_MAILS", $arrval, $conf->global->TICKET_DISABLE_CUSTOMER_MAILS); + } + print ''; + print $form->textwithpicto('', $langs->trans("TicketsDisableEmailHelp"), 1, 'help'); + print '
' . $langs->trans("TicketNewEmailBodyLabel") . ''; + print ''; + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $doleditor = new DolEditor('TICKET_MESSAGE_MAIL_NEW', $mail_mesg_new, '100%', 120, 'dolibarr_mailings', '', false, true, $conf->global->FCKEDITOR_ENABLE_MAIL, ROWS_2, 70); + $doleditor->Create(); + print ''; + print $form->textwithpicto('', $langs->trans("TicketNewEmailBodyHelp"), 1, 'help'); + print '
'; + + print '
'; + + print ''; +} + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 19bd61c641b..f4a7084b336 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -274,7 +274,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id; } - else if ($modulepart == 'adherent' || $modulepart == 'member') + elseif ($modulepart == 'adherent' || $modulepart == 'member') { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; @@ -290,7 +290,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->adherent->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'member'); } - else if ($modulepart == 'propal' || $modulepart == 'proposal') + elseif ($modulepart == 'propal' || $modulepart == 'proposal') { require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; @@ -306,7 +306,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->propal->multidir_output[$object->entity] . "/" . get_exdir(0, 0, 0, 1, $object, 'propal'); } - else if ($modulepart == 'commande' || $modulepart == 'order') + elseif ($modulepart == 'commande' || $modulepart == 'order') { require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; @@ -322,7 +322,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->commande->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'commande'); } - else if ($modulepart == 'shipment' || $modulepart == 'expedition') + elseif ($modulepart == 'shipment' || $modulepart == 'expedition') { require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; @@ -338,7 +338,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->expedition->dir_output . "/sending/" . get_exdir(0, 0, 0, 1, $object, 'shipment'); } - else if ($modulepart == 'facture' || $modulepart == 'invoice') + elseif ($modulepart == 'facture' || $modulepart == 'invoice') { require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; @@ -354,7 +354,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->facture->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'invoice'); } - else if ($modulepart == 'produit' || $modulepart == 'product') + elseif ($modulepart == 'produit' || $modulepart == 'product') { require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -370,7 +370,7 @@ class Documents extends DolibarrApi $upload_dir = $conf->product->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'product'); } - else if ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event') + elseif ($modulepart == 'agenda' || $modulepart == 'action' || $modulepart == 'event') { require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; @@ -600,7 +600,8 @@ class Documents extends DolibarrApi * @return array * @throws RestException */ - private function _validate_file($data) { + private function _validate_file($data) + { // phpcs:enable $result = array(); foreach (Documents::$DOCUMENT_FIELDS as $field) { diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 766cf79f7be..783ec6540e3 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -273,14 +273,16 @@ class Setup extends DolibarrApi return $list; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->error); diff --git a/htdocs/bom/admin/setup.php b/htdocs/bom/admin/setup.php index 561b44fa262..a484718ac32 100644 --- a/htdocs/bom/admin/setup.php +++ b/htdocs/bom/admin/setup.php @@ -1,6 +1,7 @@ - * Copyright (C) 2019 Maxime Kohlhaas +/* Copyright (C) 2004-2017 Laurent Destailleur + * Copyright (C) 2019 Maxime Kohlhaas + * Copyright (C) 2019 Frédéric France * * 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 @@ -23,21 +24,7 @@ */ // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); - -global $langs, $user; - +require '../../main.inc.php'; // Libraries require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php"; require_once '../lib/bom.lib.php'; @@ -62,11 +49,7 @@ $arrayofparameters=array( /* * Actions */ -if ((float) DOL_VERSION >= 6) -{ - include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -} - +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; /* * View diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 0054e427996..19d7fdaa60b 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- +/* Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2019 Frédéric France * * 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 @@ -17,50 +17,17 @@ */ /** - * \file bom_card.php + * \file htdocs/bom/bom_card.php * \ingroup bom * \brief Page to create/edit/view bom */ -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session). This include the NOIPCHECK too. -//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("FORCECSP")) define('FORCECSP','none'); // Disable all Content Security Policies - - // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); - +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -dol_include_once('/bom/class/bom.class.php'); -dol_include_once('/bom/lib/bom_bom.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom_bom.lib.php'; // Load translation files required by the page $langs->loadLangs(array("mrp","other")); @@ -75,7 +42,7 @@ $contextpage= GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'bomcard $backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects -$object=new BillOfMaterials($db); +$object=new BOM($db); $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->bom->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('bomcard', 'globalcard')); // Note that conf->hooks_modules contains array @@ -119,10 +86,10 @@ if (empty($reshook)) $permissiontoadd = $user->rights->bom->write; $permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && $object->status == 0); - $backurlforlist = dol_buildpath('/bom/bom_list.php', 1); + $backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php'; if (empty($backtopage)) { if (empty($id)) $backtopage = $backurlforlist; - else $backtopage = dol_buildpath('/bom/bom_card.php', 1).($id > 0 ? $id : '__ID__'); + else $backtopage = DOL_URL_ROOT.'/bom/bom_card.php?id='.$id; } $triggermodname = 'BILLOFMATERIALS_BILLOFMATERIALS_MODIFY'; // Name of trigger action code to execute when we modify record diff --git a/htdocs/bom/bom_document.php b/htdocs/bom/bom_document.php index b13277cd82b..ff8887bb4e8 100644 --- a/htdocs/bom/bom_document.php +++ b/htdocs/bom/bom_document.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- +/* Copyright (C) 2007-2017 Laurent Destailleur + * Copyright (C) 2019 Frédéric France * * 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 @@ -23,26 +23,13 @@ */ // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); - +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -dol_include_once('/bom/class/bom.class.php'); -dol_include_once('/bom/lib/bom_bom.lib.php'); +require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom_bom.lib.php'; // Load translation files required by the page $langs->loadLangs(array("mrp","companies","other","mails")); diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index 25fad036b65..cf9ad7ffaf2 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -17,49 +17,16 @@ */ /** - * \file bom_list.php + * \file htdocs/bom/bom_list.php * \ingroup bom * \brief List page for bom */ - -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); // Do not create database handler $db -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Do not load object $user -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); // Do not load object $mysoc -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Do not load object $langs -//if (! defined('NOSCANGETFORINJECTION')) define('NOSCANGETFORINJECTION','1'); // Do not check injection attack on GET parameters -//if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1'); // Do not check injection attack on POST parameters -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check CSRF attack (test on referer + on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on). -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not roll the Anti CSRF token (used if MAIN_SECURITY_CSRF_WITH_TOKEN is on) -//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data -//if (! defined('NOIPCHECK')) define('NOIPCHECK','1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); // Do not load ajax.lib.php library -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) -//if (! defined("MAIN_LANG_DEFAULT")) define('MAIN_LANG_DEFAULT','auto'); // Force lang to a particular value -//if (! defined("MAIN_AUTHENTICATION_MODE")) define('MAIN_AUTHENTICATION_MODE','aloginmodule'); // Force authentication handler -//if (! defined("NOREDIRECTBYMAINTOLOGIN")) define('NOREDIRECTBYMAINTOLOGIN',1); // The main.inc.php does not make a redirect if not logged, instead show simple error message -//if (! defined("XFRAMEOPTIONS_ALLOWALL")) define('XFRAMEOPTIONS_ALLOWALL',1); // Do not add the HTTP header 'X-Frame-Options: SAMEORIGIN' but 'X-Frame-Options: ALLOWALL' - // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); - +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -dol_include_once('/bom/class/bom.class.php'); +require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; // Load translation files required by the page $langs->loadLangs(array("mrp", "other")); @@ -89,7 +56,7 @@ $pagenext = $page + 1; //if (! $sortorder) $sortorder="DESC"; // Initialize technical objects -$object = new BillOfMaterials($db); +$object = new BOM($db); $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->bom->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('bomlist')); // Note that conf->hooks_modules contains array @@ -179,7 +146,7 @@ if (empty($reshook)) } // Mass actions - $objectclass='BillOfMaterials'; + $objectclass='BOM'; $objectlabel='BillOfMaterials'; $permtoread = $user->rights->bom->read; $permtodelete = $user->rights->bom->delete; diff --git a/htdocs/bom/bom_note.php b/htdocs/bom/bom_note.php index fb0d58509d7..4c45512c064 100644 --- a/htdocs/bom/bom_note.php +++ b/htdocs/bom/bom_note.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- +/* Copyright (C) 2007-2017 Laurent Destailleur + * Copyright (C) 2019 Frédéric France * * 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 @@ -23,22 +23,9 @@ */ // Load Dolibarr environment -$res=0; -// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined) -if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include $_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php"; -// Try main.inc.php into web root detected using web root calculated from SCRIPT_FILENAME -$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1; -while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; } -if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include substr($tmp, 0, ($i+1))."/main.inc.php"; -if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include dirname(substr($tmp, 0, ($i+1)))."/main.inc.php"; -// Try main.inc.php using relative path -if (! $res && file_exists("../main.inc.php")) $res=@include "../main.inc.php"; -if (! $res && file_exists("../../main.inc.php")) $res=@include "../../main.inc.php"; -if (! $res && file_exists("../../../main.inc.php")) $res=@include "../../../main.inc.php"; -if (! $res) die("Include of main fails"); - -dol_include_once('/bom/class/bom.class.php'); -dol_include_once('/bom/lib/bom_bom.lib.php'); +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; +require_once DOL_DOCUMENT_ROOT.'/bom/lib/bom_bom.lib.php'; // Load translation files required by the page $langs->loadLangs(array("mrp","companies")); diff --git a/htdocs/bom/class/api_bom.class.php b/htdocs/bom/class/api_boms.class.php similarity index 83% rename from htdocs/bom/class/api_bom.class.php rename to htdocs/bom/class/api_boms.class.php index 4bb4f1a96ab..adda9ceb238 100644 --- a/htdocs/bom/class/api_bom.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -18,12 +18,11 @@ use Luracast\Restler\RestException; -dol_include_once('/bom/class/bom.class.php'); - +require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; /** - * \file bom/class/api_bom.class.php + * \file bom/class/api_boms.class.php * \ingroup bom * \brief File for API management of bom. */ @@ -31,36 +30,32 @@ dol_include_once('/bom/class/bom.class.php'); /** * API class for bom bom * - * @smart-auto-routing false * @access protected * @class DolibarrApiAccess {@requires user,external} */ -class BillOfMaterialsApi extends DolibarrApi +class BOMs extends DolibarrApi { /** * @var array $FIELDS Mandatory fields, checked when create and update object */ static $FIELDS = array( - 'name', + 'label' ); /** - * @var BillOfMaterials $bom {@type BillOfMaterials} + * @var BOM $bom {@type BOM} */ public $bom; /** * Constructor - * - * @url GET / - * */ public function __construct() { global $db, $conf; $this->db = $db; - $this->bom = new BillOfMaterials($this->db); + $this->bom = new BOM($this->db); } /** @@ -71,7 +66,7 @@ class BillOfMaterialsApi extends DolibarrApi * @param int $id ID of bom * @return array|mixed data without useless information * - * @url GET boms/{id} + * @url GET {id} * @throws RestException */ public function get($id) @@ -82,7 +77,7 @@ class BillOfMaterialsApi extends DolibarrApi $result = $this->bom->fetch($id); if( ! $result ) { - throw new RestException(404, 'BillOfMaterials not found'); + throw new RestException(404, 'BOM not found'); } if( ! DolibarrApi::_checkAccessToResource('bom', $this->bom->id)) { @@ -106,8 +101,6 @@ class BillOfMaterialsApi extends DolibarrApi * @return array Array of order objects * * @throws RestException - * - * @url GET /boms/ */ public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') { @@ -134,7 +127,7 @@ class BillOfMaterialsApi extends DolibarrApi //if ($mode == 1) $sql.= " AND s.client IN (1, 3)"; //if ($mode == 2) $sql.= " AND s.client IN (2, 3)"; - $tmpobject = new BillOfMaterials($db); + $tmpobject = new BOM($db); if ($tmpobject->ismultientitymanaged) $sql.= ' AND t.entity IN ('.getEntity('bom').')'; if ($restictonsocid && (!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; if ($restictonsocid && $socid) $sql.= " AND t.fk_soc = ".$socid; @@ -172,7 +165,7 @@ class BillOfMaterialsApi extends DolibarrApi while ($i < $num) { $obj = $db->fetch_object($result); - $bom_static = new BillOfMaterials($db); + $bom_static = new BOM($db); if($bom_static->fetch($obj->rowid)) { $obj_ret[] = $this->_cleanObjectDatas($bom_static); } @@ -193,8 +186,6 @@ class BillOfMaterialsApi extends DolibarrApi * * @param array $request_data Request datas * @return int ID of bom - * - * @url POST boms/ */ public function post($request_data = null) { @@ -208,7 +199,7 @@ class BillOfMaterialsApi extends DolibarrApi $this->bom->$field = $value; } if( ! $this->bom->create(DolibarrApiAccess::$user)) { - throw new RestException(500); + throw new RestException(500, "Error creating BOM", array_merge(array($this->bom->error), $this->bom->errors)); } return $this->bom->id; } @@ -218,9 +209,8 @@ class BillOfMaterialsApi extends DolibarrApi * * @param int $id Id of bom to update * @param array $request_data Datas - * @return int * - * @url PUT boms/{id} + * @return int */ public function put($id, $request_data = null) { @@ -230,7 +220,7 @@ class BillOfMaterialsApi extends DolibarrApi $result = $this->bom->fetch($id); if( ! $result ) { - throw new RestException(404, 'BillOfMaterials not found'); + throw new RestException(404, 'BOM not found'); } if( ! DolibarrApi::_checkAccessToResource('bom', $this->bom->id)) { @@ -238,59 +228,64 @@ class BillOfMaterialsApi extends DolibarrApi } foreach($request_data as $field => $value) { + if ($field == 'id') continue; $this->bom->$field = $value; } - if($this->bom->update($id, DolibarrApiAccess::$user)) + if($this->bom->update($id, DolibarrApiAccess::$user) > 0) + { return $this->get($id); - - return false; + } + else + { + throw new RestException(500, $this->commande->error); + } } /** * Delete bom * - * @param int $id BillOfMaterials ID + * @param int $id BOM ID * @return array - * - * @url DELETE bom/{id} */ public function delete($id) { - if(! DolibarrApiAccess::$user->rights->bom->delete) { + if (! DolibarrApiAccess::$user->rights->bom->delete) { throw new RestException(401); } $result = $this->bom->fetch($id); - if( ! $result ) { - throw new RestException(404, 'BillOfMaterials not found'); + if (! $result) { + throw new RestException(404, 'BOM not found'); } - if( ! DolibarrApi::_checkAccessToResource('bom', $this->bom->id)) { + if (! DolibarrApi::_checkAccessToResource('bom', $this->bom->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( !$this->bom->delete(DolibarrApiAccess::$user, 0)) + if (! $this->bom->delete(DolibarrApiAccess::$user)) { - throw new RestException(500); + throw new RestException(500, 'Error when deleting BOM : '.$this->bom->error); } return array( 'success' => array( 'code' => 200, - 'message' => 'BillOfMaterials deleted' + 'message' => 'BOM deleted' ) ); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * - * @param object $object Object to clean - * @return array Array of cleaned object properties + * @param object $object Object to clean + * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { + // phpcs:enable $object = parent::_cleanObjectDatas($object); /*unset($object->note); @@ -306,15 +301,15 @@ class BillOfMaterialsApi extends DolibarrApi /** * Validate fields before create or update object * - * @param array $data Data to validate - * @return array + * @param array $data Array of data to validate + * @return array * - * @throws RestException + * @throws RestException */ private function _validate($data) { $bom = array(); - foreach (BillOfMaterialsApi::$FIELDS as $field) { + foreach (BOMs::$FIELDS as $field) { if (!isset($data[$field])) throw new RestException(400, "$field field missing"); $bom[$field] = $data[$field]; diff --git a/htdocs/bom/lib/bom.lib.php b/htdocs/bom/lib/bom.lib.php index 0085d06b69c..20f9fccfb01 100644 --- a/htdocs/bom/lib/bom.lib.php +++ b/htdocs/bom/lib/bom.lib.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2019 Maxime Kohlhaas + * Copyright (C) 2019 Frédéric France * * 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 @@ -16,7 +17,7 @@ */ /** - * \file bom/lib/bom.lib.php + * \file htdocs/bom/lib/bom.lib.php * \ingroup bom * \brief Library files with common functions for BillOfMaterials */ @@ -40,7 +41,7 @@ function bomAdminPrepareHead() $head[$h][2] = 'settings'; $h++; - /*$head[$h][0] = dol_buildpath("/bom/admin/about.php", 1); + /*$head[$h][0] = DOL_URL_ROOT."/bom/admin/about.php"; $head[$h][1] = $langs->trans("About"); $head[$h][2] = 'about'; $h++; @@ -77,7 +78,7 @@ function bomPrepareHead($object) $h = 0; $head = array(); - $head[$h][0] = dol_buildpath("/bom/bom_card.php", 1).'?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT."/bom/bom_card.php?id=".$object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h++; @@ -87,7 +88,7 @@ function bomPrepareHead($object) $nbNote = 0; if (!empty($object->note_private)) $nbNote++; if (!empty($object->note_public)) $nbNote++; - $head[$h][0] = dol_buildpath('/bom/bom_note.php', 1).'?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/bom/bom_note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); if ($nbNote > 0) $head[$h][1].= ' '.$nbNote.''; $head[$h][2] = 'note'; @@ -99,13 +100,13 @@ function bomPrepareHead($object) $upload_dir = $conf->bom->dir_output . "/bom/" . dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks=Link::count($db, $object->element, $object->id); - $head[$h][0] = dol_buildpath("/bom/bom_document.php", 1).'?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/bom/bom_document.php?id='.$object->id; $head[$h][1] = $langs->trans('Documents'); if (($nbFiles+$nbLinks) > 0) $head[$h][1].= ' '.($nbFiles+$nbLinks).''; $head[$h][2] = 'document'; $h++; - $head[$h][0] = dol_buildpath("/bom/bom_agenda.php", 1).'?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT.'/bom/bom_agenda.php?id='.$object->id; $head[$h][1] = $langs->trans("Events"); $head[$h][2] = 'agenda'; $h++; diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 434b7ba1d24..c975236f930 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -261,15 +261,16 @@ class Categories extends DolibarrApi } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param Categorie $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); // Remove fields not relevent to categories diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index a85c320a992..9416ddae748 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -81,6 +81,7 @@ if ($cancel) // Action mise a jour d'une categorie if ($action == 'update' && $user->rights->categorie->creer) { + $object->oldcopy = dol_clone($object); $object->label = $label; $object->description = dol_htmlcleanlastbr($description); $object->color = $color; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index b542cf4dd67..6ad881d141c 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -160,6 +160,10 @@ if ($action == 'confirm_clone' && $confirm == 'yes') { if ($id > 0) { $object->fetch($id); + if (!empty($object->socpeopleassigned)) { + reset($object->socpeopleassigned); + $object->contactid = key($object->socpeopleassigned); + } $result = $object->createFromClone(GETPOST('fk_userowner'), GETPOST('socid')); if ($result > 0) { header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); @@ -431,6 +435,10 @@ if ($action == 'update') $object->socpeopleassigned = array(); foreach ($socpeopleassigned as $cid) $object->socpeopleassigned[$cid] = array('id' => $cid); $object->contactid = GETPOST("contactid", 'int'); + if (empty($object->contactid) && !empty($object->socpeopleassigned)) { + reset($object->socpeopleassigned); + $object->contactid = key($object->socpeopleassigned); + } $object->fk_project = GETPOST("projectid", 'int'); $object->note = GETPOST("note", "none"); // deprecated $object->note_private= GETPOST("note", "none"); @@ -682,7 +690,7 @@ if ($action == 'create') dol_fiche_head(); - print ''; + print '
'; // Type of event if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) @@ -849,7 +857,7 @@ if ($action == 'create') print '


'; - print '
'; + print '
'; if ($conf->societe->enabled) { @@ -1078,7 +1086,7 @@ if ($id > 0) dol_fiche_head($head, 'card', $langs->trans("Action"), 0, 'action'); - print '
'; + print '
'; // Ref print ''; @@ -1259,7 +1267,7 @@ if ($id > 0) print '


'; - print '
'.$langs->trans("Ref").''.$object->id.'
'; + print '
'; if ($conf->societe->enabled) { @@ -1455,7 +1463,7 @@ if ($id > 0) print '
'; // Affichage fiche action en mode visu - print '
'; + print '
'; // Type if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) @@ -1558,7 +1566,7 @@ if ($id > 0) print '
'; print '
'; - print '
'; + print '
'; if ($conf->societe->enabled) { diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index fba891a848a..56e5e68b2f7 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -270,7 +270,7 @@ class ActionComm extends CommonObject $this->userassigned[$tmpid]=array('id'=>$tmpid, 'transparency'=>$this->transparency); } - if (is_object($this->contact) && isset($this->contact->id) && $this->contact->id > 0 && ! ($this->contactid > 0)) $this->contactid = $this->contact->id; // For backward compatibility. Using this->contact->xx is deprecated + //if (is_object($this->contact) && isset($this->contact->id) && $this->contact->id > 0 && ! ($this->contactid > 0)) $this->contactid = $this->contact->id; // For backward compatibility. Using this->contact->xx is deprecated $userownerid=$this->userownerid; @@ -656,7 +656,7 @@ class ActionComm extends CommonObject $this->fk_project = $obj->fk_project; // To have fetch_project method working $this->societe->id = $obj->fk_soc; // deprecated - $this->contact->id = $obj->fk_contact; // deprecated + //$this->contact->id = $obj->fk_contact; // deprecated $this->fk_element = $obj->elementid; $this->elementid = $obj->elementid; @@ -867,7 +867,7 @@ class ActionComm extends CommonObject } $socid=($this->socid?$this->socid:((isset($this->societe->id) && $this->societe->id > 0) ? $this->societe->id : 0)); - $contactid=($this->contactid?$this->contactid:((isset($this->contact->id) && $this->contact->id > 0) ? $this->contact->id : 0)); + $contactid=($this->contactid?$this->contactid:0); $userownerid=($this->userownerid?$this->userownerid:0); $userdoneid=($this->userdoneid?$this->userdoneid:0); diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index b6df9ec7d96..ec899d72ae1 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -313,15 +313,16 @@ class AgendaEvents extends DolibarrApi return $event; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->usermod); diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 04b63966fd2..7eec20c3499 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -166,7 +166,7 @@ if ($object->id > 0) print '
'; // Affichage fiche action en mode visu - print '
'; + print '
'; // Type if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) @@ -237,7 +237,7 @@ if ($object->id > 0) print '
'; - print ''; + print '
'; // Build file list $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 33122986187..9145b8eb151 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -782,15 +782,16 @@ class Proposals extends DolibarrApi } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->note); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 304eccf9bb7..ad5197512d4 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -3526,13 +3526,13 @@ class Propal extends CommonObject if ($option == '') { $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$this->id. $get_params; } - if ($option == 'compta') { // deprecated + elseif ($option == 'compta') { // deprecated $url = DOL_URL_ROOT.'/comm/propal/card.php?id='.$this->id. $get_params; } - if ($option == 'expedition') { + elseif ($option == 'expedition') { $url = DOL_URL_ROOT.'/expedition/propal.php?id='.$this->id. $get_params; } - if ($option == 'document') { + elseif ($option == 'document') { $url = DOL_URL_ROOT.'/comm/propal/document.php?id='.$this->id. $get_params; } @@ -3646,68 +3646,68 @@ class PropaleLigne extends CommonObjectLine */ public $table_element='propaldet'; - var $oldline; + public $oldline; // From llx_propaldet - var $fk_propal; - var $fk_parent_line; - var $desc; // Description ligne - var $fk_product; // Id produit predefini + public $fk_propal; + public $fk_parent_line; + public $desc; // Description ligne + public $fk_product; // Id produit predefini /** * @deprecated * @see product_type */ - var $fk_product_type; + public $fk_product_type; /** * Product type. * @var int * @see Product::TYPE_PRODUCT, Product::TYPE_SERVICE */ - var $product_type = Product::TYPE_PRODUCT; + public $product_type = Product::TYPE_PRODUCT; - var $qty; - var $tva_tx; - var $subprice; - var $remise_percent; - var $fk_remise_except; + public $qty; + public $tva_tx; + public $subprice; + public $remise_percent; + public $fk_remise_except; - var $rang = 0; + public $rang = 0; - var $fk_fournprice; - var $pa_ht; - var $marge_tx; - var $marque_tx; + public $fk_fournprice; + public $pa_ht; + public $marge_tx; + public $marque_tx; - var $special_code; // Tag for special lines (exlusive tags) + public $special_code; // Tag for special lines (exlusive tags) // 1: frais de port // 2: ecotaxe // 3: option line (when qty = 0) - var $info_bits = 0; // Liste d'options cumulables: + public $info_bits = 0; // Liste d'options cumulables: // Bit 0: 0 si TVA normal - 1 si TVA NPR // Bit 1: 0 ligne normale - 1 si ligne de remise fixe - var $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne - var $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne - var $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne + public $total_ht; // Total HT de la ligne toute quantite et incluant la remise ligne + public $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne + public $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne /** * @deprecated * @see $remise_percent, $fk_remise_except */ - var $remise; + public $remise; /** * @deprecated * @see subprice */ - var $price; + public $price; // From llx_product /** * @deprecated * @see product_ref */ - var $ref; + public $ref; /** * Product reference * @var string @@ -3717,7 +3717,7 @@ class PropaleLigne extends CommonObjectLine * @deprecated * @see product_label */ - var $libelle; + public $libelle; /** * Product label * @var string @@ -3729,25 +3729,25 @@ class PropaleLigne extends CommonObjectLine */ public $product_desc; - var $localtax1_tx; // Local tax 1 - var $localtax2_tx; // Local tax 2 - var $localtax1_type; // Local tax 1 type - var $localtax2_type; // Local tax 2 type - var $total_localtax1; // Line total local tax 1 - var $total_localtax2; // Line total local tax 2 + public $localtax1_tx; // Local tax 1 + public $localtax2_tx; // Local tax 2 + public $localtax1_type; // Local tax 1 type + public $localtax2_type; // Local tax 2 type + public $total_localtax1; // Line total local tax 1 + public $total_localtax2; // Line total local tax 2 - var $date_start; - var $date_end; + public $date_start; + public $date_end; - var $skip_update_total; // Skip update price total for special lines + public $skip_update_total; // Skip update price total for special lines // Multicurrency - var $fk_multicurrency; - var $multicurrency_code; - var $multicurrency_subprice; - var $multicurrency_total_ht; - var $multicurrency_total_tva; - var $multicurrency_total_ttc; + public $fk_multicurrency; + public $multicurrency_code; + public $multicurrency_subprice; + public $multicurrency_total_ht; + public $multicurrency_total_tva; + public $multicurrency_total_ttc; /** * Class line Contructor diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 2bd942a3c34..ca7823a6ac1 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -16,9 +16,9 @@ * along with this program. If not, see . */ - use Luracast\Restler\RestException; +use Luracast\Restler\RestException; - require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; /** * API class for orders @@ -544,7 +544,7 @@ class Orders extends DolibarrApi } if( ! $this->commande->delete(DolibarrApiAccess::$user)) { - throw new RestException(500, 'Error when delete order : '.$this->commande->error); + throw new RestException(500, 'Error when deleting order : '.$this->commande->error); } return array( @@ -838,15 +838,16 @@ class Orders extends DolibarrApi } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->note); diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index 04692fb4e44..72ba4c82db1 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -248,14 +248,16 @@ class BankAccounts extends DolibarrApi return $account; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->rowid); diff --git a/htdocs/compta/compta-files.php b/htdocs/compta/compta-files.php index 3917cad6133..647348269a2 100644 --- a/htdocs/compta/compta-files.php +++ b/htdocs/compta/compta-files.php @@ -25,15 +25,14 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; -require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -$langs->loadLangs(array("accountancy","bills")); +$langs->loadLangs(array("accountancy", "bills", "companies")); $date_start =GETPOST('date_start', 'alpha'); $date_startDay= GETPOST('date_startday', 'int'); @@ -49,7 +48,7 @@ $date_stop=($date_stopDay)?dol_mktime(0, 0, 0, $date_stopMonth, $date_stopDay, $ $action =GETPOST('action', 'alpha'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('comptafileslist','globallist')); +$hookmanager->initHooks(array('comptafileslist', 'globallist')); // Load variable for pagination $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; @@ -92,7 +91,7 @@ $filesarray=array(); $result=false; if(($action=="searchfiles" || $action=="dl" ) && $date_start && $date_stop) { $wheretail=" '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'"; - $sql="SELECT rowid as id, ref as ref,paye as paid, total_ttc, fk_soc, datef as date, 'Invoice' as item FROM ".MAIN_DB_PREFIX."facture"; + $sql="SELECT rowid as id, ref as ref, paye as paid, total_ttc, fk_soc, datef as date, 'Invoice' as item FROM ".MAIN_DB_PREFIX."facture"; $sql.=" WHERE datef between ".$wheretail; $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; $sql.=" AND fk_statut <> ".Facture::STATUS_DRAFT; @@ -189,6 +188,7 @@ if(($action=="searchfiles" || $action=="dl" ) && $date_start && $date_stop) { //var_dump($upload_dir); if (count($files) < 1) { + $nofile['id']=$objd->id; $nofile['date']=$db->idate($objd->date); $nofile['paid']=$objd->paid; $nofile['amount']=$objd->total_ttc; @@ -202,6 +202,7 @@ if(($action=="searchfiles" || $action=="dl" ) && $date_start && $date_stop) { { foreach ($files as $key => $file) { + $file['id']=$objd->id; $file['date']=$db->idate($objd->date); $file['paid']=$objd->paid; $file['amount']=$objd->total_ttc; @@ -236,6 +237,12 @@ if(($action=="searchfiles" || $action=="dl" ) && $date_start && $date_stop) { if ($result && $action == "dl") { + if (! extension_loaded('zip')) + { + setEventMessages('PHPZIPExtentionNotLoaded', null, 'errors'); + exit; + } + $dirfortmpfile = ($conf->accounting->dir_temp ? $conf->accounting->dir_temp : $conf->compta->dir_temp); dol_mkdir($dirfortmpfile); diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 0f1b420f66e..01ef8b4c7c3 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1131,7 +1131,7 @@ if (empty($reshook)) // Source facture $object->fac_rec = GETPOST('fac_rec', 'int'); - $id = $object->create($user); // This include recopy of links from recurring invoice and invoice lines + $id = $object->create($user); // This include recopy of links from recurring invoice and recurring invoice lines } } diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 6c4c94fc2ce..d68c3d40338 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1417,15 +1417,16 @@ class Invoices extends DolibarrApi return $paiement_id; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->note); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 5e2db021f83..7b34ad4e895 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -723,7 +723,7 @@ class Facture extends CommonInvoice } /* - * Insert lines of predefined invoices + * Insert lines of template invoices */ if (! $error && $this->fac_rec > 0) { @@ -749,7 +749,32 @@ class Facture extends CommonInvoice $localtax1_tx = $_facrec->lines[$i]->localtax1_tx; $localtax2_tx = $_facrec->lines[$i]->localtax2_tx; - $result_insert = $this->addline( + $fk_product_fournisseur_price = empty($_facrec->lines[$i]->fk_product_fournisseur_price)?null:$_facrec->lines[$i]->fk_product_fournisseur_price; + $buyprice = empty($_facrec->lines[$i]->buyprice)?0:$_facrec->lines[$i]->buyprice; + // If buyprice not defined from template invoice, we try to guess the best value + if (! $buyprice && $_facrec->lines[$i]->fk_product > 0) + { + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $producttmp = new ProductFournisseur($this->db); + $producttmp->fetch($_facrec->lines[$i]->fk_product); + + // If margin module defined on costprice, we try the costprice + // If not defined or if module margin defined and pmp and stock module enabled, we try pmp price + // else we get the best supplier price + if ($conf->global->MARGIN_TYPE == 'costprice' && ! empty($producttmp->cost_price)) $buyprice = $producttmp->cost_price; + elseif (! empty($conf->stock->enabled) && ($conf->global->MARGIN_TYPE == 'costprice' || $conf->global->MARGIN_TYPE == 'pmp') && ! empty($producttmp->pmp)) $buyprice = $producttmp->pmp; + else { + if ($producttmp->find_min_price_product_fournisseur($_facrec->lines[$i]->fk_product) > 0) + { + if ($producttmp->product_fourn_price_id > 0) + { + $buyprice = price2num($producttmp->fourn_unitprice * (1 - $producttmp->fourn_remise_percent/100) + $producttmp->fourn_remise, 'MU'); + } + } + } + } + + $result_insert = $this->addline( $_facrec->lines[$i]->desc, $_facrec->lines[$i]->subprice, $_facrec->lines[$i]->qty, @@ -771,8 +796,8 @@ class Facture extends CommonInvoice '', 0, 0, - null, - 0, + $fk_product_fournisseur_price, + $buyprice, $_facrec->lines[$i]->label, empty($_facrec->lines[$i]->array_options)?null:$_facrec->lines[$i]->array_options, $_facrec->lines[$i]->situation_percent, @@ -4273,9 +4298,9 @@ class Facture extends CommonInvoice /** * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id * @return bool */ public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index 6f4a2041670..00d168a0db4 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -633,15 +633,16 @@ class Contracts extends DolibarrApi + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - private function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable $object = parent::_cleanObjectDatas($object); unset($object->address); diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 73cbd572e9d..272ac1532a6 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -29,7 +29,7 @@ // Submit file/link if (GETPOST('sendit', 'alpha') && ! empty($conf->global->MAIN_UPLOAD_DOC)) { - if (! empty($_FILES)) + if (! empty($_FILES)) { if (is_array($_FILES['userfile']['tmp_name'])) $userfiles=$_FILES['userfile']['tmp_name']; else $userfiles=array($_FILES['userfile']['tmp_name']); diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index e23b32c5fb7..3c0e979cbed 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -1,11 +1,12 @@ - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) Dan Potter + * Copyright (C) Eric Seigne + * Copyright (C) 2000-2005 Rodolphe Quiedeville + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2019 Frédéric France * * 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 @@ -1429,7 +1430,7 @@ class CMailFile * Return a formatted address string for SMTP protocol * * @param string $address Example: 'John Doe , Alan Smith ' or 'john@doe.com, alan@smith.com' - * @param int $format 0=auto, 1=emails with <>, 2=emails without <>, 3=auto + label between " + * @param int $format 0=auto, 1=emails with <>, 2=emails without <>, 3=auto + label between ", 4 label or email, 5 mailto link * @param int $encode 0=No encode name, 1=Encode name to RFC2822 * @param int $maxnumberofemail 0=No limit. Otherwise, maximum number of emails returned ($address may contains several email separated with ','). Add '...' if there is more. * @return string If format 0: '' or 'John Doe ' or '=?UTF-8?B?Sm9obiBEb2U=?= ' @@ -1437,6 +1438,7 @@ class CMailFile * If format 2: 'john@doe.com' * If format 3: '' or '"John Doe" ' or '"=?UTF-8?B?Sm9obiBEb2U=?=" ' * If format 4: 'John Doe' or 'john@doe.com' if no label exists + * If format 5: John Doe or john@doe.com if no label exists */ public static function getValidAddress($address, $format, $encode = 0, $maxnumberofemail = 0) { @@ -1466,6 +1468,10 @@ class CMailFile $i++; $newemail=''; + if ($format == 5) { + $newemail = $name?$name:$email; + $newemail = ''.$newemail.''; + } if ($format == 4) { $newemail = $name?$name:$email; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f6232fd9394..e962e59264c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6378,6 +6378,7 @@ abstract class CommonObject } if (($mode == 'create' || $mode == 'edit') && abs($visibility) != 1 && abs($visibility) != 3) continue; // <> -1 and <> 1 and <> 3 = not visible on forms, only on list + elseif($mode == 'view' && empty($visibility)) continue; if (empty($perms)) continue; // Load language if required diff --git a/htdocs/core/class/commonorder.class.php b/htdocs/core/class/commonorder.class.php index 9d9445df91c..ddaef527630 100644 --- a/htdocs/core/class/commonorder.class.php +++ b/htdocs/core/class/commonorder.class.php @@ -82,7 +82,7 @@ abstract class CommonOrderLine extends CommonObjectLine * @deprecated * @see subprice */ - var $price; + public $price; /** * Unit price before taxes diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index a83ff1083e6..0618e15afe8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2747,23 +2747,23 @@ class Form } if ($objp->quantity == 1) { - $opt.= price($objp->fprice, 1, $langs, 0, 0, -1, $conf->currency)."/"; - $outval.= price($objp->fprice, 0, $langs, 0, 0, -1, $conf->currency)."/"; + $opt.= price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/"; + $outval.= price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 0, $langs, 0, 0, -1, $conf->currency)."/"; $opt.= $langs->trans("Unit"); // Do not use strtolower because it breaks utf8 encoding $outval.=$langs->transnoentities("Unit"); } else { - $opt.= price($objp->fprice, 1, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity; - $outval.= price($objp->fprice, 0, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity; + $opt.= price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity; + $outval.= price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 0, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity; $opt.= ' '.$langs->trans("Units"); // Do not use strtolower because it breaks utf8 encoding $outval.= ' '.$langs->transnoentities("Units"); } if ($objp->quantity >= 1) { - $opt.=" (".price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit").")"; // Do not use strtolower because it breaks utf8 encoding - $outval.=" (".price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->transnoentities("Unit").")"; // Do not use strtolower because it breaks utf8 encoding + $opt.=" (".price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit").")"; // Do not use strtolower because it breaks utf8 encoding + $outval.=" (".price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 0, $langs, 0, 0, -1, $conf->currency)."/".$langs->transnoentities("Unit").")"; // Do not use strtolower because it breaks utf8 encoding } if ($objp->remise_percent >= 1) { @@ -2854,7 +2854,7 @@ class Form $langs->load('stocks'); $sql = "SELECT p.rowid, p.label, p.ref, p.price, p.duration, pfp.fk_soc,"; - $sql.= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.quantity, pfp.unitprice,"; + $sql.= " pfp.ref_fourn, pfp.rowid as idprodfournprice, pfp.price as fprice, pfp.remise_percent, pfp.quantity, pfp.unitprice,"; $sql.= " pfp.fk_supplier_price_expression, pfp.fk_product, pfp.tva_tx, s.nom as name"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_fournisseur_price as pfp ON p.rowid = pfp.fk_product"; @@ -2914,7 +2914,7 @@ class Form } if ($objp->quantity == 1) { - $opt.= price($objp->fprice, 1, $langs, 0, 0, -1, $conf->currency)."/"; + $opt.= price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/"; } $opt.= $objp->quantity.' '; @@ -2930,7 +2930,7 @@ class Form if ($objp->quantity > 1) { $opt.=" - "; - $opt.= price($objp->unitprice, 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit"); + $opt.= price($objp->unitprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE)?(1 - $objp->remise_percent / 100):1), 1, $langs, 0, 0, -1, $conf->currency)."/".$langs->trans("Unit"); } if ($objp->duration) $opt .= " - ".$objp->duration; $opt .= "\n"; diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index 1758480af8f..166e0ce2044 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -62,7 +62,9 @@ class FormAdmin public function select_language($selected = '', $htmlname = 'lang_id', $showauto = 0, $filter = null, $showempty = '', $showwarning = 0, $disabled = 0, $morecss = '', $showcode = 0, $forcecombo = 0) { // phpcs:enable - global $langs; + global $conf, $langs; + + if (!empty($conf->global->MAIN_DEFAULT_LANGUAGE_FILTER)) $filter[$conf->global->MAIN_DEFAULT_LANGUAGE_FILTER] = 1; $langs_available=$langs->get_available_languages(DOL_DOCUMENT_ROOT, 12); diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 5e875be176d..1ea48c90091 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -77,9 +77,10 @@ class FormFile * @param string $htmlname Name and id of HTML form ('formuserfile' by default, 'formuserfileecm' when used to upload a file in ECM) * @param string $accept Specifies the types of files accepted (This is not a security check but an user interface facility. eg '.pdf,image/*' or '.png,.jpg' or 'video/*') * @param string $sectiondir If upload must be done inside a particular directory (is sectiondir defined, sectionid must not be) + * @param int $usewithoutform 0=Default, 1=Disable
and style to use in existing area * @return int <0 if KO, >0 if OK */ - public function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '') + public function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '', $usewithoutform = 0) { // phpcs:enable global $conf,$langs, $hookmanager; @@ -114,10 +115,13 @@ class FormFile if (empty($title)) $title=$langs->trans("AttachANewFile"); if ($title != 'none') $out.=load_fiche_titre($title, null, null); - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; + if (empty($usewithoutform)) + { + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + } $out .= '
'; $out .= ''; @@ -176,13 +180,7 @@ class FormFile if ($savingdocmask) { //add a global variable for disable the auto renaming on upload - if (! empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT)) - { - $rename=''; - } - else { - $rename='checked'; - } + $rename=(empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT)?'checked':''); $out .= ''; if (! empty($options)) $out .= ''; @@ -194,8 +192,11 @@ class FormFile $out .= "
'.$options.'
"; - $out .= ''; - if (empty($sectionid)) $out .= '
'; + if (empty($usewithoutform)) + { + $out .= ''; + if (empty($sectionid)) $out .= '
'; + } $out .= "\n\n"; @@ -205,12 +206,16 @@ class FormFile $langs->load('link'); $title = $langs->trans("LinkANewFile"); $out .= load_fiche_titre($title, null, null); - $out .= '