diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 7fa5bb3c28f..c83aa248c6b 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -174,15 +174,15 @@ if ($action == 'maj_pattern') $explodePattern = explode(';', $pattern); $patternInError = false; - if($explodePattern[0] < 1){ + if ($explodePattern[0] < 1 || $explodePattern[4] < 0) { $patternInError = true; } - if($explodePattern[0] < $explodePattern[1] + $explodePattern[2] + $explodePattern[3]){ + if ($explodePattern[0] < $explodePattern[1] + $explodePattern[2] + $explodePattern[3]) { $patternInError = true; } - if(!$patternInError){ + if (!$patternInError) { dolibarr_set_const($db, "USER_PASSWORD_PATTERN", $pattern, 'chaine', 0, '', $conf->entity); header("Location: security.php"); exit; diff --git a/htdocs/admin/system/about.php b/htdocs/admin/system/about.php index a941c89b994..706bcd9912a 100644 --- a/htdocs/admin/system/about.php +++ b/htdocs/admin/system/about.php @@ -160,7 +160,6 @@ print ''; diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index 8cb1e85afe4..31e2d8f219a 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -42,6 +42,12 @@ $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scandir', 'alpha'); $type = 'ticket'; +$error = 0; + +/* + * Actions + */ + if ($action == 'updateMask') { $maskconstticket = GETPOST('maskconstticket', 'alpha'); $maskticket = GETPOST('maskticket', 'alpha'); @@ -91,7 +97,7 @@ if ($action == 'updateMask') { $error++; } - $mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'alpha'); + $mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'restricthtml'); if (!empty($mail_intro)) { $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity); } else { @@ -101,7 +107,7 @@ if ($action == 'updateMask') { $error++; } - $mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'alpha'); + $mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'restricthtml'); if (!empty($mail_signature)) { $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, '', $conf->entity); } else { @@ -110,16 +116,6 @@ if ($action == 'updateMask') { 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') { diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index 4e6b6d75e85..ec36d3f873d 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -42,6 +42,12 @@ $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scandir', 'alpha'); $type = 'ticket'; +$error = 0; + +/* + * Actions + */ + if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') { if (GETPOST('value')) dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 1, 'chaine', 0, '', $conf->entity); @@ -51,95 +57,54 @@ if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') 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); + $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'nohtml'); + if (!empty($topic_interface)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity); } else { - $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', '', 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity); } if (!$res > 0) { - $error++; + $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); + $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'restricthtml'); + if (!empty($text_home)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity); } else { - $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity); } if (!$res > 0) { - $error++; + $error++; } - $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'alpha'); + $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'restricthtml'); + 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++; + } + + $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'restricthtml'); if (!empty($mail_new_ticket)) { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity); + $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); + $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++; + $error++; } $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha'); if (!empty($url_interface)) { - $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity); + $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); + $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($topic_interface)) { - $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($text_home)) { - $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++; + $error++; } } @@ -162,14 +127,11 @@ if ($action == 'setvarother') { $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++; - } - } + $param_show_module_logo = GETPOST('TICKET_SHOW_COMPANY_LOGO', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_SHOW_COMPANY_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { @@ -179,12 +141,6 @@ if ($action == 'setvarother') { $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++; - } } @@ -238,8 +194,7 @@ print '

'; if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { - - if (!$conf->use_javascript_ajax) { + if (empty($conf->use_javascript_ajax)) { print '
'; print ''; print ''; @@ -349,16 +304,6 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print "\n"; } - // Url public interface - $url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; - print '' . $langs->trans("TicketUrlPublicInterfaceLabelAdmin") . ''; - print ''; - print ''; - print ''; - print ''; - print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); - print ''; - // Interface topic $url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC; print '' . $langs->trans("TicketPublicInterfaceTopicLabelAdmin") . ''; @@ -420,6 +365,16 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print $form->textwithpicto('', $langs->trans("TicketNewEmailBodyHelp"), 1, 'help'); print ''; + // Url public interface + $url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; + print '' . $langs->trans("TicketUrlPublicInterfaceLabelAdmin") . ''; + print ''; + print ''; + print ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); + print ''; + print ''; print '
'; diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 501192a68eb..cba2a3c1e5d 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -172,6 +172,7 @@ class CUnits // extends CommonObject $sql.= " t.code,"; $sql.= " t.label,"; $sql.= " t.short_label,"; + $sql.= " t.scale,"; $sql.= " t.unit_type,"; $sql.= " t.active"; $sql.= " FROM ".MAIN_DB_PREFIX."c_units as t"; @@ -195,6 +196,7 @@ class CUnits // extends CommonObject $this->code = $obj->code; $this->label = $obj->label; $this->short_label = $obj->short_label; + $this->scale = $obj->scale; $this->unit_type = $obj->unit_type; $this->active = $obj->active; } diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index b0cdcd23a96..99153f667e9 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -212,7 +212,7 @@ class FormMail extends Form /** * Remove a file from the list of attached files (stored in SECTION array) * - * @param string $keytodelete Key in file array (0, 1, 2, ...) + * @param string $keytodelete Key index in file array (0, 1, 2, ...) * @return void */ public function remove_attached_files($keytodelete) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index cdb595883f3..747b2dbdf8b 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -939,13 +939,13 @@ class FormTicket if (is_array($contacts) && count($contacts) > 0) { foreach ($contacts as $key => $info_sendto) { if ($info_sendto['email'] != '') { - $sendto[] = dol_escape_htmltag(trim($info_sendto['firstname'] . " " . $info_sendto['lastname']) . " <" . $info_sendto['email'] . "> (" . $info_sendto['libelle'] . ")"); + $sendto[] = dol_escape_htmltag(trim($info_sendto['firstname'] . " " . $info_sendto['lastname']) . " <" . $info_sendto['email'] . ">")." (" . dol_escape_htmltag($info_sendto['libelle']) . ")"; } } } if ($ticketstat->origin_email && !in_array($this->dao->origin_email, $sendto)) { - $sendto[] = $ticketstat->origin_email . "(origin)"; + $sendto[] = dol_escape_htmltag($ticketstat->origin_email) . " (".$langs->trans("TicketEmailOriginIssuer").")"; } if ($ticketstat->fk_soc > 0) { @@ -953,12 +953,12 @@ class FormTicket $ticketstat->fetch_thirdparty(); if (is_array($ticketstat->thirdparty->email) && !in_array($ticketstat->thirdparty->email, $sendto)) { - $sendto[] = $ticketstat->thirdparty->email . '(' . $langs->trans('Customer') . ')'; + $sendto[] = $ticketstat->thirdparty->email . ' (' . $langs->trans('Customer') . ')'; } } if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS) { - $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO . '(generic email)'; + $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO . ' (generic email)'; } // Print recipient list diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 27a197a88fb..22c3bdb6785 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -540,6 +540,9 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti $out=dol_string_nohtmltag($out); } break; + case 'restricthtml': // Recommended for most html textarea + $out=dol_string_onlythesehtmltags($out, 0); + break; case 'custom': if (empty($filter)) return 'BadFourthParameterForGETPOST'; $out=filter_var($out, $filter, $options); diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php index db5740d277b..f2b701b371f 100644 --- a/htdocs/core/lib/payments.lib.php +++ b/htdocs/core/lib/payments.lib.php @@ -125,12 +125,12 @@ function getValidOnlinePaymentMethods($paymentmethod = '') */ function showOnlinePaymentUrl($type, $ref) { - global $conf, $langs; + global $langs; // Load translation files required by the page $langs->loadLangs(array('payment', 'paybox')); - $servicename='Online'; + $servicename=$langs->transnoentitiesnoconv('Online'); $out = img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'
'; $url = getOnlinePaymentUrl(0, $type, $ref); diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 0a60d9dc0ae..fd39ed6f49e 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -489,7 +489,7 @@ class ImportCsv extends ModeleImports { if (empty($newval)) $newval='0'; } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits') + elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits' || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchscalefromcodeunits') { $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']); $class=$objimport->array_import_convertvalue[0][$val]['class']; @@ -509,16 +509,17 @@ class ImportCsv extends ModeleImports } $classinstance=new $class($this->db); // Try the fetch from code or ref - call_user_func_array(array($classinstance, $method), array('', $units, $newval)); - $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code; - //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; - if ($classinstance->code != '') // id may be 0, it is a found value + call_user_func_array(array($classinstance, $method), array('', '', $newval, $units)); + $scaleorid = (($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits') ? $classinstance->id : $classinstance->scale); + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$scaleorid; + //print 'We have made a '.$class.'->'.$method." to get a value from key '".$newval."' and we got '".$scaleorid."'.";exit; + if ($classinstance->id > 0) // we found record { - $newval=$classinstance->code; + $newval = $scaleorid ? $scaleorid : 0; } else { - if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); + if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'scale', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); else $this->errors[$error]['lib']='ErrorFieldValueNotIn'; $this->errors[$error]['type']='FOREIGNKEY'; $errorforthistable++; @@ -677,7 +678,7 @@ class ImportCsv extends ModeleImports // Loop on each hidden fields to add them into listfields/listvalues foreach($objimport->array_import_fieldshidden[0] as $key => $val) { - if (! preg_match('/^'.preg_quote($alias).'\./', $key)) continue; // Not a field of current table + if (! preg_match('/^'.preg_quote($alias, '/').'\./', $key)) continue; // Not a field of current table if ($val == 'user->id') { $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index af9c0e2c412..a4615579f34 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -516,7 +516,7 @@ class ImportXlsx extends ModeleImports { if (empty($newval)) $newval='0'; } - elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits') + elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits' || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchscalefromcodeunits') { $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']); $class=$objimport->array_import_convertvalue[0][$val]['class']; @@ -536,17 +536,18 @@ class ImportXlsx extends ModeleImports } $classinstance=new $class($this->db); // Try the fetch from code or ref - call_user_func_array(array($classinstance, $method), array('', $units, '', $newval)); - $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code; - //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; - if ($classinstance->code != '') // id may be 0, it is a found value - { - $newval=$classinstance->code; - } - else - { - if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); - else $this->errors[$error]['lib']='ErrorFieldValueNotIn'; + call_user_func_array(array($classinstance, $method), array('', '', $newval, $units)); + $scaleorid = (($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits') ? $classinstance->id : $classinstance->scale); + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$scaleorid; + //print 'We have made a '.$class.'->'.$method." to get a value from key '".$newval."' and we got '".$scaleorid."'.";exit; + if ($classinstance->id > 0) // we found record + { + $newval = $scaleorid ? $scaleorid : 0; + } + else + { + if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'scale', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); + else $this->errors[$error]['lib']='ErrorFieldValueNotIn'; $this->errors[$error]['type']='FOREIGNKEY'; $errorforthistable++; $error++; @@ -668,8 +669,9 @@ class ImportXlsx extends ModeleImports $errorforthistable++; $error++; } - } elseif (! preg_match('/'.$objimport->array_import_regex[0][$val].'/i', $newval)) { - // If test is just a static regex + } + // If test is just a static regex + elseif (! preg_match('/'.$objimport->array_import_regex[0][$val].'/i', $newval)) { //if ($key == 19) print "xxx".$newval."zzz".$objimport->array_import_regex[0][$val]."
"; $this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorWrongValueForField', $key, $newval, $objimport->array_import_regex[0][$val]); $this->errors[$error]['type']='REGEX'; @@ -778,7 +780,7 @@ class ImportXlsx extends ModeleImports $error++; } } else { - // We have a last INSERT ID. Check if we have a row referencing this foreign key. + // We have a last INSERT ID (got by previous pass), so we check if we have a row referencing this foreign key. // This is required when updating table with some extrafields. When inserting a record in parent table, we can make // a direct insert into subtable extrafields, but when me wake an update, the insertid is defined and the child record // may already exists. So we rescan the extrafield table to know if record exists or not for the rowid. diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 9592e3b185f..001c7759c67 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -168,16 +168,22 @@ class modProduct extends DolibarrModules $this->export_label[$r]="Products"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("produit","export")); $this->export_fields_array[$r]=array( - 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode", - 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", - 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.width'=>"Width",'p.height'=>"Height",'p.surface'=>"Surface", - 'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode','p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC", - 'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification' + 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label", + 'p.fk_product_type'=>'Type','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy", + 'p.description'=>"Description",'p.url'=>"PublicUrl", + 'p.customcode'=>'CustomCode','p.fk_country'=>'IDCountry', + 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", + 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", + 'p.note'=>"NotePrivate",'p.note_public'=>'NotePublic', + 'p.weight'=>"Weight",'p.length'=>"Length",'p.width'=>"Width",'p.height'=>"Height",'p.surface'=>"Surface",'p.volume'=>"Volume", + //'p.duration'=>"Duration", + 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC", + 'p.tva_tx'=>'VATRate','p.datec'=>'DateCreation','p.tms'=>'DateModification' ); if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR'; + if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.quantity'=>'QtyMin','pf.remise_percent'=>'DiscountQtyMin','pf.unitprice'=>'BuyingPrice','pf.delivery_time_days'=>'NbDaysToDelivery')); @@ -187,9 +193,11 @@ class modProduct extends DolibarrModules $this->export_TypeFields_array[$r]=array( 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text",'p.accountancy_code_sell_export'=>"Text",'p.accountancy_code_buy'=>"Text", - 'p.note'=>"Text",'p.length'=>"Numeric",'p.width'=>"Numeric",'p.height'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric", + 'p.note'=>"Text",'p.note_public'=>"Text", + 'p.weight'=>"Numeric",'p.length'=>"Numeric",'p.width'=>"Numeric",'p.height'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric", 'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date' + //'p.duration'=>"Duree", ); if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); @@ -292,8 +300,9 @@ class modProduct extends DolibarrModules $this->export_fields_array[$r]=array( 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl", 'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", - 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note", - 'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode', + 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", + 'p.note'=>"NotePrivate",'p.note_public'=>'NotePublic', + 'p.weight'=>"Weight",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.customcode'=>'CustomCode', 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell", 'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification' ); @@ -301,9 +310,10 @@ class modProduct extends DolibarrModules if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty','pa.incdec'=>'ComposedProductIncDecStock')); $this->export_TypeFields_array[$r]=array( - 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text", - 'p.accountancy_code_sell_intra'=>"Text",'p.accountancy_code_sell_export'=>"Text",'p.accountancy_code_buy'=>"Text", - 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text', + 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text", + 'p.accountancy_code_sell'=>"Text",'p.accountancy_code_sell_intra'=>"Text",'p.accountancy_code_sell_export'=>"Text",'p.accountancy_code_buy'=>"Text", + 'p.note'=>"Text",'p.note_public'=>"Text", + 'p.weight'=>"Numeric",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.customcode'=>'Text', 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", 'p.datec'=>'Date','p.tms'=>'Date' ); @@ -346,31 +356,23 @@ class modProduct extends DolibarrModules $this->import_entities_array[$r]=array(); // We define here only fields that use a different icon from the one defined in import_icon $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields'); $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id - $this->import_fields_array[$r]=array(//field order as per structure of table llx_product + $this->import_fields_array[$r]=array( 'p.ref' => "Ref*", - 'p.datec' => 'DateCreation', 'p.label' => "Label*", - 'p.description' => "Description", - 'p.note_public' => "PublicNote",//public note - 'p.note' => "PrivateNote",//private note - 'p.customcode' => 'CustomCode', - 'p.price' => "SellingPriceHT",//without - 'p.price_min' => "MinPrice", - 'p.price_ttc' => "SellingPriceTTC",//with tax - 'p.price_min_ttc' => "SellingMinPriceTTC", - 'p.price_base_type' => "PriceBaseType",//price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card - 'p.cost_price' => "CostPrice", - 'p.tva_tx' => 'VATRate', - 'p.tosell' => "OnSell*", - 'p.tobuy' => "OnBuy*", - 'p.fk_product_type' => "Type*", - 'p.duration' => "Duration",///duration of service - 'p.url' => "PublicUrl", + 'p.fk_product_type' => "Type*", + 'p.tosell' => "OnSell*", + 'p.tobuy' => "OnBuy*", + 'p.description' => "Description", + 'p.url' => "PublicUrl", + 'p.customcode' => 'CustomCode', + 'p.fk_country' => 'CountryCode', 'p.accountancy_code_sell' => "ProductAccountancySellCode", 'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode", 'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode", 'p.accountancy_code_buy' => "ProductAccountancyBuyCode", - 'p.weight' => "Weight", + 'p.note_public' => "NotePublic", + 'p.note' => "NotePrivate", + 'p.weight' => "Weight", 'p.weight_units' => "WeightUnits", 'p.length' => "Length", 'p.length_units' => "LengthUnit", @@ -382,7 +384,16 @@ class modProduct extends DolibarrModules 'p.surface_units' => "SurfaceUnit", 'p.volume' => "Volume", 'p.volume_units' => "VolumeUnits", - 'p.finished' => 'Nature', + 'p.duration' => "Duration",//duration of service + 'p.finished' => 'Nature', + 'p.price' => "SellingPriceHT",//without + 'p.price_min' => "MinPrice", + 'p.price_ttc' => "SellingPriceTTC",//with tax + 'p.price_min_ttc' => "SellingMinPriceTTC", + 'p.price_base_type' => "PriceBaseType",//price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card + 'p.tva_tx' => 'VATRate', + 'p.datec' => 'DateCreation', + 'p.cost_price' => "CostPrice", ); if (!empty($conf->stock->enabled)) {//if Stock module enabled $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( @@ -392,10 +403,9 @@ class modProduct extends DolibarrModules )); } - /* Disabled: The value of fields xxx_units is the scale for reference unit, not the rowid in table llx_c_unit !!! $this->import_convertvalue_array[$r] = array( - 'p.weight_units' => array( - 'rule' => 'fetchidfromcodeunits', + 'p.weight_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -403,7 +413,7 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.length_units' => array( - 'rule' => 'fetchidfromcodeunits', + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -411,7 +421,7 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.width_units' => array( - 'rule' => 'fetchidfromcodeunits', + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -419,7 +429,7 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.height_units' => array( - 'rule' => 'fetchidfromcodeunits', + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -427,7 +437,7 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.surface_units' => array( - 'rule' => 'fetchidfromcodeunits', + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', @@ -435,14 +445,21 @@ class modProduct extends DolibarrModules 'dict' => 'DictionaryMeasuringUnits' ), 'p.volume_units' => array( - 'rule' => 'fetchidfromcodeunits', + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table 'classfile' => '/core/class/cunits.class.php', 'class' => 'CUnits', 'method' => 'fetch', 'units' => 'volume', 'dict' => 'DictionaryMeasuringUnits' - ) - );*/ + ), + 'p.fk_country' => array( + 'rule' => 'fetchidfromcodeid', + 'classfile' => '/core/class/ccountry.class.php', + 'class' => 'Ccountry', + 'method' => 'fetch', + 'dict' => 'DictionaryCountry' + ) + ); if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); @@ -480,18 +497,19 @@ class modProduct extends DolibarrModules // field order as per structure of table llx_product $import_sample = array( 'p.ref' => "PREF123456", - 'p.datec' => 'formatted as '.dol_print_date(dol_now(), '%Y-%m-%d'), + 'p.datec' => dol_print_date(dol_now(), '%Y-%m-%d'), 'p.label' => "Product name in default language", 'p.description' => "Product description in default language", 'p.note_public' => "a public note (free text)", 'p.note' => "a private note (free text)", 'p.customcode' => 'customs code', - 'p.price' => "price ex-vat eg. 100", - 'p.price_min' => "price ex-vat eg. 100", - 'p.price_ttc' => "price inc-vat eg. 110", - 'p.price_min_ttc' => "price inc-vat eg. 110", + 'p.fk_country' => 'FR', + 'p.price' => "100", + 'p.price_min' => "100", + 'p.price_ttc' => "110", + 'p.price_min_ttc' => "110", 'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)", - 'p.tva_tx' => 'tax rate eg: 10. Must match numerically one of the tax rates defined for your country', + 'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country' 'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)", 'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)", 'p.fk_product_type' => "0 (product) / 1 (service)", @@ -502,27 +520,27 @@ class modProduct extends DolibarrModules 'p.accountancy_code_sell_export' => "", 'p.accountancy_code_buy' => "", 'p.weight' => "", - 'p.weight_units' => 'use a unit of measure from the dictionary. g/Kg/T etc....matches field "Scale" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.weight_units' => 'kg', // Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.length' => "", - 'p.length_units' => 'use a unit of measure from the dictionary. m/cm/mm etc....matches field "Scale" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.length_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.width' => "", - 'p.width_units' => 'use a unit of measure from the dictionary. m/cm/mm etc....matches field "Scale" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.width_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.height' => "", - 'p.height_units' => 'use a unit of measure from the dictionary. m/cm/mm etc....matches field "Scale" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.height_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.surface' => "", - 'p.surface_units' => 'use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Scale" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.volume' => "", - 'p.volume_units' => 'use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Scale" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', 'p.finished' => '0 (raw material) / 1 (finished goods)' ); //clauses copied from import_fields_array if (!empty($conf->stock->enabled)) $import_sample = array_merge($import_sample, array( - 'p.seuil_stock_alerte' => 'quantity for low-stock warning (empty for no warning)', - 'p.pmp' => '0 (default)', - 'p.desiredstock' => 'target quantity to maintain in stock (for replenishment feature)' + 'p.seuil_stock_alerte' => '', + 'p.pmp' => '0', + 'p.desiredstock' => '' )); - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample=array_merge($import_sample, array('p.cost_price'=>'user-editable, used for margin calculations only')); - if (is_object($mysoc) && $mysoc->useNPR()) $import_sample=array_merge($import_sample, array('p.recuperableonly'=>'0 / 1 (French VAT NPR yes/no')); + if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample=array_merge($import_sample, array('p.cost_price'=>'90')); + if (is_object($mysoc) && $mysoc->useNPR()) $import_sample=array_merge($import_sample, array('p.recuperableonly'=>'0')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample=array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>'')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample=array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>'')); if (! empty($conf->barcode->enabled)) $import_sample=array_merge($import_sample, array('p.barcode'=>'')); @@ -534,6 +552,7 @@ class modProduct extends DolibarrModules ) ); + if (! is_array($this->import_convertvalue_array[$r])) $this->import_convertvalue_array[$r] = array(); $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array( 'p.fk_unit' => array( 'rule' => 'fetchidfromcodeorlabel', @@ -596,34 +615,34 @@ class modProduct extends DolibarrModules $this->import_examplevalues_array[$r]=array( 'sp.fk_product' => "PRODUCT_REF or id:123456", 'sp.fk_soc' => "My Supplier", - 'sp.ref_fourn' => "eg: XYZ-F123456", + 'sp.ref_fourn' => "XYZ-F123456", 'sp.quantity' => "5", - 'sp.tva_tx' => 'one of the defined rates eg. 21', + 'sp.tva_tx' => '10', 'sp.price'=>"50", 'sp.unitprice'=>'50', 'sp.remise_percent'=>'0', 'sp.default_vat_code' => '', - 'sp.delivery_time_days' => 'eg. 5', + 'sp.delivery_time_days' => '5', 'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER' ); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( - 'sp.price' => "eg. 50.00", - 'sp.unitprice' => 'eg. 10', + 'sp.price' => "50.00", + 'sp.unitprice' => '10', // TODO Make this field not required and calculate it from price and qty - 'sp.remise_percent' => 'eg: 20' + 'sp.remise_percent' => '20' )); if ($conf->multicurrency->enabled) { $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array( 'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency', - 'sp.multicurrency_code'=>'eg: GBP', - 'sp.multicurrency_tx'=>'currency rate eg: 1.12345', - 'sp.multicurrency_unitprice'=>'cost per unit in supplier currency', + 'sp.multicurrency_code'=>'GBP', + 'sp.multicurrency_tx'=>'1.12345', + 'sp.multicurrency_unitprice'=>'', // TODO Make this field not required and calculate it from price and qty - 'sp.multicurrency_price'=>'cost for min quantity in supplier currency' + 'sp.multicurrency_price'=>'' )); } @@ -653,8 +672,8 @@ class modProduct extends DolibarrModules ); $this->import_examplevalues_array[$r]=array('pr.fk_product'=>"PRODUCT_REF or id:123456", 'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)",'pr.price_level'=>"1", - 'pr.price'=>"100",'pr.price_ttc'=>"110", - 'pr.price_min'=>"100",'pr.price_min_ttc'=>"110", + 'pr.price'=>"100", 'pr.price_ttc'=>"110", + 'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110", 'pr.tva_tx'=>'20', 'pr.recuperableonly'=>'0', 'pr.date_price'=>'2013-04-10'); diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 605c48f0e6b..b21c954185a 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -141,19 +141,39 @@ class modService extends DolibarrModules $this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_label[$r]="Services"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("service","export")); - $this->export_fields_array[$r]=array('p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification'); + $this->export_fields_array[$r]=array( + 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label", + 'p.fk_product_type'=>'Type','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy", + 'p.description'=>"Description",'p.url'=>"PublicUrl", + 'p.customcode'=>'CustomCode','p.fk_country'=>'IDCountry', + 'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", + 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", + 'p.note'=>"NotePrivate",'p.note_public'=>'NotePublic', + //'p.weight'=>"Weight",'p.length'=>"Length",'p.width'=>"Width",'p.height'=>"Height",'p.surface'=>"Surface",'p.volume'=>"Volume", + 'p.duration'=>"Duration", + 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC", + 'p.tva_tx'=>'VATRate','p.datec'=>'DateCreation','p.tms'=>'DateModification' + ); if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['p.recuperableonly']='NPR'; + if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); - if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.cost_price'=>'CostPrice')); $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; if (! empty($conf->fournisseur->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('s.nom'=>'Supplier','pf.ref_fourn'=>'SupplierRef','pf.quantity'=>'QtyMin','pf.remise_percent'=>'DiscountQtyMin','pf.unitprice'=>'BuyingPrice','pf.delivery_time_days'=>'NbDaysToDelivery')); if (! empty($conf->global->EXPORTTOOL_CATEGORIES)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('group_concat(cat.label)'=>'Categories')); if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('l.lang'=>'Language', 'l.label'=>'TranslatedLabel','l.description'=>'TranslatedDescription','l.note'=>'TranslatedNote')); if (! empty($conf->global->PRODUCT_USE_UNITS)) $this->export_fields_array[$r]['p.fk_unit'] = 'Unit'; - $this->export_TypeFields_array[$r]=array('p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text",'p.note'=>"Text",'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date'); - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric')); + $this->export_TypeFields_array[$r]=array( + 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text", + 'p.accountancy_code_sell_intra'=>"Text",'p.accountancy_code_sell_export'=>"Text",'p.accountancy_code_buy'=>"Text", + 'p.note'=>"Text",'p.note_public'=>"Text", + 'p.weight'=>"Numeric",'p.length'=>"Numeric",'p.width'=>"Numeric",'p.height'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric", + 'p.customcode'=>'Text','p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean", + 'p.tobuy'=>"Boolean",'p.datec'=>'Date','p.tms'=>'Date', + 'p.duration'=>"Duree", + ); + if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); if (! empty($conf->fournisseur->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('s.nom'=>'Text','pf.ref_fourn'=>'Text','pf.unitprice'=>'Numeric','pf.quantity'=>'Numeric','pf.remise_percent'=>'Numeric','pf.delivery_time_days'=>'Numeric')); if (! empty($conf->global->MAIN_MULTILANGS)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('l.lang'=>'Text', 'l.label'=>'Text','l.description'=>'Text','l.note'=>'Text')); @@ -211,7 +231,7 @@ class modService extends DolibarrModules $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity - $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; + $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile } if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) @@ -243,7 +263,7 @@ class modService extends DolibarrModules $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid'; - $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; + $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile } if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) @@ -255,8 +275,10 @@ class modService extends DolibarrModules $this->export_permission[$r]=array(array("produit","export")); $this->export_fields_array[$r]=array( 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl", - 'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note", - 'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode', + 'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", + 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode", + 'p.note'=>"NotePrivate",'p.note_public'=>'NotePublic', + 'p.weight'=>"Weight",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.customcode'=>'CustomCode', 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell", 'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification' ); @@ -264,8 +286,10 @@ class modService extends DolibarrModules if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty','pa.incdec'=>'ComposedProductIncDecStock')); $this->export_TypeFields_array[$r]=array( - 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text", - 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text', + 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text", + 'p.accountancy_code_sell'=>"Text",'p.accountancy_code_sell_intra'=>"Text",'p.accountancy_code_sell_export'=>"Text",'p.accountancy_code_buy'=>"Text", + 'p.note'=>"Text",'p.note_public'=>"Text", + 'p.weight'=>"Numeric",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.customcode'=>'Text', 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", 'p.datec'=>'Date','p.tms'=>'Date' ); @@ -274,7 +298,8 @@ class modService extends DolibarrModules $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); $this->export_entities_array[$r]=array( 'p.rowid'=>"virtualproduct",'p.ref'=>"virtualproduct",'p.label'=>"virtualproduct",'p.description'=>"virtualproduct",'p.url'=>"virtualproduct", - 'p.accountancy_code_sell'=>'virtualproduct','p.accountancy_code_buy'=>'virtualproduct','p.note'=>"virtualproduct",'p.length'=>"virtualproduct", + 'p.accountancy_code_sell'=>'virtualproduct','p.accountancy_code_sell_intra'=>'virtualproduct','p.accountancy_code_sell_export'=>'virtualproduct', + 'p.accountancy_code_buy'=>'virtualproduct','p.note'=>"virtualproduct",'p.length'=>"virtualproduct", 'p.surface'=>"virtualproduct",'p.volume'=>"virtualproduct",'p.weight'=>"virtualproduct",'p.customcode'=>'virtualproduct', 'p.price_base_type'=>"virtualproduct",'p.price'=>"virtualproduct",'p.price_ttc'=>"virtualproduct",'p.tva_tx'=>"virtualproduct", 'p.tosell'=>"virtualproduct",'p.tobuy'=>"virtualproduct",'p.datec'=>"virtualproduct",'p.tms'=>"virtualproduct" @@ -290,55 +315,7 @@ class modService extends DolibarrModules $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; - $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; - $this->export_sql_end[$r] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; - } - - if (! empty($conf->global->PRODUIT_SOUSPRODUITS)) - { - // Exports virtual products - $r++; - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]="AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_permission[$r]=array(array("service","export")); - $this->export_fields_array[$r]=array( - 'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl", - 'p.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note", - 'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode', - 'p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC",'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell", - 'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification' - ); - if (! empty($conf->stock->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock','p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); - if (! empty($conf->barcode->enabled)) $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode')); - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty','pa.incdec'=>'ComposedProductIncDecStock')); - $this->export_TypeFields_array[$r]=array( - 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text",'p.accountancy_code_buy'=>"Text", - 'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'Text', - 'p.price_base_type'=>"Text",'p.price'=>"Numeric",'p.price_ttc'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean", - 'p.datec'=>'Date','p.tms'=>'Date' - ); - if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric','p.seuil_stock_alerte'=>'Numeric','p.desiredstock'=>'Numeric','p.pmp'=>'Numeric','p.cost_price'=>'Numeric')); - if (! empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text')); - $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric')); - $this->export_entities_array[$r]=array( - 'p.rowid'=>"virtualproduct",'p.ref'=>"virtualproduct",'p.label'=>"virtualproduct",'p.description'=>"virtualproduct",'p.url'=>"virtualproduct", - 'p.accountancy_code_sell'=>'virtualproduct','p.accountancy_code_buy'=>'virtualproduct','p.note'=>"virtualproduct",'p.length'=>"virtualproduct", - 'p.surface'=>"virtualproduct",'p.volume'=>"virtualproduct",'p.weight'=>"virtualproduct",'p.customcode'=>'virtualproduct', - 'p.price_base_type'=>"virtualproduct",'p.price'=>"virtualproduct",'p.price_ttc'=>"virtualproduct",'p.tva_tx'=>"virtualproduct", - 'p.tosell'=>"virtualproduct",'p.tobuy'=>"virtualproduct",'p.datec'=>"virtualproduct",'p.tms'=>"virtualproduct" - ); - if (! empty($conf->stock->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct','p.seuil_stock_alerte'=>'virtualproduct','p.desiredstock'=>'virtualproduct','p.pmp'=>'virtualproduct')); - if (! empty($conf->barcode->enabled)) $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct')); - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct",'pa.incdec'=>'subproduct')); - $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - $this->export_fields_array[$r]=array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id",'p2.ref'=>"Ref",'p2.label'=>"Label",'p2.description'=>"Description")); - $this->export_entities_array[$r]=array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct",'p2.ref'=>"subproduct",'p2.label'=>"subproduct",'p2.description'=>"subproduct")); - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,'; - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2'; - $this->export_sql_end[$r] .=' WHERE p.fk_product_type = 0 AND p.entity IN ('.getEntity('product').')'; + $this->export_sql_end[$r] .=' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile $this->export_sql_end[$r] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; } } @@ -357,12 +334,109 @@ class modService extends DolibarrModules $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product','extra'=>MAIN_DB_PREFIX.'product_extrafields'); $this->import_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id $this->import_fields_array[$r]=array( - 'p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode", - 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume", - 'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC", - 'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation' + 'p.ref' => "Ref*", + 'p.label' => "Label*", + 'p.fk_product_type' => "Type*", + 'p.tosell' => "OnSell*", + 'p.tobuy' => "OnBuy*", + 'p.description' => "Description", + 'p.url' => "PublicUrl", + 'p.customcode' => 'CustomCode', + 'p.fk_country' => 'CountryCode', + 'p.accountancy_code_sell' => "ProductAccountancySellCode", + 'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode", + 'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode", + 'p.accountancy_code_buy' => "ProductAccountancyBuyCode", + 'p.note_public' => "NotePublic", + 'p.note' => "NotePrivate", + 'p.weight' => "Weight", + 'p.weight_units' => "WeightUnits", + 'p.length' => "Length", + 'p.length_units' => "LengthUnit", + 'p.width' => "Width", + 'p.width_units' => "VolumeUnits", + 'p.height' => "Height", + 'p.height_units' => "HeightUnit", + 'p.surface' => "Surface", + 'p.surface_units' => "SurfaceUnit", + 'p.volume' => "Volume", + 'p.volume_units' => "VolumeUnits", + 'p.duration' => "Duration",//duration of service + 'p.finished' => 'Nature', + 'p.price' => "SellingPriceHT",//without + 'p.price_min' => "MinPrice", + 'p.price_ttc' => "SellingPriceTTC",//with tax + 'p.price_min_ttc' => "SellingMinPriceTTC", + 'p.price_base_type' => "PriceBaseType",//price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card + 'p.tva_tx' => 'VATRate', + 'p.datec' => 'DateCreation', + 'p.cost_price' => "CostPrice", ); - //if (! empty($conf->stock->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r],array('p.seuil_stock_alerte'=>'StockLimit','p.desiredstock'=>'DesiredStock','p.pmp'=>'PMPValue')); + if (!empty($conf->stock->enabled)) {//if Stock module enabled + $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( + 'p.seuil_stock_alerte' => 'StockLimit',//lower limit for warning + 'p.pmp' => 'PMPValue',//weighted average price + 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature + )); + } + + $this->import_convertvalue_array[$r] = array( + 'p.weight_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'units' => 'weight', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.length_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'units' => 'size', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.width_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'units' => 'size', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.height_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'units' => 'size', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.surface_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'units' => 'surface', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.volume_units' => array( + 'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'units' => 'volume', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.fk_country' => array( + 'rule' => 'fetchidfromcodeid', + 'classfile' => '/core/class/ccountry.class.php', + 'class' => 'Ccountry', + 'method' => 'fetch', + 'dict' => 'DictionaryCountry' + ) + ); if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); @@ -387,13 +461,82 @@ class modService extends DolibarrModules $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) $this->import_regex_array[$r]=array( 'p.ref'=>'[^ ]', - 'p.tosell'=>'^[0|1]$', + 'p.price_base_type' => '\AHT\z|\ATTC\z', + 'p.tosell'=>'^[0|1]$', 'p.tobuy'=>'^[0|1]$', 'p.fk_product_type'=>'^[0|1]$', 'p.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', - 'p.recuperableonly'=>'^[0|1]$' - ); - $import_sample=array('p.ref'=>"SERVICE_REF or id:123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.tosell'=>"0 or 1",'p.tobuy'=>"0 or 1",'p.fk_product_type'=>"0 for product/1 for service",'p.finished'=>'','p.duration'=>"1y",'p.datec'=>'2008-12-31','p.recuperableonly'=>'0 or 1'); + 'p.recuperableonly' => '^[0|1]$', + 'p.finished' => '^[0|1]$' + ); + // field order as per structure of table llx_product + $import_sample = array( + 'p.ref' => "PREF123456", + 'p.datec' => dol_print_date(dol_now(), '%Y-%m-%d'), + 'p.label' => "Product name in default language", + 'p.description' => "Product description in default language", + 'p.note_public' => "a public note (free text)", + 'p.note' => "a private note (free text)", + 'p.customcode' => 'customs code', + 'p.fk_country' => 'FR', + 'p.price' => "100", + 'p.price_min' => "100", + 'p.price_ttc' => "110", + 'p.price_min_ttc' => "110", + 'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)", + 'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country' + 'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)", + 'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)", + 'p.fk_product_type' => "0 (product) / 1 (service)", + 'p.duration' => "eg. 365d/12m/1y", + 'p.url' => 'link to product (no https)', + 'p.accountancy_code_sell' => "", + 'p.accountancy_code_sell_intra' => "", + 'p.accountancy_code_sell_export' => "", + 'p.accountancy_code_buy' => "", + 'p.weight' => "", + 'p.weight_units' => 'kg', // Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.length' => "", + 'p.length_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.width' => "", + 'p.width_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.height' => "", + 'p.height_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.surface' => "", + 'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.volume' => "", + 'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units', + 'p.finished' => '0 (raw material) / 1 (finished goods)' + ); + //clauses copied from import_fields_array + if (!empty($conf->stock->enabled)) $import_sample = array_merge($import_sample, array( + 'p.seuil_stock_alerte' => '', + 'p.pmp' => '0', + 'p.desiredstock' => '' + )); + if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample=array_merge($import_sample, array('p.cost_price'=>'90')); + if (is_object($mysoc) && $mysoc->useNPR()) $import_sample=array_merge($import_sample, array('p.recuperableonly'=>'0')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample=array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>'')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample=array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>'')); + if (! empty($conf->barcode->enabled)) $import_sample=array_merge($import_sample, array('p.barcode'=>'')); + if (! empty($conf->global->PRODUCT_USE_UNITS)) { + $import_sample = array_merge( + $import_sample, + array( + 'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "' . MAIN_DB_PREFIX . 'c_units"' + ) + ); + + $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array( + 'p.fk_unit' => array( + 'rule' => 'fetchidfromcodeorlabel', + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'dict' => 'DictionaryUnits' + ) + )); + } $this->import_examplevalues_array[$r]=array_merge($import_sample, $import_extrafield_sample); $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref'); if (! empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r]=array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode'));//only show/allow barcode as update key if Barcode module enabled @@ -445,12 +588,39 @@ class modService extends DolibarrModules 'sp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product') ); $this->import_examplevalues_array[$r]=array( - 'sp.fk_product'=>"SERVICE_REF or id:123456", - 'sp.fk_soc'=>"My Supplier",'sp.ref_fourn'=>"SupplierRef", 'sp.quantity'=>"1", 'sp.tva_tx'=>'21', - 'sp.price'=>"50", - 'sp.unitprice'=>'50', - 'sp.remise_percent'=>'0' + 'sp.fk_product' => "PRODUCT_REF or id:123456", + 'sp.fk_soc' => "My Supplier", + 'sp.ref_fourn' => "XYZ-F123456", + 'sp.quantity' => "5", + 'sp.tva_tx' => '10', + 'sp.price'=>"50", + 'sp.unitprice'=>'50', + 'sp.remise_percent'=>'0', + 'sp.default_vat_code' => '', + 'sp.delivery_time_days' => '5', + 'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER' ); + if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>'')); + if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); + if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); + $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array( + 'sp.price' => "50.00", + 'sp.unitprice' => '10', + // TODO Make this field not required and calculate it from price and qty + 'sp.remise_percent' => '20' + )); + if ($conf->multicurrency->enabled) + { + $this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array( + 'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency', + 'sp.multicurrency_code'=>'GBP', + 'sp.multicurrency_tx'=>'1.12345', + 'sp.multicurrency_unitprice'=>'', + // TODO Make this field not required and calculate it from price and qty + 'sp.multicurrency_price'=>'' + )); + } + $this->import_updatekeys_array[$r]=array('sp.fk_product'=>'ProductOrService','sp.ref_fourn'=>'SupplierRef','sp.fk_soc'=>'Supplier'); } diff --git a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php index f8c02cc95f8..741c9e314b4 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php @@ -206,17 +206,20 @@ class modGeneratePassPerso extends ModeleGenPassword } /** - * check the consecutive iterations of the same character. Return false if the number doesn't match the maximum consecutive value allowed. + * Check the consecutive iterations of the same character. Return false if the number doesn't match the maximum consecutive value allowed. * * @param string $password Password to check - * * @return bool */ private function consecutiveInterationSameCharacter($password) { $last = ""; + + if (empty($this->NbRepeat)) return 1; + $count = 0; $char = str_split($password); + foreach($char as $c) { if($c != $last) { $last = $c; diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index d8ac6e752f9..d0f9b3d1c84 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -96,7 +96,6 @@ $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); // fetch optionals attributes lines and labels $extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line); - // Load object. Make an object->fetch include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once @@ -1570,10 +1569,10 @@ if ($action == 'create') } } - //Display lines extrafields if (is_array($extralabelslines) && count($extralabelslines)>0) { + //var_dump($line); $colspan=5; $orderLineExtrafields = new Extrafields($db); $orderLineExtrafieldLabels = $orderLineExtrafields->fetch_name_optionals_label($object->table_element_line); @@ -1583,7 +1582,7 @@ if ($action == 'create') //$line->fetch_optionals($line->id); $line->array_options = array_merge($line->array_options, $srcLine->array_options); print ''; - print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan), $indiceAsked); + print $line->showOptionals($extrafieldsline, 'edit', array('colspan'=>$colspan), $indiceAsked); print ''; } } @@ -1841,8 +1840,8 @@ elseif ($id || $ref) print ''; print ''; print ''; - print ''; - print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units); + print ''; + print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); print ' '; print ' '; print '
'; @@ -1850,7 +1849,7 @@ elseif ($id || $ref) else { print $object->trueWeight; - print ($object->trueWeight && $object->weight_units!='')?' '.measuring_units_string($object->weight_units, "weight"):''; + print ($object->trueWeight && $object->weight_units!='')?' '.measuring_units_string(0, "weight", $object->weight_units):''; } // Calculated @@ -1867,7 +1866,7 @@ elseif ($id || $ref) // Width print ''.$form->editfieldkey("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer).''; print $form->editfieldval("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer); - print ($object->trueWidth && $object->width_units!='')?' '.measuring_units_string($object->width_units, "size"):''; + print ($object->trueWidth && $object->width_units!='')?' '.measuring_units_string(0, "size", $object->width_units):''; print ''; // Height @@ -1878,8 +1877,8 @@ elseif ($id || $ref) print ''; print ''; print ''; - print ''; - print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units); + print ''; + print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units, 0, 2); print ' '; print ' '; print ''; @@ -1887,7 +1886,7 @@ elseif ($id || $ref) else { print $object->trueHeight; - print ($object->trueHeight && $object->height_units!='')?' '.measuring_units_string($object->height_units, "size"):''; + print ($object->trueHeight && $object->height_units!='')?' '.measuring_units_string(0, "size", $object->height_units):''; } print ''; @@ -1895,7 +1894,7 @@ elseif ($id || $ref) // Depth print ''.$form->editfieldkey("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer).''; print $form->editfieldval("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer); - print ($object->trueDepth && $object->depth_units!='')?' '.measuring_units_string($object->depth_units, "size"):''; + print ($object->trueDepth && $object->depth_units!='')?' '.measuring_units_string(0, "size", $object->depth_units):''; print ''; // Volume @@ -2101,8 +2100,6 @@ elseif ($id || $ref) } print "\n"; - $var=false; - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $object->fetch_thirdparty(); @@ -2407,14 +2404,14 @@ elseif ($id || $ref) } // Weight - print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->weight_units, "weight"); + print ''; + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->weight*$lines[$i]->qty_shipped.' '.measuring_units_string(0, "weight", $lines[$i]->weight_units); else print ' '; print ''; // Volume - print ''; - if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string($lines[$i]->volume_units, "volume"); + print ''; + if ($lines[$i]->fk_product_type == Product::TYPE_PRODUCT) print $lines[$i]->volume*$lines[$i]->qty_shipped.' '.measuring_units_string(0, "volume", $lines[$i]->volume_units); else print ' '; print ''; diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index 30c2a3d4038..8ad19e06695 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -86,6 +86,10 @@ InvoiceDeleted=Invoice deleted PRODUCT_CREATEInDolibarr=Product %s created PRODUCT_MODIFYInDolibarr=Product %s modified PRODUCT_DELETEInDolibarr=Product %s deleted +HOLIDAY_CREATEInDolibarr=Request for leave %s created +HOLIDAY_MODIFYInDolibarr=Request for leave %s modified +HOLIDAY_VALIDATEDInDolibarr=Request for leave %s validated +HOLIDAY_DELETEInDolibarr=Request for leave %s deleted EXPENSE_REPORT_CREATEInDolibarr=Expense report %s created EXPENSE_REPORT_VALIDATEInDolibarr=Expense report %s validated EXPENSE_REPORT_APPROVEInDolibarr=Expense report %s approved diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index d06d38ad390..4a9b613bcd5 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -588,27 +588,27 @@ print ''; print "\n"; print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''.$langs->trans("Project").''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''.$langs->trans("ThirdParty").''; -print ''.$langs->trans("Task").''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''.$langs->trans("Project").''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''.$langs->trans("ThirdParty").''; +print ''.$langs->trans("Task").''; // TASK fields $extrafieldsobjectkey='projet_task'; $extrafieldsobjectprefix='efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; if (! empty($arrayfields['t.planned_workload']['checked'])) { - print ''.$langs->trans("PlannedWorkload").''; + print ''.$langs->trans("PlannedWorkload").''; } if (! empty($arrayfields['t.progress']['checked'])) { - print ''.$langs->trans("ProgressDeclared").''; + print ''.$langs->trans("ProgressDeclared").''; } /*print ''.$langs->trans("TimeSpent").''; if ($usertoprocess->id == $user->id) print ''.$langs->trans("TimeSpentByYou").''; else print ''.$langs->trans("TimeSpentByUser").'';*/ -print ''.$langs->trans("TimeSpent").'
('.$langs->trans("Everybody").')'; -print ''.$langs->trans("TimeSpent").($usertoprocess->firstname?'
('.dol_trunc($usertoprocess->firstname, 10).')':'').''; -print ''.$langs->trans("HourStart").''; +print ''.$langs->trans("TimeSpent").'
('.$langs->trans("Everybody").')'; +print ''.$langs->trans("TimeSpent").($usertoprocess->firstname?'
('.dol_trunc($usertoprocess->firstname, 10).')':'').''; +print ''.$langs->trans("HourStart").''; // By default, we can edit only tasks we are assigned to $restrictviewformytask=((! isset($conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED)) ? 2 : $conf->global->PROJECT_TIME_SHOW_TASK_NOT_ASSIGNED); @@ -645,8 +645,8 @@ if (! $isavailable[$daytoparse]['morning'] && ! $isavailable[$daytoparse]['after elseif (! $isavailable[$daytoparse]['morning']) $cssonholiday.='onholidaymorning '; elseif (! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayafternoon '; -print ''.$langs->trans("Duration").''; -print ''.$langs->trans("Note").''; +print ''.$langs->trans("Duration").''; +print ''.$langs->trans("Note").''; //print ''; print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); diff --git a/htdocs/projet/activity/perweek.php b/htdocs/projet/activity/perweek.php index 4c4f1844be3..280c9944d9f 100644 --- a/htdocs/projet/activity/perweek.php +++ b/htdocs/projet/activity/perweek.php @@ -640,26 +640,26 @@ print ''; print "\n"; print ''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''.$langs->trans("Project").''; -if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''.$langs->trans("ThirdParty").''; -print ''.$langs->trans("Task").''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''.$langs->trans("Project").''; +if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print ''.$langs->trans("ThirdParty").''; +print ''.$langs->trans("Task").''; // TASK fields $extrafieldsobjectkey='projet_task'; $extrafieldsobjectprefix='efpt.'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; if (! empty($arrayfields['t.planned_workload']['checked'])) { - print ''.$langs->trans("PlannedWorkload").''; + print ''.$langs->trans("PlannedWorkload").''; } if (! empty($arrayfields['t.progress']['checked'])) { - print ''.$langs->trans("ProgressDeclared").''; + print ''.$langs->trans("ProgressDeclared").''; } /*print ''.$langs->trans("TimeSpent").''; if ($usertoprocess->id == $user->id) print ''.$langs->trans("TimeSpentByYou").''; else print ''.$langs->trans("TimeSpentByUser").'';*/ -print ''.$langs->trans("TimeSpent").'
('.$langs->trans("Everybody").')'; -print ''.$langs->trans("TimeSpent").($usertoprocess->firstname?'
('.dol_trunc($usertoprocess->firstname, 10).')':'').''; +print ''.$langs->trans("TimeSpent").'
('.$langs->trans("Everybody").')'; +print ''.$langs->trans("TimeSpent").($usertoprocess->firstname?'
('.dol_trunc($usertoprocess->firstname, 10).')':'').''; for ($idw=0; $idw<7; $idw++) { @@ -679,7 +679,7 @@ for ($idw=0; $idw<7; $idw++) elseif (! $isavailable[$tmpday]['morning']) $cssonholiday.='onholidaymorning '; elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; - print ''.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'
'.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').''; + print ''.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'
'.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').''; } //print ''; print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); diff --git a/htdocs/public/ticket/list.php b/htdocs/public/ticket/list.php index 5e1ce07e098..078fe46b7ac 100644 --- a/htdocs/public/ticket/list.php +++ b/htdocs/public/ticket/list.php @@ -37,6 +37,7 @@ if (!defined("NOLOGIN")) { require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -95,7 +96,8 @@ if ($action == "view_ticketlist") { $ret = $object->fetch('', '', $track_id); if ($ret && $object->id > 0) { - // vérifie si l'adresse email est bien dans les contacts du ticket + + // vérifie si l'adresse email est bien dans les contacts du ticket $contacts = $object->liste_contact(-1, 'external'); foreach ($contacts as $contact) { if ($contact['email'] == $email) { @@ -124,7 +126,9 @@ if ($action == "view_ticketlist") { $_SESSION['track_id_customer'] = $track_id; } } - if ($email == $object->origin_email) { + + $emailorigin = CMailFile::getValidAddress($object->origin_email, 2); + if ($email == $emailorigin) { $display_ticket_list = true; $_SESSION['email_customer'] = $email; $_SESSION['track_id_customer'] = $track_id; @@ -638,7 +642,7 @@ if ($action == "view_ticketlist") // Statut if (!empty($arrayfields['t.fk_statut']['checked'])) { - print ''; + print ''; $object->fk_statut = $obj->fk_statut; print $object->getLibStatut(2); print ''; diff --git a/htdocs/public/ticket/view.php b/htdocs/public/ticket/view.php index cdbd3abad19..47dc038120f 100644 --- a/htdocs/public/ticket/view.php +++ b/htdocs/public/ticket/view.php @@ -38,6 +38,7 @@ if (!defined("NOLOGIN")) { require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formticket.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ticket.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -100,7 +101,8 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a $ret = $object->fetch('', '', $track_id); if ($ret && $object->dao->id > 0) { // Check if emails provided is the one of author - if ($object->dao->origin_email == $email) + $emailofticket = CMailFile::getValidAddress($object->dao->origin_email, 2); + if ($emailofticket == $email) { $display_ticket = true; $_SESSION['email_customer'] = $email; @@ -174,7 +176,6 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a - if (! $error) { $action = 'view_ticket'; @@ -226,7 +227,8 @@ llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss); print '
'; if ($action == "view_ticket" || $action == "presend" || $action == "close" || $action == "confirm_public_close") { - if ($display_ticket) { + if ($display_ticket) + { // Confirmation close if ($action == 'close') { print $form->formconfirm($_SERVER["PHP_SELF"] . "?track_id=" . $track_id, $langs->trans("CloseATicket"), $langs->trans("ConfirmCloseAticket"), "confirm_public_close", '', '', 1); @@ -284,7 +286,7 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a $fuser->fetch($object->dao->fk_user_create); print $fuser->getFullName($langs); } else { - print $object->dao->origin_email; + print dol_escape_htmltag($object->dao->origin_email); } print ''; @@ -370,7 +372,9 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a // Message list print load_fiche_titre($langs->trans('TicketMessagesList'), '', 'messages@ticket'); $object->viewTicketMessages(false, true, $object->dao); - } else { + } + else + { print '
Not Allowed
' . $langs->trans('Back') . '
'; } } else { diff --git a/htdocs/societe/project.php b/htdocs/societe/project.php index 0a345fc6369..dd6c4b46cdf 100644 --- a/htdocs/societe/project.php +++ b/htdocs/societe/project.php @@ -119,25 +119,7 @@ if ($socid) dol_fiche_end(); - /* - * Barre d'action - */ - - /*print '
'; - - if (! empty($conf->projet->enabled)) - { - if (! empty($conf->projet->enabled) && ! empty($user->rights->projet->creer)) - {*/ - $addbutton = ''.$langs->trans("AddProject").''; - /* } - else - { - print ''.$langs->trans("AddProject").''; - } - } - - print '
'; */ + $addbutton = ''.$langs->trans("AddProject").''; print '
'; diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index eb47bc7044f..2f3a79c59be 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -371,7 +371,7 @@ if ($action == "assign_user" && GETPOST('btn_assign_user', 'aplha') && $user->ri $action = 'view'; } -if ($action == "add_message" && GETPOST('btn_add_message') && $user->rights->ticket->read) { +if ($action == 'add_message' && GETPOSTISSET('btn_add_message') && $user->rights->ticket->read) { $ret = $object->newMessage($user, $action, (GETPOST('private_message', 'alpha') == "on" ? 1 : 0)); if ($ret > 0) { @@ -769,7 +769,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd } if (!empty($object->origin_email)) { $morehtmlref .= '
' . $langs->trans("CreatedBy") . ' : '; - $morehtmlref .= $object->origin_email . ' (' . $langs->trans("TicketEmailOriginIssuer") . ')'; + $morehtmlref .= dol_escape_htmltag($object->origin_email) . ' (' . $langs->trans("TicketEmailOriginIssuer") . ')'; } // Thirdparty @@ -1290,10 +1290,8 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd //$formticket->param['socid']=$object->fk_soc; $formticket->param['returnurl']=$_SERVER["PHP_SELF"].'?track_id='.$object->track_id; - $formticket->withsubstit = 1; $formticket->substit = $substitutionarray; - $formticket->showMessageForm('100%'); print '
'; } diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 1ae0bb56aae..cdf2c14a500 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -1602,13 +1602,16 @@ class Ticket extends CommonObject } /** - * Add message into database + * Add message into database * - * @param User $user User that creates - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK + * @param User $user User that creates + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @param array $filename_list List of files to attach (full path of filename on file system) + * @param array $mimetype_list List of MIME type of attached files + * @param array $mimefilename_list List of attached file name in message + * @return void */ - public function createTicketMessage($user, $notrigger = 0) + public function createTicketMessage($user, $notrigger = 0, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array()) { global $conf, $langs; $error = 0; @@ -1633,7 +1636,7 @@ class Ticket extends CommonObject $actioncomm->code = 'TICKET_MSG'; $actioncomm->socid = $this->socid; $actioncomm->label = $this->subject; - $actioncomm->note = $this->message; + $actioncomm->note_private = $this->message; $actioncomm->userassigned = array($user->id); $actioncomm->userownerid = $user->id; $actioncomm->datep = $now; @@ -1641,6 +1644,19 @@ class Ticket extends CommonObject $actioncomm->elementtype = 'ticket'; $actioncomm->fk_element = $this->id; + $attachedfiles = array(); + $attachedfiles['paths'] = $filename_list; + $attachedfiles['names'] = $mimefilename_list; + $attachedfiles['mimes'] = $mimetype_list; + if (is_array($attachedfiles) && count($attachedfiles)>0) { + $actioncomm->attachedfiles = $attachedfiles; + } + + if (! empty($mimefilename_list) && is_array($mimefilename_list)) + { + $actioncomm->note_private=dol_concatdesc($actioncomm->note_private, "\n".$langs->transnoentities("AttachedFiles").': '.join(';', $mimefilename_list)); + } + $actionid = $actioncomm->create($user); if ($actionid <= 0) { @@ -2389,10 +2405,11 @@ class Ticket extends CommonObject /** - * Copy files into ticket directory - * Used for files linked into messages + * Copy files defined into $_SESSION array into the ticket directory of attached files. + * Used for files linked into messages. + * Files may be renamed during copy to avoid overwriting existing files. * - * @return void + * @return array Array with final path/name/mime of files. */ public function copyFilesForTicket() { @@ -2422,23 +2439,42 @@ class Ticket extends CommonObject if (!dol_is_dir($destdir)) { dol_mkdir($destdir); } + + $listofpaths = array(); + $listofnames = array(); foreach ($filename as $i => $val) { - $res = dol_move($filepath[$i], $destdir . '/' . $filename[$i]); - if (image_format_supported($destdir . '/' . $filename[$i]) == 1) { + $destfile = $destdir . '/' . $filename[$i]; + // If destination file already exists, we add a suffix to avoid to overwrite + if (is_file($destfile)) + { + $now = dol_now(); + $destfile.='.'.dol_print_date($now, 'dayhourlog'); + } + + $res = dol_move($filepath[$i], $destfile, 0, 1); + + if (image_format_supported($destfile) == 1) { // Create small thumbs for image (Ratio is near 16/9) // Used on logon for example - $imgThumbSmall = vignette($destdir . '/' . $filename[$i], $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); + $imgThumbSmall = vignette($destfile, $maxwidthsmall, $maxheightsmall, '_small', 50, "thumbs"); // Create mini thumbs for image (Ratio is near 16/9) // Used on menu or for setup page for example - $imgThumbMini = vignette($destdir . '/' . $filename[$i], $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); + $imgThumbMini = vignette($destfile, $maxwidthmini, $maxheightmini, '_mini', 50, "thumbs"); } + $formmail->remove_attached_files($i); + + // Fill array with new names + $listofpaths[$i] = $destfile; + $listofnames[$i] = basename($destfile); } + + return array('listofpaths'=>$listofpaths, 'listofnames'=>$listofnames, 'listofmimes'=>$mimetype); } /** - * Add new message on a ticket (private area) + * Add new message on a ticket (private area). Can also send it be email if GETPOST('send_email', 'int') is set. * * @param User $user User for action * @param string $action Action string @@ -2449,19 +2485,15 @@ class Ticket extends CommonObject { global $mysoc, $conf, $langs; - if (!class_exists('Contact')) { - include_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; - } - - $contactstatic = new Contact($this->db); - $object = new Ticket($this->db); - $error = 0; + $object = new Ticket($this->db); + $ret = $object->fetch('', '', GETPOST('track_id', 'alpha')); $object->socid = $object->fk_soc; $object->fetch_thirdparty(); + if ($ret < 0) { $error++; array_push($this->errors, $langs->trans("ErrorTicketIsNotValid")); @@ -2478,9 +2510,17 @@ class Ticket extends CommonObject $object->subject = GETPOST('subject', 'alphanohtml'); $object->message = GETPOST("message", "none"); $object->private = GETPOST("private_message", "alpha"); + $send_email = GETPOST('send_email', 'int'); - $id = $object->createTicketMessage($user); + // Copy attached files (saved into $_SESSION) as linked files to ticket. Return array with final name used. + $resarray = $object->copyFilesForTicket(); + + $listofpaths = $resarray['listofpaths']; + $listofnames = $resarray['listofnames']; + $listofmimes = $resarray['listofmimes']; + + $id = $object->createTicketMessage($user, 0, $listofpaths, $listofmimes, $listofnames); if ($id <= 0) { $error++; $this->errors = $object->error; @@ -2491,24 +2531,27 @@ class Ticket extends CommonObject if (!$error && $id > 0) { setEventMessages($langs->trans('TicketMessageSuccessfullyAdded'), null, 'mesgs'); + //var_dump($_SESSION); var_dump($listofpaths);exit; + /* - * Send email to linked contacts + * Send emails to internal users (linked contacts) */ if ($send_email > 0) { // Retrieve internal contact datas $internal_contacts = $object->getInfosTicketInternalContact(); + $sendto = array(); if (is_array($internal_contacts) && count($internal_contacts) > 0) { // altairis: set default subject $label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE; - $subject = GETPOST('subject') ? GETPOST('subject') : '[' . $label_title . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage'); + $subject = GETPOST('subject', 'nohtml') ? GETPOST('subject', 'nohtml') : '[' . $label_title . '- ticket #' . $object->track_id . '] ' . $langs->trans('TicketNewMessage'); $message_intro = $langs->trans('TicketNotificationEmailBody', "#" . $object->id); $message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE; $message = $langs->trans('TicketMessageMailIntroText'); $message .= "\n\n"; - $message .= GETPOST('message'); + $message .= GETPOST('message', 'restricthtml'); // Coordonnées client $message .= "\n\n"; @@ -2547,12 +2590,12 @@ class Ticket extends CommonObject // altairis: dont try to send email if no recipient if (!empty($sendto)) { - $this->sendTicketMessageByEmail($subject, $message, '', $sendto); + $this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames); } } /* - * Email for externals users if not private + * Send emails for externals users if not private (linked contacts) */ if (empty($object->private)) { // Retrieve email of all contacts (external) @@ -2599,47 +2642,42 @@ class Ticket extends CommonObject // If public interface is not enable, use link to internal page into mail $url_public_ticket = (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) ? - (!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? - $conf->global->TICKET_URL_PUBLIC_INTERFACE . '/view.php' : - dol_buildpath('/public/ticket/view.php', 2) - ) : - dol_buildpath('/ticket/card.php', 2) - ) . '?track_id=' . $object->track_id; - $message .= "\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . '' . $object->track_id . '' . "\n"; + (!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? $conf->global->TICKET_URL_PUBLIC_INTERFACE . '/view.php' : dol_buildpath('/public/ticket/view.php', 2)) : + dol_buildpath('/ticket/card.php', 2)) . '?track_id=' . $object->track_id; + $message .= "\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . '' . $object->track_id . '' . "\n"; - // Build final message - $message = $message_intro . $message; + // Build final message + $message = $message_intro . $message; - // Add signature - $message .= '
' . $message_signature; + // Add signature + $message .= '
' . $message_signature; - if (!empty($object->origin_email)) { - $sendto[] = $object->origin_email; - } + if (!empty($object->origin_email)) { + $sendto[] = $object->origin_email; + } - if ($object->fk_soc > 0 && ! in_array($object->origin_email, $sendto)) { - $object->socid = $object->fk_soc; - $object->fetch_thirdparty(); - if(!empty($object->thirdparty->email)) $sendto[] = $object->thirdparty->email; - } + if ($object->fk_soc > 0 && ! in_array($object->origin_email, $sendto)) { + $object->socid = $object->fk_soc; + $object->fetch_thirdparty(); + if(!empty($object->thirdparty->email)) $sendto[] = $object->thirdparty->email; + } - // altairis: Add global email address reciepient - if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) { - if(!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO; - } + // altairis: Add global email address reciepient + if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) { + if(!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO; + } - // altairis: dont try to send email when no recipient - if (!empty($sendto)) { - $this->sendTicketMessageByEmail($subject, $message, '', $sendto); - } + // altairis: dont try to send email when no recipient + if (!empty($sendto)) { + $this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames); + } } } } - $object->copyFilesForTicket(); - - // Set status to "answered" if not set yet, only for internal users - if ($object->fk_statut < 3 && !$user->societe_id) { + // Set status to "answered" if not set yet, but only if internal user + if ($object->fk_statut < 3 && ! $user->socid) + { $object->setStatut(3); } @@ -2658,13 +2696,16 @@ class Ticket extends CommonObject /** * Send ticket by email to linked contacts * - * @param string $subject Email subject - * @param string $message Email message - * @param int $send_internal_cc Receive a copy on internal email ($conf->global->TICKET_NOTIFICATION_EMAIL_FROM) - * @param array $array_receiver Array of receiver. exemple array('name' => 'John Doe', 'email' => 'john@doe.com', etc...) + * @param string $subject Email subject + * @param string $message Email message + * @param int $send_internal_cc Receive a copy on internal email ($conf->global->TICKET_NOTIFICATION_EMAIL_FROM) + * @param array $array_receiver Array of receiver. exemple array('name' => 'John Doe', 'email' => 'john@doe.com', etc...) + * @param array $filename_list List of files to attach (full path of filename on file system) + * @param array $mimetype_list List of MIME type of attached files + * @param array $mimefilename_list List of attached file name in message * @return void */ - public function sendTicketMessageByEmail($subject, $message, $send_internal_cc = 0, $array_receiver = array()) + public function sendTicketMessageByEmail($subject, $message, $send_internal_cc = 0, $array_receiver = array(), $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array()) { global $conf, $langs; @@ -2690,15 +2731,12 @@ class Ticket extends CommonObject $from = $conf->global->TICKET_NOTIFICATION_EMAIL_FROM; if (is_array($array_receiver) && count($array_receiver) > 0) { - foreach ($array_receiver as $key => $receiver) { - // Create form object - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; - $formmail = new FormMail($this->db); - - $attachedfiles = $formmail->get_attached_files(); - $filepath = $attachedfiles['paths']; - $filename = $attachedfiles['names']; - $mimetype = $attachedfiles['mimes']; + foreach ($array_receiver as $key => $receiver) + { + $deliveryreceipt = 0; + $filepath = $filename_list; + $filename = $mimefilename_list; + $mimetype = $mimetype_list; $message_to_send = dol_nl2br($message); diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index cc6d7a265e9..2bfc1719360 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -229,8 +229,8 @@ foreach($search as $key => $val) if ($key == 'fk_statut') { $tmpstatus=''; - if ($search['fk_statut'] == 'openall' || in_array('openall', $search['fk_statut'])) $tmpstatus.=($tmpstatus?',':'')."'0', '1', '3', '4', '5', '6'"; - if ($search['fk_statut'] == 'closeall' || in_array('closeall', $search['fk_statut'])) $tmpstatus.=($tmpstatus?',':'')."'8', '9'"; + if ($search['fk_statut'] == 'openall' || in_array('openall', $search['fk_statut'])) $tmpstatus.=($tmpstatus?',':'')."'".Ticket::STATUS_NOT_READ."', '".Ticket::STATUS_READ."', '".Ticket::STATUS_ASSIGNED."', '".Ticket::STATUS_IN_PROGRESS."', '".Ticket::STATUS_NEED_MORE_INFO."', '".Ticket::STATUS_WAITING."'"; + if ($search['fk_statut'] == 'closeall' || in_array('closeall', $search['fk_statut'])) $tmpstatus.=($tmpstatus?',':'')."'".Ticket::STATUS_CLOSED."', '".Ticket::STATUS_CANCELED."'"; if ($tmpstatus) $sql.=" AND fk_statut IN (".$tmpstatus.")"; elseif (is_array($search[$key]) && count($search[$key])) $sql.=natural_search($key, join(',', $search[$key]), 2); continue; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index d89e1308612..8e0a9d956cb 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1293,8 +1293,8 @@ class User extends CommonObject $this->db->begin(); - // Cree et positionne $this->id - $result=$this->create($user); + // Create user and set $this->id. Trigger is disabled because executed later. + $result=$this->create($user, 1); if ($result > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."user"; diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php index 1610210e473..20b0aee410f 100644 --- a/htdocs/user/group/card.php +++ b/htdocs/user/group/card.php @@ -362,7 +362,7 @@ else print '
'; print '
'; - print ''; + print '
'; // Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner) if (! empty($conf->mutlicompany->enabled)) diff --git a/htdocs/user/group/perms.php b/htdocs/user/group/perms.php index f4fae8160c4..e80d75e6c0e 100644 --- a/htdocs/user/group/perms.php +++ b/htdocs/user/group/perms.php @@ -201,7 +201,7 @@ if ($object->id > 0) * Ecran ajout/suppression permission */ - print '
'; + print '
'; // Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner) if (! empty($conf->mutlicompany->enabled))