Merge branch '10.0' into hotfix/12041-security-generate-password

This commit is contained in:
Laurent Destailleur 2019-10-07 20:22:19 +02:00 committed by GitHub
commit 156eb7fa61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 608 additions and 431 deletions

View File

@ -174,15 +174,15 @@ if ($action == 'maj_pattern')
$explodePattern = explode(';', $pattern); $explodePattern = explode(';', $pattern);
$patternInError = false; $patternInError = false;
if($explodePattern[0] < 1){ if ($explodePattern[0] < 1 || $explodePattern[4] < 0) {
$patternInError = true; $patternInError = true;
} }
if($explodePattern[0] < $explodePattern[1] + $explodePattern[2] + $explodePattern[3]){ if ($explodePattern[0] < $explodePattern[1] + $explodePattern[2] + $explodePattern[3]) {
$patternInError = true; $patternInError = true;
} }
if(!$patternInError){ if (!$patternInError) {
dolibarr_set_const($db, "USER_PASSWORD_PATTERN", $pattern, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "USER_PASSWORD_PATTERN", $pattern, 'chaine', 0, '', $conf->entity);
header("Location: security.php"); header("Location: security.php");
exit; exit;

View File

@ -160,7 +160,6 @@ print '<ul>';
print '<li><a href="https://facebook.com/dolibarr" target="_blank" rel="external">FaceBook</a></li>'; print '<li><a href="https://facebook.com/dolibarr" target="_blank" rel="external">FaceBook</a></li>';
print '<li><a href="https://twitter.com/dolibarr" target="_blank" rel="external">Twitter</a></li>'; print '<li><a href="https://twitter.com/dolibarr" target="_blank" rel="external">Twitter</a></li>';
print '<li><a href="https://plus.google.com/+DolibarrOrg" target="_blank" rel="external">Google Plus page</a></li>';
print '</ul>'; print '</ul>';

View File

@ -42,6 +42,12 @@ $label = GETPOST('label', 'alpha');
$scandir = GETPOST('scandir', 'alpha'); $scandir = GETPOST('scandir', 'alpha');
$type = 'ticket'; $type = 'ticket';
$error = 0;
/*
* Actions
*/
if ($action == 'updateMask') { if ($action == 'updateMask') {
$maskconstticket = GETPOST('maskconstticket', 'alpha'); $maskconstticket = GETPOST('maskconstticket', 'alpha');
$maskticket = GETPOST('maskticket', 'alpha'); $maskticket = GETPOST('maskticket', 'alpha');
@ -91,7 +97,7 @@ if ($action == 'updateMask') {
$error++; $error++;
} }
$mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'alpha'); $mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'restricthtml');
if (!empty($mail_intro)) { if (!empty($mail_intro)) {
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity);
} else { } else {
@ -101,7 +107,7 @@ if ($action == 'updateMask') {
$error++; $error++;
} }
$mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'alpha'); $mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'restricthtml');
if (!empty($mail_signature)) { if (!empty($mail_signature)) {
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, '', $conf->entity);
} else { } else {
@ -110,16 +116,6 @@ if ($action == 'updateMask') {
if (!$res > 0) { if (!$res > 0) {
$error++; $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') { if ($action == 'setvarother') {

View File

@ -42,6 +42,12 @@ $label = GETPOST('label', 'alpha');
$scandir = GETPOST('scandir', 'alpha'); $scandir = GETPOST('scandir', 'alpha');
$type = 'ticket'; $type = 'ticket';
$error = 0;
/*
* Actions
*/
if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE')
{ {
if (GETPOST('value')) dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 1, 'chaine', 0, '', $conf->entity); 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') { if ($action == 'setvar') {
include_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"; include_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php";
$notification_email = GETPOST('TICKET_NOTIFICATION_EMAIL_FROM', 'alpha'); $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'nohtml');
if (!empty($notification_email)) { if (!empty($topic_interface)) {
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity);
} else { } 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) { if (!$res > 0) {
$error++; $error++;
} }
// altairis : differentiate notification email FROM and TO $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'restricthtml');
$notification_email_to = GETPOST('TICKET_NOTIFICATION_EMAIL_TO', 'alpha'); if (!empty($text_home)) {
if (!empty($notification_email_to)) { $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity);
$res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, '', $conf->entity);
} else { } 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) { 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)) { 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 { } 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) { if (!$res > 0) {
$error++; $error++;
}
$mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'alpha');
if (!empty($mail_intro)) {
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity);
} else {
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $langs->trans('TicketMessageMailIntroText'), 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
}
$mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'alpha');
if (!empty($mail_signature)) {
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, '', $conf->entity);
} else {
$res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $langs->trans('TicketMessageMailSignatureText'), 'chaine', 0, '', $conf->entity);
}
if (!$res > 0) {
$error++;
} }
$url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha'); $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha');
if (!empty($url_interface)) { 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 { } 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) { if (!$res > 0) {
$error++; $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++;
} }
} }
@ -162,14 +127,11 @@ if ($action == 'setvarother') {
$error++; $error++;
} }
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) $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);
$param_show_module_logo = GETPOST('TICKET_SHOW_MODULE_LOGO', 'alpha'); if (!$res > 0) {
$res = dolibarr_set_const($db, 'TICKET_SHOW_MODULE_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity); $error++;
if (!$res > 0) { }
$error++;
}
}
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
{ {
@ -179,12 +141,6 @@ if ($action == 'setvarother') {
$error++; $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 '<br><br>';
if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE))
{ {
if (empty($conf->use_javascript_ajax)) {
if (!$conf->use_javascript_ajax) {
print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" enctype="multipart/form-data" >'; print '<form method="post" action="' . $_SERVER['PHP_SELF'] . '" enctype="multipart/form-data" >';
print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
print '<input type="hidden" name="action" value="setvarother">'; print '<input type="hidden" name="action" value="setvarother">';
@ -349,16 +304,6 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE))
print "</tr>\n"; print "</tr>\n";
} }
// Url public interface
$url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE;
print '<tr><td>' . $langs->trans("TicketUrlPublicInterfaceLabelAdmin") . '</label>';
print '</td><td>';
print '<input type="text" name="TICKET_URL_PUBLIC_INTERFACE" value="' . $conf->global->TICKET_URL_PUBLIC_INTERFACE . '" size="40" ></td>';
print '</td>';
print '<td align="center">';
print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help');
print '</td></tr>';
// Interface topic // Interface topic
$url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC; $url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC;
print '<tr><td>' . $langs->trans("TicketPublicInterfaceTopicLabelAdmin") . '</label>'; print '<tr><td>' . $langs->trans("TicketPublicInterfaceTopicLabelAdmin") . '</label>';
@ -420,6 +365,16 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE))
print $form->textwithpicto('', $langs->trans("TicketNewEmailBodyHelp"), 1, 'help'); print $form->textwithpicto('', $langs->trans("TicketNewEmailBodyHelp"), 1, 'help');
print '</td></tr>'; print '</td></tr>';
// Url public interface
$url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE;
print '<tr><td>' . $langs->trans("TicketUrlPublicInterfaceLabelAdmin") . '</label>';
print '</td><td>';
print '<input type="text" name="TICKET_URL_PUBLIC_INTERFACE" value="' . $conf->global->TICKET_URL_PUBLIC_INTERFACE . '" size="40" ></td>';
print '</td>';
print '<td align="center">';
print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help');
print '</td></tr>';
print '</table>'; print '</table>';
print '<div class="center"><input type="submit" class="button" value="' . $langs->trans("Save") . '"></div>'; print '<div class="center"><input type="submit" class="button" value="' . $langs->trans("Save") . '"></div>';

View File

@ -172,6 +172,7 @@ class CUnits // extends CommonObject
$sql.= " t.code,"; $sql.= " t.code,";
$sql.= " t.label,"; $sql.= " t.label,";
$sql.= " t.short_label,"; $sql.= " t.short_label,";
$sql.= " t.scale,";
$sql.= " t.unit_type,"; $sql.= " t.unit_type,";
$sql.= " t.active"; $sql.= " t.active";
$sql.= " FROM ".MAIN_DB_PREFIX."c_units as t"; $sql.= " FROM ".MAIN_DB_PREFIX."c_units as t";
@ -195,6 +196,7 @@ class CUnits // extends CommonObject
$this->code = $obj->code; $this->code = $obj->code;
$this->label = $obj->label; $this->label = $obj->label;
$this->short_label = $obj->short_label; $this->short_label = $obj->short_label;
$this->scale = $obj->scale;
$this->unit_type = $obj->unit_type; $this->unit_type = $obj->unit_type;
$this->active = $obj->active; $this->active = $obj->active;
} }

View File

@ -212,7 +212,7 @@ class FormMail extends Form
/** /**
* Remove a file from the list of attached files (stored in SECTION array) * 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 * @return void
*/ */
public function remove_attached_files($keytodelete) public function remove_attached_files($keytodelete)

View File

@ -939,13 +939,13 @@ class FormTicket
if (is_array($contacts) && count($contacts) > 0) { if (is_array($contacts) && count($contacts) > 0) {
foreach ($contacts as $key => $info_sendto) { foreach ($contacts as $key => $info_sendto) {
if ($info_sendto['email'] != '') { 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'] . ">")." <small>(" . dol_escape_htmltag($info_sendto['libelle']) . ")</small>";
} }
} }
} }
if ($ticketstat->origin_email && !in_array($this->dao->origin_email, $sendto)) { if ($ticketstat->origin_email && !in_array($this->dao->origin_email, $sendto)) {
$sendto[] = $ticketstat->origin_email . "(origin)"; $sendto[] = dol_escape_htmltag($ticketstat->origin_email) . " <small>(".$langs->trans("TicketEmailOriginIssuer").")</small>";
} }
if ($ticketstat->fk_soc > 0) { if ($ticketstat->fk_soc > 0) {
@ -953,12 +953,12 @@ class FormTicket
$ticketstat->fetch_thirdparty(); $ticketstat->fetch_thirdparty();
if (is_array($ticketstat->thirdparty->email) && !in_array($ticketstat->thirdparty->email, $sendto)) { if (is_array($ticketstat->thirdparty->email) && !in_array($ticketstat->thirdparty->email, $sendto)) {
$sendto[] = $ticketstat->thirdparty->email . '(' . $langs->trans('Customer') . ')'; $sendto[] = $ticketstat->thirdparty->email . ' <small>(' . $langs->trans('Customer') . ')</small>';
} }
} }
if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS) { if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS) {
$sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO . '(generic email)'; $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO . ' <small>(generic email)</small>';
} }
// Print recipient list // Print recipient list

View File

@ -540,6 +540,9 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti
$out=dol_string_nohtmltag($out); $out=dol_string_nohtmltag($out);
} }
break; break;
case 'restricthtml': // Recommended for most html textarea
$out=dol_string_onlythesehtmltags($out, 0);
break;
case 'custom': case 'custom':
if (empty($filter)) return 'BadFourthParameterForGETPOST'; if (empty($filter)) return 'BadFourthParameterForGETPOST';
$out=filter_var($out, $filter, $options); $out=filter_var($out, $filter, $options);

View File

@ -125,12 +125,12 @@ function getValidOnlinePaymentMethods($paymentmethod = '')
*/ */
function showOnlinePaymentUrl($type, $ref) function showOnlinePaymentUrl($type, $ref)
{ {
global $conf, $langs; global $langs;
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('payment', 'paybox')); $langs->loadLangs(array('payment', 'paybox'));
$servicename='Online'; $servicename=$langs->transnoentitiesnoconv('Online');
$out = img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'<br>'; $out = img_picto('', 'object_globe.png').' '.$langs->trans("ToOfferALinkForOnlinePayment", $servicename).'<br>';
$url = getOnlinePaymentUrl(0, $type, $ref); $url = getOnlinePaymentUrl(0, $type, $ref);

View File

@ -489,7 +489,7 @@ class ImportCsv extends ModeleImports
{ {
if (empty($newval)) $newval='0'; 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']); $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']; $class=$objimport->array_import_convertvalue[0][$val]['class'];
@ -509,16 +509,17 @@ class ImportCsv extends ModeleImports
} }
$classinstance=new $class($this->db); $classinstance=new $class($this->db);
// Try the fetch from code or ref // Try the fetch from code or ref
call_user_func_array(array($classinstance, $method), array('', $units, $newval)); call_user_func_array(array($classinstance, $method), array('', '', $newval, $units));
$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code; $scaleorid = (($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits') ? $classinstance->id : $classinstance->scale);
//print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$scaleorid;
if ($classinstance->code != '') // id may be 0, it is a found value //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 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'; else $this->errors[$error]['lib']='ErrorFieldValueNotIn';
$this->errors[$error]['type']='FOREIGNKEY'; $this->errors[$error]['type']='FOREIGNKEY';
$errorforthistable++; $errorforthistable++;
@ -677,7 +678,7 @@ class ImportCsv extends ModeleImports
// Loop on each hidden fields to add them into listfields/listvalues // Loop on each hidden fields to add them into listfields/listvalues
foreach($objimport->array_import_fieldshidden[0] as $key => $val) 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') if ($val == 'user->id')
{ {
$listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key); $listfields[] = preg_replace('/^'.preg_quote($alias, '/').'\./', '', $key);

View File

@ -516,7 +516,7 @@ class ImportXlsx extends ModeleImports
{ {
if (empty($newval)) $newval='0'; 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']); $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']; $class=$objimport->array_import_convertvalue[0][$val]['class'];
@ -536,17 +536,18 @@ class ImportXlsx extends ModeleImports
} }
$classinstance=new $class($this->db); $classinstance=new $class($this->db);
// Try the fetch from code or ref // Try the fetch from code or ref
call_user_func_array(array($classinstance, $method), array('', $units, '', $newval)); call_user_func_array(array($classinstance, $method), array('', '', $newval, $units));
$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code; $scaleorid = (($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits') ? $classinstance->id : $classinstance->scale);
//print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$scaleorid;
if ($classinstance->code != '') // id may be 0, it is a found value //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 }
{ 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'; 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'; $this->errors[$error]['type']='FOREIGNKEY';
$errorforthistable++; $errorforthistable++;
$error++; $error++;
@ -668,8 +669,9 @@ class ImportXlsx extends ModeleImports
$errorforthistable++; $errorforthistable++;
$error++; $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]."<br>"; //if ($key == 19) print "xxx".$newval."zzz".$objimport->array_import_regex[0][$val]."<br>";
$this->errors[$error]['lib']=$langs->transnoentitiesnoconv('ErrorWrongValueForField', $key, $newval, $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'; $this->errors[$error]['type']='REGEX';
@ -778,7 +780,7 @@ class ImportXlsx extends ModeleImports
$error++; $error++;
} }
} else { } 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 // 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 // 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. // may already exists. So we rescan the extrafield table to know if record exists or not for the rowid.

View File

@ -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_label[$r]="Products"; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_permission[$r]=array(array("produit","export")); $this->export_permission[$r]=array(array("produit","export"));
$this->export_fields_array[$r]=array( $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.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",
'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode", 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.fk_product_type'=>'Type','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",
'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.width'=>"Width",'p.height'=>"Height",'p.surface'=>"Surface", 'p.description'=>"Description",'p.url'=>"PublicUrl",
'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode','p.price_base_type'=>"PriceBase",'p.price'=>"UnitPriceHT",'p.price_ttc'=>"UnitPriceTTC", 'p.customcode'=>'CustomCode','p.fk_country'=>'IDCountry',
'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell",'p.tobuy'=>"OnBuy",'p.datec'=>'DateCreation','p.tms'=>'DateModification' '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 (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->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->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'; $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; 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->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( $this->export_TypeFields_array[$r]=array(
'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"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.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.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.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->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->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( $this->export_fields_array[$r]=array(
'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl", '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'=>"ProductAccountancySellCode",'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode",
'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note", 'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode",'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",
'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume",'p.weight'=>"Weight",'p.customcode'=>'CustomCode', '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.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.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')); 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_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty','pa.incdec'=>'ComposedProductIncDecStock'));
$this->export_TypeFields_array[$r]=array( $this->export_TypeFields_array[$r]=array(
'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",'p.accountancy_code_sell'=>"Text", 'p.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",
'p.accountancy_code_sell_intra'=>"Text",'p.accountancy_code_sell_export'=>"Text",'p.accountancy_code_buy'=>"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.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.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.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_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_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_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.ref' => "Ref*",
'p.datec' => 'DateCreation',
'p.label' => "Label*", 'p.label' => "Label*",
'p.description' => "Description", 'p.fk_product_type' => "Type*",
'p.note_public' => "PublicNote",//public note 'p.tosell' => "OnSell*",
'p.note' => "PrivateNote",//private note 'p.tobuy' => "OnBuy*",
'p.customcode' => 'CustomCode', 'p.description' => "Description",
'p.price' => "SellingPriceHT",//without 'p.url' => "PublicUrl",
'p.price_min' => "MinPrice", 'p.customcode' => 'CustomCode',
'p.price_ttc' => "SellingPriceTTC",//with tax 'p.fk_country' => 'CountryCode',
'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.accountancy_code_sell' => "ProductAccountancySellCode", 'p.accountancy_code_sell' => "ProductAccountancySellCode",
'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode", 'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode",
'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode", 'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode",
'p.accountancy_code_buy' => "ProductAccountancyBuyCode", 'p.accountancy_code_buy' => "ProductAccountancyBuyCode",
'p.weight' => "Weight", 'p.note_public' => "NotePublic",
'p.note' => "NotePrivate",
'p.weight' => "Weight",
'p.weight_units' => "WeightUnits", 'p.weight_units' => "WeightUnits",
'p.length' => "Length", 'p.length' => "Length",
'p.length_units' => "LengthUnit", 'p.length_units' => "LengthUnit",
@ -382,7 +384,16 @@ class modProduct extends DolibarrModules
'p.surface_units' => "SurfaceUnit", 'p.surface_units' => "SurfaceUnit",
'p.volume' => "Volume", 'p.volume' => "Volume",
'p.volume_units' => "VolumeUnits", '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 if (!empty($conf->stock->enabled)) {//if Stock module enabled
$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( $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( $this->import_convertvalue_array[$r] = array(
'p.weight_units' => array( 'p.weight_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', 'classfile' => '/core/class/cunits.class.php',
'class' => 'CUnits', 'class' => 'CUnits',
'method' => 'fetch', 'method' => 'fetch',
@ -403,7 +413,7 @@ class modProduct extends DolibarrModules
'dict' => 'DictionaryMeasuringUnits' 'dict' => 'DictionaryMeasuringUnits'
), ),
'p.length_units' => array( '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', 'classfile' => '/core/class/cunits.class.php',
'class' => 'CUnits', 'class' => 'CUnits',
'method' => 'fetch', 'method' => 'fetch',
@ -411,7 +421,7 @@ class modProduct extends DolibarrModules
'dict' => 'DictionaryMeasuringUnits' 'dict' => 'DictionaryMeasuringUnits'
), ),
'p.width_units' => array( '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', 'classfile' => '/core/class/cunits.class.php',
'class' => 'CUnits', 'class' => 'CUnits',
'method' => 'fetch', 'method' => 'fetch',
@ -419,7 +429,7 @@ class modProduct extends DolibarrModules
'dict' => 'DictionaryMeasuringUnits' 'dict' => 'DictionaryMeasuringUnits'
), ),
'p.height_units' => array( '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', 'classfile' => '/core/class/cunits.class.php',
'class' => 'CUnits', 'class' => 'CUnits',
'method' => 'fetch', 'method' => 'fetch',
@ -427,7 +437,7 @@ class modProduct extends DolibarrModules
'dict' => 'DictionaryMeasuringUnits' 'dict' => 'DictionaryMeasuringUnits'
), ),
'p.surface_units' => array( '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', 'classfile' => '/core/class/cunits.class.php',
'class' => 'CUnits', 'class' => 'CUnits',
'method' => 'fetch', 'method' => 'fetch',
@ -435,14 +445,21 @@ class modProduct extends DolibarrModules
'dict' => 'DictionaryMeasuringUnits' 'dict' => 'DictionaryMeasuringUnits'
), ),
'p.volume_units' => array( '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', 'classfile' => '/core/class/cunits.class.php',
'class' => 'CUnits', 'class' => 'CUnits',
'method' => 'fetch', 'method' => 'fetch',
'units' => 'volume', 'units' => 'volume',
'dict' => 'DictionaryMeasuringUnits' '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 (! 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->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 // field order as per structure of table llx_product
$import_sample = array( $import_sample = array(
'p.ref' => "PREF123456", '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.label' => "Product name in default language",
'p.description' => "Product description in default language", 'p.description' => "Product description in default language",
'p.note_public' => "a public note (free text)", 'p.note_public' => "a public note (free text)",
'p.note' => "a private note (free text)", 'p.note' => "a private note (free text)",
'p.customcode' => 'customs code', 'p.customcode' => 'customs code',
'p.price' => "price ex-vat eg. 100", 'p.fk_country' => 'FR',
'p.price_min' => "price ex-vat eg. 100", 'p.price' => "100",
'p.price_ttc' => "price inc-vat eg. 110", 'p.price_min' => "100",
'p.price_min_ttc' => "price inc-vat eg. 110", '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.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.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.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)",
'p.fk_product_type' => "0 (product) / 1 (service)", 'p.fk_product_type' => "0 (product) / 1 (service)",
@ -502,27 +520,27 @@ class modProduct extends DolibarrModules
'p.accountancy_code_sell_export' => "", 'p.accountancy_code_sell_export' => "",
'p.accountancy_code_buy' => "", 'p.accountancy_code_buy' => "",
'p.weight' => "", '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' => "",
'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' => "",
'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' => "",
'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' => "",
'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' => "",
'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)' 'p.finished' => '0 (raw material) / 1 (finished goods)'
); );
//clauses copied from import_fields_array //clauses copied from import_fields_array
if (!empty($conf->stock->enabled)) $import_sample = array_merge($import_sample, 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.seuil_stock_alerte' => '',
'p.pmp' => '0 (default)', 'p.pmp' => '0',
'p.desiredstock' => 'target quantity to maintain in stock (for replenishment feature)' '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 (! 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 / 1 (French VAT NPR yes/no')); 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(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 (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->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( $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(
'p.fk_unit' => array( 'p.fk_unit' => array(
'rule' => 'fetchidfromcodeorlabel', 'rule' => 'fetchidfromcodeorlabel',
@ -596,34 +615,34 @@ class modProduct extends DolibarrModules
$this->import_examplevalues_array[$r]=array( $this->import_examplevalues_array[$r]=array(
'sp.fk_product' => "PRODUCT_REF or id:123456", 'sp.fk_product' => "PRODUCT_REF or id:123456",
'sp.fk_soc' => "My Supplier", 'sp.fk_soc' => "My Supplier",
'sp.ref_fourn' => "eg: XYZ-F123456", 'sp.ref_fourn' => "XYZ-F123456",
'sp.quantity' => "5", 'sp.quantity' => "5",
'sp.tva_tx' => 'one of the defined rates eg. 21', 'sp.tva_tx' => '10',
'sp.price'=>"50", 'sp.price'=>"50",
'sp.unitprice'=>'50', 'sp.unitprice'=>'50',
'sp.remise_percent'=>'0', 'sp.remise_percent'=>'0',
'sp.default_vat_code' => '', 'sp.default_vat_code' => '',
'sp.delivery_time_days' => 'eg. 5', 'sp.delivery_time_days' => '5',
'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER' '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->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(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')); 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( $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
'sp.price' => "eg. 50.00", 'sp.price' => "50.00",
'sp.unitprice' => 'eg. 10', 'sp.unitprice' => '10',
// TODO Make this field not required and calculate it from price and qty // 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) if ($conf->multicurrency->enabled)
{ {
$this->import_examplevalues_array[$r]=array_merge($this->import_examplevalues_array[$r], array( $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.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency',
'sp.multicurrency_code'=>'eg: GBP', 'sp.multicurrency_code'=>'GBP',
'sp.multicurrency_tx'=>'currency rate eg: 1.12345', 'sp.multicurrency_tx'=>'1.12345',
'sp.multicurrency_unitprice'=>'cost per unit in supplier currency', 'sp.multicurrency_unitprice'=>'',
// TODO Make this field not required and calculate it from price and qty // 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", $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_base_type'=>"HT (for excl tax) or TTC (for inc tax)",'pr.price_level'=>"1",
'pr.price'=>"100",'pr.price_ttc'=>"110", 'pr.price'=>"100", 'pr.price_ttc'=>"110",
'pr.price_min'=>"100",'pr.price_min_ttc'=>"110", 'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110",
'pr.tva_tx'=>'20', 'pr.tva_tx'=>'20',
'pr.recuperableonly'=>'0', 'pr.recuperableonly'=>'0',
'pr.date_price'=>'2013-04-10'); 'pr.date_price'=>'2013-04-10');

View File

@ -141,19 +141,39 @@ class modService extends DolibarrModules
$this->export_code[$r]=$this->rights_class.'_'.$r; $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_label[$r]="Services"; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_permission[$r]=array(array("service","export")); $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 (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->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->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'; $keyforselect='product'; $keyforelement='product'; $keyforaliasextra='extra';
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; 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->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->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->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'; 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'); $this->export_TypeFields_array[$r]=array(
if (! empty($conf->stock->enabled)) $this->export_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric')); '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->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->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')); 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_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'product as p'; $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] .=' 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)) 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] =' 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.'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] .=' 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)) if (! empty($conf->global->PRODUIT_SOUSPRODUITS))
@ -255,8 +275,10 @@ class modService extends DolibarrModules
$this->export_permission[$r]=array(array("produit","export")); $this->export_permission[$r]=array(array("produit","export"));
$this->export_fields_array[$r]=array( $this->export_fields_array[$r]=array(
'p.rowid'=>"Id",'p.ref'=>"Ref",'p.label'=>"Label",'p.description'=>"Description",'p.url'=>"PublicUrl", '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.accountancy_code_sell'=>"ProductAccountancySellCode",'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode",
'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.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.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')); 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_fields_array[$r]=array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty','pa.incdec'=>'ComposedProductIncDecStock'));
$this->export_TypeFields_array[$r]=array( $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.ref'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.url'=>"Text",
'p.note'=>"Text",'p.length'=>"Numeric",'p.surface'=>"Numeric",'p.volume'=>"Numeric",'p.weight'=>"Numeric",'p.customcode'=>'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.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.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_TypeFields_array[$r]=array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric'));
$this->export_entities_array[$r]=array( $this->export_entities_array[$r]=array(
'p.rowid'=>"virtualproduct",'p.ref'=>"virtualproduct",'p.label'=>"virtualproduct",'p.description'=>"virtualproduct",'p.url'=>"virtualproduct", '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.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.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" '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] =' 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] .=' 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] .=' '.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] .=' 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';
}
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] .=' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils'; $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_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_tables_creator_array[$r]=array('p'=>'fk_user_author'); // Fields to store import user id
$this->import_fields_array[$r]=array( $this->import_fields_array[$r]=array(
'p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.url'=>"PublicUrl",'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.ref' => "Ref*",
'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",'p.note'=>"Note",'p.length'=>"Length",'p.surface'=>"Surface",'p.volume'=>"Volume", 'p.label' => "Label*",
'p.weight'=>"Weight",'p.duration'=>"Duration",'p.customcode'=>'CustomCode','p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC", 'p.fk_product_type' => "Type*",
'p.tva_tx'=>'VATRate','p.tosell'=>"OnSell*",'p.tobuy'=>"OnBuy*",'p.fk_product_type'=>"Type*",'p.finished'=>'Nature','p.datec'=>'DateCreation' '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 (! 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->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')); 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_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( $this->import_regex_array[$r]=array(
'p.ref'=>'[^ ]', 'p.ref'=>'[^ ]',
'p.tosell'=>'^[0|1]$', 'p.price_base_type' => '\AHT\z|\ATTC\z',
'p.tosell'=>'^[0|1]$',
'p.tobuy'=>'^[0|1]$', 'p.tobuy'=>'^[0|1]$',
'p.fk_product_type'=>'^[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.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
'p.recuperableonly'=>'^[0|1]$' 'p.recuperableonly' => '^[0|1]$',
); 'p.finished' => '^[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'); );
// 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_examplevalues_array[$r]=array_merge($import_sample, $import_extrafield_sample);
$this->import_updatekeys_array[$r] = array('p.ref'=>'Ref'); $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 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') 'sp.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'Product')
); );
$this->import_examplevalues_array[$r]=array( $this->import_examplevalues_array[$r]=array(
'sp.fk_product'=>"SERVICE_REF or id:123456", 'sp.fk_product' => "PRODUCT_REF or id:123456",
'sp.fk_soc'=>"My Supplier",'sp.ref_fourn'=>"SupplierRef", 'sp.quantity'=>"1", 'sp.tva_tx'=>'21', 'sp.fk_soc' => "My Supplier",
'sp.price'=>"50", 'sp.ref_fourn' => "XYZ-F123456",
'sp.unitprice'=>'50', 'sp.quantity' => "5",
'sp.remise_percent'=>'0' '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'); $this->import_updatekeys_array[$r]=array('sp.fk_product'=>'ProductOrService','sp.ref_fourn'=>'SupplierRef','sp.fk_soc'=>'Supplier');
} }

View File

@ -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 * @param string $password Password to check
*
* @return bool * @return bool
*/ */
private function consecutiveInterationSameCharacter($password) private function consecutiveInterationSameCharacter($password)
{ {
$last = ""; $last = "";
if (empty($this->NbRepeat)) return 1;
$count = 0; $count = 0;
$char = str_split($password); $char = str_split($password);
foreach($char as $c) { foreach($char as $c) {
if($c != $last) { if($c != $last) {
$last = $c; $last = $c;

View File

@ -96,7 +96,6 @@ $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
// fetch optionals attributes lines and labels // fetch optionals attributes lines and labels
$extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line); $extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
// Load object. Make an object->fetch // Load object. Make an object->fetch
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
@ -1570,10 +1569,10 @@ if ($action == 'create')
} }
} }
//Display lines extrafields //Display lines extrafields
if (is_array($extralabelslines) && count($extralabelslines)>0) if (is_array($extralabelslines) && count($extralabelslines)>0)
{ {
//var_dump($line);
$colspan=5; $colspan=5;
$orderLineExtrafields = new Extrafields($db); $orderLineExtrafields = new Extrafields($db);
$orderLineExtrafieldLabels = $orderLineExtrafields->fetch_name_optionals_label($object->table_element_line); $orderLineExtrafieldLabels = $orderLineExtrafields->fetch_name_optionals_label($object->table_element_line);
@ -1583,7 +1582,7 @@ if ($action == 'create')
//$line->fetch_optionals($line->id); //$line->fetch_optionals($line->id);
$line->array_options = array_merge($line->array_options, $srcLine->array_options); $line->array_options = array_merge($line->array_options, $srcLine->array_options);
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>$colspan), $indiceAsked); print $line->showOptionals($extrafieldsline, 'edit', array('colspan'=>$colspan), $indiceAsked);
print '</tr>'; print '</tr>';
} }
} }
@ -1841,8 +1840,8 @@ elseif ($id || $ref)
print '<input name="action" value="settrueWeight" type="hidden">'; print '<input name="action" value="settrueWeight" type="hidden">';
print '<input name="id" value="'.$object->id.'" type="hidden">'; print '<input name="id" value="'.$object->id.'" type="hidden">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input id="trueWeight" name="trueWeight" value="'.$object->trueWeight.'" type="text">'; print '<input id="trueWeight" name="trueWeight" value="'.$object->trueWeight.'" type="text" class="width50">';
print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units); print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2);
print ' <input class="button" name="modify" value="'.$langs->trans("Modify").'" type="submit">'; print ' <input class="button" name="modify" value="'.$langs->trans("Modify").'" type="submit">';
print ' <input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">'; print ' <input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">';
print '</form>'; print '</form>';
@ -1850,7 +1849,7 @@ elseif ($id || $ref)
else else
{ {
print $object->trueWeight; 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 // Calculated
@ -1867,7 +1866,7 @@ elseif ($id || $ref)
// Width // Width
print '<tr><td>'.$form->editfieldkey("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer).'</td><td colspan="3">'; print '<tr><td>'.$form->editfieldkey("Width", 'trueWidth', $object->trueWidth, $object, $user->rights->expedition->creer).'</td><td colspan="3">';
print $form->editfieldval("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 '</td></tr>'; print '</td></tr>';
// Height // Height
@ -1878,8 +1877,8 @@ elseif ($id || $ref)
print '<input name="action" value="settrueHeight" type="hidden">'; print '<input name="action" value="settrueHeight" type="hidden">';
print '<input name="id" value="'.$object->id.'" type="hidden">'; print '<input name="id" value="'.$object->id.'" type="hidden">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input id="trueHeight" name="trueHeight" value="'.$object->trueHeight.'" type="text">'; print '<input id="trueHeight" name="trueHeight" value="'.$object->trueHeight.'" type="text" class="width50">';
print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units); print $formproduct->selectMeasuringUnits("size_units", "size", $object->size_units, 0, 2);
print ' <input class="button" name="modify" value="'.$langs->trans("Modify").'" type="submit">'; print ' <input class="button" name="modify" value="'.$langs->trans("Modify").'" type="submit">';
print ' <input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">'; print ' <input class="button" name="cancel" value="'.$langs->trans("Cancel").'" type="submit">';
print '</form>'; print '</form>';
@ -1887,7 +1886,7 @@ elseif ($id || $ref)
else else
{ {
print $object->trueHeight; 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 '</td></tr>'; print '</td></tr>';
@ -1895,7 +1894,7 @@ elseif ($id || $ref)
// Depth // Depth
print '<tr><td>'.$form->editfieldkey("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer).'</td><td colspan="3">'; print '<tr><td>'.$form->editfieldkey("Depth", 'trueDepth', $object->trueDepth, $object, $user->rights->expedition->creer).'</td><td colspan="3">';
print $form->editfieldval("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 '</td></tr>'; print '</td></tr>';
// Volume // Volume
@ -2101,8 +2100,6 @@ elseif ($id || $ref)
} }
print "</tr>\n"; print "</tr>\n";
$var=false;
if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
{ {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
@ -2407,14 +2404,14 @@ elseif ($id || $ref)
} }
// Weight // Weight
print '<td class="center">'; print '<td class="center linecolweight">';
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"); 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 '&nbsp;'; else print '&nbsp;';
print '</td>'; print '</td>';
// Volume // Volume
print '<td class="center">'; print '<td class="center linecolvolume">';
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"); 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 '&nbsp;'; else print '&nbsp;';
print '</td>'; print '</td>';

View File

@ -86,6 +86,10 @@ InvoiceDeleted=Invoice deleted
PRODUCT_CREATEInDolibarr=Product %s created PRODUCT_CREATEInDolibarr=Product %s created
PRODUCT_MODIFYInDolibarr=Product %s modified PRODUCT_MODIFYInDolibarr=Product %s modified
PRODUCT_DELETEInDolibarr=Product %s deleted 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_CREATEInDolibarr=Expense report %s created
EXPENSE_REPORT_VALIDATEInDolibarr=Expense report %s validated EXPENSE_REPORT_VALIDATEInDolibarr=Expense report %s validated
EXPENSE_REPORT_APPROVEInDolibarr=Expense report %s approved EXPENSE_REPORT_APPROVEInDolibarr=Expense report %s approved

View File

@ -588,27 +588,27 @@ print '</td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<td>'.$langs->trans("Project").'</td>'; if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<th>'.$langs->trans("Project").'</th>';
if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<td>'.$langs->trans("ThirdParty").'</td>'; if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<th>'.$langs->trans("ThirdParty").'</th>';
print '<td>'.$langs->trans("Task").'</td>'; print '<th>'.$langs->trans("Task").'</th>';
// TASK fields // TASK fields
$extrafieldsobjectkey='projet_task'; $extrafieldsobjectkey='projet_task';
$extrafieldsobjectprefix='efpt.'; $extrafieldsobjectprefix='efpt.';
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
if (! empty($arrayfields['t.planned_workload']['checked'])) if (! empty($arrayfields['t.planned_workload']['checked']))
{ {
print '<td class="right leftborder plannedworkload maxwidth100">'.$langs->trans("PlannedWorkload").'</td>'; print '<th class="right leftborder plannedworkload maxwidth100">'.$langs->trans("PlannedWorkload").'</th>';
} }
if (! empty($arrayfields['t.progress']['checked'])) if (! empty($arrayfields['t.progress']['checked']))
{ {
print '<td class="right maxwidth100">'.$langs->trans("ProgressDeclared").'</td>'; print '<th class="right maxwidth100">'.$langs->trans("ProgressDeclared").'</th>';
} }
/*print '<td class="right maxwidth100">'.$langs->trans("TimeSpent").'</td>'; /*print '<td class="right maxwidth100">'.$langs->trans("TimeSpent").'</td>';
if ($usertoprocess->id == $user->id) print '<td class="right maxwidth100">'.$langs->trans("TimeSpentByYou").'</td>'; if ($usertoprocess->id == $user->id) print '<td class="right maxwidth100">'.$langs->trans("TimeSpentByYou").'</td>';
else print '<td class="right maxwidth100">'.$langs->trans("TimeSpentByUser").'</td>';*/ else print '<td class="right maxwidth100">'.$langs->trans("TimeSpentByUser").'</td>';*/
print '<td class="right maxwidth100">'.$langs->trans("TimeSpent").'<br>('.$langs->trans("Everybody").')</td>'; print '<th class="right maxwidth100">'.$langs->trans("TimeSpent").'<br>('.$langs->trans("Everybody").')</th>';
print '<td class="right maxwidth100">'.$langs->trans("TimeSpent").($usertoprocess->firstname?'<br>('.dol_trunc($usertoprocess->firstname, 10).')':'').'</td>'; print '<th class="right maxwidth100">'.$langs->trans("TimeSpent").($usertoprocess->firstname?'<br>('.dol_trunc($usertoprocess->firstname, 10).')':'').'</th>';
print '<td class="center leftborder">'.$langs->trans("HourStart").'</td>'; print '<th class="center leftborder">'.$langs->trans("HourStart").'</td>';
// By default, we can edit only tasks we are assigned to // 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); $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]['morning']) $cssonholiday.='onholidaymorning ';
elseif (! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayafternoon '; elseif (! $isavailable[$daytoparse]['afternoon']) $cssonholiday.='onholidayafternoon ';
print '<td class="center'.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">'.$langs->trans("Duration").'</td>'; print '<th class="center'.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">'.$langs->trans("Duration").'</th>';
print '<td class="center">'.$langs->trans("Note").'</td>'; print '<th class="center">'.$langs->trans("Note").'</th>';
//print '<td class="center"></td>'; //print '<td class="center"></td>';
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');

View File

@ -640,26 +640,26 @@ print '</td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<td>'.$langs->trans("Project").'</td>'; if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<th>'.$langs->trans("Project").'</th>';
if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<td>'.$langs->trans("ThirdParty").'</td>'; if (! empty($conf->global->PROJECT_TIMESHEET_DISABLEBREAK_ON_PROJECT)) print '<th>'.$langs->trans("ThirdParty").'</th>';
print '<td>'.$langs->trans("Task").'</td>'; print '<th>'.$langs->trans("Task").'</th>';
// TASK fields // TASK fields
$extrafieldsobjectkey='projet_task'; $extrafieldsobjectkey='projet_task';
$extrafieldsobjectprefix='efpt.'; $extrafieldsobjectprefix='efpt.';
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
if (! empty($arrayfields['t.planned_workload']['checked'])) if (! empty($arrayfields['t.planned_workload']['checked']))
{ {
print '<td class="leftborder plannedworkload maxwidth75 right">'.$langs->trans("PlannedWorkload").'</td>'; print '<th class="leftborder plannedworkload maxwidth75 right">'.$langs->trans("PlannedWorkload").'</th>';
} }
if (! empty($arrayfields['t.progress']['checked'])) if (! empty($arrayfields['t.progress']['checked']))
{ {
print '<td class="maxwidth75 right">'.$langs->trans("ProgressDeclared").'</td>'; print '<th class="maxwidth75 right">'.$langs->trans("ProgressDeclared").'</th>';
} }
/*print '<td class="maxwidth75 right">'.$langs->trans("TimeSpent").'</td>'; /*print '<td class="maxwidth75 right">'.$langs->trans("TimeSpent").'</td>';
if ($usertoprocess->id == $user->id) print '<td class="maxwidth75 right">'.$langs->trans("TimeSpentByYou").'</td>'; if ($usertoprocess->id == $user->id) print '<td class="maxwidth75 right">'.$langs->trans("TimeSpentByYou").'</td>';
else print '<td class="maxwidth75 right">'.$langs->trans("TimeSpentByUser").'</td>';*/ else print '<td class="maxwidth75 right">'.$langs->trans("TimeSpentByUser").'</td>';*/
print '<td class="maxwidth75 right">'.$langs->trans("TimeSpent").'<br>('.$langs->trans("Everybody").')</td>'; print '<th class="maxwidth75 right">'.$langs->trans("TimeSpent").'<br>('.$langs->trans("Everybody").')</th>';
print '<td class="maxwidth75 right">'.$langs->trans("TimeSpent").($usertoprocess->firstname?'<br>('.dol_trunc($usertoprocess->firstname, 10).')':'').'</td>'; print '<th class="maxwidth75 right">'.$langs->trans("TimeSpent").($usertoprocess->firstname?'<br>('.dol_trunc($usertoprocess->firstname, 10).')':'').'</th>';
for ($idw=0; $idw<7; $idw++) 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]['morning']) $cssonholiday.='onholidaymorning ';
elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon '; elseif (! $isavailable[$tmpday]['afternoon']) $cssonholiday.='onholidayafternoon ';
print '<td width="6%" align="center" class="bold hide'.$idw.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">'.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'<br>'.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'</td>'; print '<th width="6%" align="center" class="bold hide'.$idw.($cssonholiday?' '.$cssonholiday:'').($cssweekend?' '.$cssweekend:'').'">'.dol_print_date($dayinloopfromfirstdaytoshow, '%a').'<br>'.dol_print_date($dayinloopfromfirstdaytoshow, 'dayreduceformat').'</th>';
} }
//print '<td></td>'; //print '<td></td>';
print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');

View File

@ -37,6 +37,7 @@ if (!defined("NOLOGIN")) {
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.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/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/ticket.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.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); $ret = $object->fetch('', '', $track_id);
if ($ret && $object->id > 0) { 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'); $contacts = $object->liste_contact(-1, 'external');
foreach ($contacts as $contact) { foreach ($contacts as $contact) {
if ($contact['email'] == $email) { if ($contact['email'] == $email) {
@ -124,7 +126,9 @@ if ($action == "view_ticketlist") {
$_SESSION['track_id_customer'] = $track_id; $_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; $display_ticket_list = true;
$_SESSION['email_customer'] = $email; $_SESSION['email_customer'] = $email;
$_SESSION['track_id_customer'] = $track_id; $_SESSION['track_id_customer'] = $track_id;
@ -638,7 +642,7 @@ if ($action == "view_ticketlist")
// Statut // Statut
if (!empty($arrayfields['t.fk_statut']['checked'])) { if (!empty($arrayfields['t.fk_statut']['checked'])) {
print '<td>'; print '<td class="nowraponall">';
$object->fk_statut = $obj->fk_statut; $object->fk_statut = $obj->fk_statut;
print $object->getLibStatut(2); print $object->getLibStatut(2);
print '</td>'; print '</td>';

View File

@ -38,6 +38,7 @@ if (!defined("NOLOGIN")) {
require '../../main.inc.php'; require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.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/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/ticket.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.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); $ret = $object->fetch('', '', $track_id);
if ($ret && $object->dao->id > 0) { if ($ret && $object->dao->id > 0) {
// Check if emails provided is the one of author // 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; $display_ticket = true;
$_SESSION['email_customer'] = $email; $_SESSION['email_customer'] = $email;
@ -174,7 +176,6 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a
if (! $error) if (! $error)
{ {
$action = 'view_ticket'; $action = 'view_ticket';
@ -226,7 +227,8 @@ llxHeaderTicket($langs->trans("Tickets"), "", 0, 0, $arrayofjs, $arrayofcss);
print '<div style="margin: 0 auto;" class="ticketpublicarea">'; print '<div style="margin: 0 auto;" class="ticketpublicarea">';
if ($action == "view_ticket" || $action == "presend" || $action == "close" || $action == "confirm_public_close") { if ($action == "view_ticket" || $action == "presend" || $action == "close" || $action == "confirm_public_close") {
if ($display_ticket) { if ($display_ticket)
{
// Confirmation close // Confirmation close
if ($action == 'close') { if ($action == 'close') {
print $form->formconfirm($_SERVER["PHP_SELF"] . "?track_id=" . $track_id, $langs->trans("CloseATicket"), $langs->trans("ConfirmCloseAticket"), "confirm_public_close", '', '', 1); 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); $fuser->fetch($object->dao->fk_user_create);
print $fuser->getFullName($langs); print $fuser->getFullName($langs);
} else { } else {
print $object->dao->origin_email; print dol_escape_htmltag($object->dao->origin_email);
} }
print '</td></tr>'; print '</td></tr>';
@ -370,7 +372,9 @@ if ($action == "view_ticket" || $action == "presend" || $action == "close" || $a
// Message list // Message list
print load_fiche_titre($langs->trans('TicketMessagesList'), '', 'messages@ticket'); print load_fiche_titre($langs->trans('TicketMessagesList'), '', 'messages@ticket');
$object->viewTicketMessages(false, true, $object->dao); $object->viewTicketMessages(false, true, $object->dao);
} else { }
else
{
print '<div class="error">Not Allowed<br><a href="' . $_SERVER['PHP_SELF'] . '?track_id=' . $object->dao->track_id . '">' . $langs->trans('Back') . '</a></div>'; print '<div class="error">Not Allowed<br><a href="' . $_SERVER['PHP_SELF'] . '?track_id=' . $object->dao->track_id . '">' . $langs->trans('Back') . '</a></div>';
} }
} else { } else {

View File

@ -119,25 +119,7 @@ if ($socid)
dol_fiche_end(); dol_fiche_end();
/* $addbutton = '<a class="butActionNew" href="'.DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$object->id.'&amp;backtopage='.urlencode($backtopage).'"><span class="text-plus-circle">'.$langs->trans("AddProject").'</span><span class="fa fa-plus-circle valignmiddle"></span></a>';
* Barre d'action
*/
/*print '<div class="tabsAction">';
if (! empty($conf->projet->enabled))
{
if (! empty($conf->projet->enabled) && ! empty($user->rights->projet->creer))
{*/
$addbutton = '<a href="'.DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$object->id.'&amp;backtopage='.urlencode($backtopage).'">'.$langs->trans("AddProject").'</a>';
/* }
else
{
print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("AddProject").'</a>';
}
}
print '</div>'; */
print '<br>'; print '<br>';

View File

@ -371,7 +371,7 @@ if ($action == "assign_user" && GETPOST('btn_assign_user', 'aplha') && $user->ri
$action = 'view'; $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)); $ret = $object->newMessage($user, $action, (GETPOST('private_message', 'alpha') == "on" ? 1 : 0));
if ($ret > 0) { if ($ret > 0) {
@ -769,7 +769,7 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd
} }
if (!empty($object->origin_email)) { if (!empty($object->origin_email)) {
$morehtmlref .= '<br>' . $langs->trans("CreatedBy") . ' : '; $morehtmlref .= '<br>' . $langs->trans("CreatedBy") . ' : ';
$morehtmlref .= $object->origin_email . ' <small>(' . $langs->trans("TicketEmailOriginIssuer") . ')</small>'; $morehtmlref .= dol_escape_htmltag($object->origin_email) . ' <small>(' . $langs->trans("TicketEmailOriginIssuer") . ')</small>';
} }
// Thirdparty // Thirdparty
@ -1290,10 +1290,8 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd
//$formticket->param['socid']=$object->fk_soc; //$formticket->param['socid']=$object->fk_soc;
$formticket->param['returnurl']=$_SERVER["PHP_SELF"].'?track_id='.$object->track_id; $formticket->param['returnurl']=$_SERVER["PHP_SELF"].'?track_id='.$object->track_id;
$formticket->withsubstit = 1; $formticket->withsubstit = 1;
$formticket->substit = $substitutionarray; $formticket->substit = $substitutionarray;
$formticket->showMessageForm('100%'); $formticket->showMessageForm('100%');
print '</div>'; print '</div>';
} }

View File

@ -1602,13 +1602,16 @@ class Ticket extends CommonObject
} }
/** /**
* Add message into database * Add message into database
* *
* @param User $user User that creates * @param User $user User that creates
* @param int $notrigger 0=launch triggers after, 1=disable triggers * @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, Id of created object if OK * @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; global $conf, $langs;
$error = 0; $error = 0;
@ -1633,7 +1636,7 @@ class Ticket extends CommonObject
$actioncomm->code = 'TICKET_MSG'; $actioncomm->code = 'TICKET_MSG';
$actioncomm->socid = $this->socid; $actioncomm->socid = $this->socid;
$actioncomm->label = $this->subject; $actioncomm->label = $this->subject;
$actioncomm->note = $this->message; $actioncomm->note_private = $this->message;
$actioncomm->userassigned = array($user->id); $actioncomm->userassigned = array($user->id);
$actioncomm->userownerid = $user->id; $actioncomm->userownerid = $user->id;
$actioncomm->datep = $now; $actioncomm->datep = $now;
@ -1641,6 +1644,19 @@ class Ticket extends CommonObject
$actioncomm->elementtype = 'ticket'; $actioncomm->elementtype = 'ticket';
$actioncomm->fk_element = $this->id; $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); $actionid = $actioncomm->create($user);
if ($actionid <= 0) if ($actionid <= 0)
{ {
@ -2389,10 +2405,11 @@ class Ticket extends CommonObject
/** /**
* Copy files into ticket directory * Copy files defined into $_SESSION array into the ticket directory of attached files.
* Used for files linked into messages * 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() public function copyFilesForTicket()
{ {
@ -2422,23 +2439,42 @@ class Ticket extends CommonObject
if (!dol_is_dir($destdir)) { if (!dol_is_dir($destdir)) {
dol_mkdir($destdir); dol_mkdir($destdir);
} }
$listofpaths = array();
$listofnames = array();
foreach ($filename as $i => $val) { foreach ($filename as $i => $val) {
$res = dol_move($filepath[$i], $destdir . '/' . $filename[$i]); $destfile = $destdir . '/' . $filename[$i];
if (image_format_supported($destdir . '/' . $filename[$i]) == 1) { // 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) // Create small thumbs for image (Ratio is near 16/9)
// Used on logon for example // 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) // Create mini thumbs for image (Ratio is near 16/9)
// Used on menu or for setup page for example // 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); $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 User $user User for action
* @param string $action Action string * @param string $action Action string
@ -2449,19 +2485,15 @@ class Ticket extends CommonObject
{ {
global $mysoc, $conf, $langs; 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; $error = 0;
$object = new Ticket($this->db);
$ret = $object->fetch('', '', GETPOST('track_id', 'alpha')); $ret = $object->fetch('', '', GETPOST('track_id', 'alpha'));
$object->socid = $object->fk_soc; $object->socid = $object->fk_soc;
$object->fetch_thirdparty(); $object->fetch_thirdparty();
if ($ret < 0) { if ($ret < 0) {
$error++; $error++;
array_push($this->errors, $langs->trans("ErrorTicketIsNotValid")); array_push($this->errors, $langs->trans("ErrorTicketIsNotValid"));
@ -2478,9 +2510,17 @@ class Ticket extends CommonObject
$object->subject = GETPOST('subject', 'alphanohtml'); $object->subject = GETPOST('subject', 'alphanohtml');
$object->message = GETPOST("message", "none"); $object->message = GETPOST("message", "none");
$object->private = GETPOST("private_message", "alpha"); $object->private = GETPOST("private_message", "alpha");
$send_email = GETPOST('send_email', 'int'); $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) { if ($id <= 0) {
$error++; $error++;
$this->errors = $object->error; $this->errors = $object->error;
@ -2491,24 +2531,27 @@ class Ticket extends CommonObject
if (!$error && $id > 0) { if (!$error && $id > 0) {
setEventMessages($langs->trans('TicketMessageSuccessfullyAdded'), null, 'mesgs'); 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) { if ($send_email > 0) {
// Retrieve internal contact datas // Retrieve internal contact datas
$internal_contacts = $object->getInfosTicketInternalContact(); $internal_contacts = $object->getInfosTicketInternalContact();
$sendto = array(); $sendto = array();
if (is_array($internal_contacts) && count($internal_contacts) > 0) { if (is_array($internal_contacts) && count($internal_contacts) > 0) {
// altairis: set default subject // altairis: set default subject
$label_title = empty($conf->global->MAIN_APPLICATION_TITLE) ? $mysoc->name : $conf->global->MAIN_APPLICATION_TITLE; $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_intro = $langs->trans('TicketNotificationEmailBody', "#" . $object->id);
$message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE; $message_signature = GETPOST('mail_signature') ? GETPOST('mail_signature') : $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE;
$message = $langs->trans('TicketMessageMailIntroText'); $message = $langs->trans('TicketMessageMailIntroText');
$message .= "\n\n"; $message .= "\n\n";
$message .= GETPOST('message'); $message .= GETPOST('message', 'restricthtml');
// Coordonnées client // Coordonnées client
$message .= "\n\n"; $message .= "\n\n";
@ -2547,12 +2590,12 @@ class Ticket extends CommonObject
// altairis: dont try to send email if no recipient // altairis: dont try to send email if no recipient
if (!empty($sendto)) { 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)) { if (empty($object->private)) {
// Retrieve email of all contacts (external) // 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 // If public interface is not enable, use link to internal page into mail
$url_public_ticket = (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) ? $url_public_ticket = (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) ?
(!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? (!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? $conf->global->TICKET_URL_PUBLIC_INTERFACE . '/view.php' : dol_buildpath('/public/ticket/view.php', 2)) :
$conf->global->TICKET_URL_PUBLIC_INTERFACE . '/view.php' : dol_buildpath('/ticket/card.php', 2)) . '?track_id=' . $object->track_id;
dol_buildpath('/public/ticket/view.php', 2) $message .= "\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . '<a href="' . $url_public_ticket . '">' . $object->track_id . '</a>' . "\n";
) :
dol_buildpath('/ticket/card.php', 2)
) . '?track_id=' . $object->track_id;
$message .= "\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . '<a href="' . $url_public_ticket . '">' . $object->track_id . '</a>' . "\n";
// Build final message // Build final message
$message = $message_intro . $message; $message = $message_intro . $message;
// Add signature // Add signature
$message .= '<br>' . $message_signature; $message .= '<br>' . $message_signature;
if (!empty($object->origin_email)) { if (!empty($object->origin_email)) {
$sendto[] = $object->origin_email; $sendto[] = $object->origin_email;
} }
if ($object->fk_soc > 0 && ! in_array($object->origin_email, $sendto)) { if ($object->fk_soc > 0 && ! in_array($object->origin_email, $sendto)) {
$object->socid = $object->fk_soc; $object->socid = $object->fk_soc;
$object->fetch_thirdparty(); $object->fetch_thirdparty();
if(!empty($object->thirdparty->email)) $sendto[] = $object->thirdparty->email; if(!empty($object->thirdparty->email)) $sendto[] = $object->thirdparty->email;
} }
// altairis: Add global email address reciepient // altairis: Add global email address reciepient
if ($conf->global->TICKET_NOTIFICATION_ALSO_MAIN_ADDRESS && !in_array($conf->global->TICKET_NOTIFICATION_EMAIL_TO, $sendto)) { 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; if(!empty($conf->global->TICKET_NOTIFICATION_EMAIL_TO)) $sendto[] = $conf->global->TICKET_NOTIFICATION_EMAIL_TO;
} }
// altairis: dont try to send email when no recipient // altairis: dont try to send email when no recipient
if (!empty($sendto)) { if (!empty($sendto)) {
$this->sendTicketMessageByEmail($subject, $message, '', $sendto); $this->sendTicketMessageByEmail($subject, $message, '', $sendto, $listofpaths, $listofmimes, $listofnames);
} }
} }
} }
} }
$object->copyFilesForTicket(); // Set status to "answered" if not set yet, but only if internal user
if ($object->fk_statut < 3 && ! $user->socid)
// Set status to "answered" if not set yet, only for internal users {
if ($object->fk_statut < 3 && !$user->societe_id) {
$object->setStatut(3); $object->setStatut(3);
} }
@ -2658,13 +2696,16 @@ class Ticket extends CommonObject
/** /**
* Send ticket by email to linked contacts * Send ticket by email to linked contacts
* *
* @param string $subject Email subject * @param string $subject Email subject
* @param string $message Email message * @param string $message Email message
* @param int $send_internal_cc Receive a copy on internal email ($conf->global->TICKET_NOTIFICATION_EMAIL_FROM) * @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 $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 * @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; global $conf, $langs;
@ -2690,15 +2731,12 @@ class Ticket extends CommonObject
$from = $conf->global->TICKET_NOTIFICATION_EMAIL_FROM; $from = $conf->global->TICKET_NOTIFICATION_EMAIL_FROM;
if (is_array($array_receiver) && count($array_receiver) > 0) { if (is_array($array_receiver) && count($array_receiver) > 0) {
foreach ($array_receiver as $key => $receiver) { foreach ($array_receiver as $key => $receiver)
// Create form object {
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $deliveryreceipt = 0;
$formmail = new FormMail($this->db); $filepath = $filename_list;
$filename = $mimefilename_list;
$attachedfiles = $formmail->get_attached_files(); $mimetype = $mimetype_list;
$filepath = $attachedfiles['paths'];
$filename = $attachedfiles['names'];
$mimetype = $attachedfiles['mimes'];
$message_to_send = dol_nl2br($message); $message_to_send = dol_nl2br($message);

View File

@ -229,8 +229,8 @@ foreach($search as $key => $val)
if ($key == 'fk_statut') if ($key == 'fk_statut')
{ {
$tmpstatus=''; $tmpstatus='';
if ($search['fk_statut'] == 'openall' || in_array('openall', $search['fk_statut'])) $tmpstatus.=($tmpstatus?',':'')."'0', '1', '3', '4', '5', '6'"; 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?',':'')."'8', '9'"; 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.")"; if ($tmpstatus) $sql.=" AND fk_statut IN (".$tmpstatus.")";
elseif (is_array($search[$key]) && count($search[$key])) $sql.=natural_search($key, join(',', $search[$key]), 2); elseif (is_array($search[$key]) && count($search[$key])) $sql.=natural_search($key, join(',', $search[$key]), 2);
continue; continue;

View File

@ -1293,8 +1293,8 @@ class User extends CommonObject
$this->db->begin(); $this->db->begin();
// Cree et positionne $this->id // Create user and set $this->id. Trigger is disabled because executed later.
$result=$this->create($user); $result=$this->create($user, 1);
if ($result > 0) if ($result > 0)
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."user"; $sql = "UPDATE ".MAIN_DB_PREFIX."user";

View File

@ -362,7 +362,7 @@ else
print '<div class="fichecenter">'; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">'; print '<table class="border centpercent tableforfield">';
// Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner) // 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)) if (! empty($conf->mutlicompany->enabled))

View File

@ -201,7 +201,7 @@ if ($object->id > 0)
* Ecran ajout/suppression permission * Ecran ajout/suppression permission
*/ */
print '<table class="border centpercent">'; print '<table class="border centpercent tableforfield">';
// Name (already in dol_banner, we keep it to have the GlobalGroup picto, but we should move it in dol_banner) // 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)) if (! empty($conf->mutlicompany->enabled))