diff --git a/ChangeLog b/ChangeLog index d3a5558db6b..e534e9e3d6d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -341,14 +341,14 @@ Following changes may create regressions for some external modules, but were nec WARNING FOR DOLIWAMP USERS ONLY: -Only people that installed Dolibarr using the all-in-one autoinstaller for Windows called "DoliWAMP" are concerned by the following warnings: +Only people that installed Dolibarr using the all-in-one auto-installer for Windows called "DoliWAMP" are concerned by the following warnings: -* DoliWAMP autoinstaller for Windows is not more available on 32bits systems. Use standard package if you need to use such architecture. -* It is not possible to migrate from an installation done with the old DoliWAMP autoinstaller for Windows by using this new one. You must make a backup - of your database, make a fresh installation using the new installer and reload your backup. Don't forget that DoliWAMP is a good solution to make a - quick test of Dolibarr on your local computer but was never recommanded as a production solution on a local desktop since a desktop computer has not - a backup and security policy as good as on a server (when there is one). - DoliWAMP remains a solution for fast test or demo purposes. Prefer using standard package for production. +* DoliWAMP auto-installer for Windows is no more available on 32 bits systems. Use standard package if you need to use such architecture. +* It is not possible to migrate from an installation done with the old DoliWAMP auto-installer for Windows by using this new one. + You must make a backup of your database, make a fresh installation using the new installer and reload your backup. + Don't forget that DoliWAMP is a good solution to make a quick test of Dolibarr on your local computer but is not recommended as a production + solution on a local desktop since a local desktop computer has often no backup and security policy, or not as good as on a server (when there is one). + DoliWAMP remains a solution for fast test or demo purposes. Prefer using standard packages for production. ***** ChangeLog for 11.0.5 compared to 11.0.4 ***** diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index 26ea76d2277..24c605bd930 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -174,6 +174,42 @@ if ($action == 'setenablesubsidiarylist') { } } +if ($action == 'setdisablebindingonsales') { + $setdisablebindingonsales = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_SALES", $setdisablebindingonsales, 'yesno', 0, '', $conf->entity); + if (!$res > 0) + $error++; + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + +if ($action == 'setdisablebindingonpurchases') { + $setdisablebindingonpurchases = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_PURCHASES", $setdisablebindingonpurchases, 'yesno', 0, '', $conf->entity); + if (!$res > 0) + $error++; + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + +if ($action == 'setdisablebindingonexpensereports') { + $setdisablebindingonexpensereports = GETPOST('value', 'int'); + $res = dolibarr_set_const($db, "ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS", $setdisablebindingonexpensereports, 'yesno', 0, '', $conf->entity); + if (!$res > 0) + $error++; + if (!$error) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'mesgs'); + } +} + /* * View */ @@ -226,82 +262,78 @@ print ''; print ''.$langs->trans('Options').''; print "\n"; -if (!empty($user->admin)) +// TO DO Mutualize code for yes/no constants + +/* Set this option as a hidden option but keep it for some needs. +print ''; +print ''.$langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL").''; +if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; +*/ + +print ''; +print ''.$langs->trans("BANK_DISABLE_DIRECT_INPUT").''; +if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; + +print ''; +print ''.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").''; +if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; + +print ''; +print ''.$langs->trans("ACCOUNTING_MANAGE_ZERO").''; +if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; + +// Param a user $user->rights->accounting->chartofaccount can access +foreach ($list as $key) { - // TO DO Mutualize code for yes/no constants + print ''; - /* Set this option as a hidden option but keep it for some needs. - print ''; - print ''.$langs->trans("ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL").''; - if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL)) { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } + if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue; + + // Param + $label = $langs->trans($key); + print ''.$label.''; + // Value + print ''; + print ''; + + print ''; print ''; - */ - - print ''; - print ''.$langs->trans("BANK_DISABLE_DIRECT_INPUT").''; - if (!empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - print ''; - - print ''; - print ''.$langs->trans("ACCOUNTANCY_COMBO_FOR_AUX").''; - if (!empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX)) { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - print ''; - - print ''; - print ''.$langs->trans("ACCOUNTING_MANAGE_ZERO").''; - if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO)) { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - print ''; - - // Param a user $user->rights->accounting->chartofaccount can access - foreach ($list as $key) - { - print ''; - - if (!empty($conf->global->ACCOUNTING_MANAGE_ZERO) && ($key == 'ACCOUNTING_LENGTH_GACCOUNT' || $key == 'ACCOUNTING_LENGTH_AACCOUNT')) continue; - - // Param - $label = $langs->trans($key); - print ''.$label.''; - // Value - print ''; - print ''; - - print ''; - - print ''; - } } print ''; print '
'; @@ -312,57 +344,91 @@ print ''; print ''.$langs->trans('BindingOptions').''; print "\n"; -if (!empty($user->admin)) -{ - // TO DO Mutualize code for yes/no constants - print ''; - print ''.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO").''; - if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - print ''; - - print ''; - print ''.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE").''; - if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) { - print ''; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - } else { - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - } - print ''; +// TO DO Mutualize code for yes/no constants +print ''; +print ''.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_TODO").''; +if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_TODO)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; } +print ''; + +print ''; +print ''.$langs->trans("ACCOUNTING_LIST_SORT_VENTILATION_DONE").''; +if (!empty($conf->global->ACCOUNTING_LIST_SORT_VENTILATION_DONE)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; // Param a user $user->rights->accounting->chartofaccount can access foreach ($list_binding as $key) { - print ''; + print ''; - // Param - $label = $langs->trans($key); - print ''.$label.''; - // Value - print ''; - if ($key == 'ACCOUNTING_DATE_START_BINDING') { + // Param + $label = $langs->trans($key); + print ''.$label.''; + // Value + print ''; + if ($key == 'ACCOUNTING_DATE_START_BINDING') { print $form->selectDate(($conf->global->$key ? $db->idate($conf->global->$key) : -1), $key, 0, 0, 1); } else { print ''; } - print ''; - - print ''; + print ''; + print ''; } +print ''; +print ''.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_SALES").''; +if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_SALES)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; + +print ''; +print ''.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_PURCHASES").''; +if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_PURCHASES)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; + +print ''; +print ''.$langs->trans("ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS").''; +if (!empty($conf->global->ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS)) { + print ''; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; +} else { + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; +} +print ''; print ''; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index f3612133100..a181586815f 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -58,23 +58,23 @@ $origin = GETPOST('origin', 'alpha'); $originid = GETPOST('originid', 'int'); $confirm = GETPOST('confirm', 'alpha'); -$fulldayevent = GETPOST('fullday'); +$fulldayevent = GETPOST('fullday', 'alpha'); -$aphour = GETPOST('aphour'); -$apmin = GETPOST('apmin'); -$p2hour = GETPOST('p2hour'); -$p2min = GETPOST('p2min'); +$aphour = GETPOST('aphour', 'int'); +$apmin = GETPOST('apmin', 'int'); +$p2hour = GETPOST('p2hour', 'int'); +$p2min = GETPOST('p2min', 'int'); -$addreminder = GETPOST('addreminder'); -$offsetvalue = GETPOST('offsetvalue'); -$offsetunit = GETPOST('offsetunittype_duration'); -$remindertype = GETPOST('selectremindertype'); -$modelmail = GETPOST('actioncommsendmodel_mail'); +$addreminder = GETPOST('addreminder', 'alpha'); +$offsetvalue = GETPOST('offsetvalue', 'int'); +$offsetunit = GETPOST('offsetunittype_duration', 'aZ09'); +$remindertype = GETPOST('selectremindertype', 'aZ09'); +$modelmail = GETPOST('actioncommsendmodel_mail', 'int'); //var_dump($_POST); exit; -$datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth"), GETPOST("apday"), GETPOST("apyear")); -$datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month"), GETPOST("p2day"), GETPOST("p2year")); +$datep = dol_mktime($fulldayevent ? '00' : $aphour, $fulldayevent ? '00' : $apmin, 0, GETPOST("apmonth", 'int'), GETPOST("apday", 'int'), GETPOST("apyear", 'int')); +$datef = dol_mktime($fulldayevent ? '23' : $p2hour, $fulldayevent ? '59' : $p2min, $fulldayevent ? '59' : '0', GETPOST("p2month", 'int'), GETPOST("p2day", 'int'), GETPOST("p2year", 'int')); // Security check $socid = GETPOST('socid', 'int'); @@ -391,19 +391,7 @@ if (empty($reshook) && $action == 'add') if ($addreminder == 'on'){ $actionCommReminder = new ActionCommReminder($db); - if ($offsetunit == 'minute'){ - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'i'); - } elseif ($offsetunit == 'hour'){ - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'h'); - } elseif ($offsetunit == 'day') { - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'd'); - } elseif ($offsetunit == 'week') { - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'w'); - } elseif ($offsetunit == 'month') { - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'm'); - } elseif ($offsetunit == 'year') { - $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'y'); - } + $dateremind = dol_time_plus_duree($datep, -$offsetvalue, 'i'); $actionCommReminder->dateremind = $dateremind; $actionCommReminder->typeremind = $remindertype; @@ -418,15 +406,20 @@ if (empty($reshook) && $action == 'add') if ($res <= 0){ // If error - $db->rollback(); + $error++; $langs->load("errors"); - $error = $langs->trans('ErrorReminderActionCommCreation'); - setEventMessages($error, null, 'errors'); + $error = $langs->trans('ErrorReminderActionCommCreation').' '.$actionCommReminder->error; + setEventMessages($error, $actionCommReminder->errors, 'errors'); $action = 'create'; $donotclearsession = 1; } } - $db->commit(); + if ($error) { + $db->rollback(); + } else { + $db->commit(); + } + if (!empty($backtopage)) { dol_syslog("Back to ".$backtopage.($moreparam ? (preg_match('/\?/', $backtopage) ? '&'.$moreparam : '?'.$moreparam) : '')); @@ -929,9 +922,9 @@ if ($action == 'create') print '     -     '; //print ' - '; if (GETPOST("afaire") == 1) { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend'); } else { - print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 2, 0, 'fulldayend'); + print $form->selectDate($datef, 'p2', 1, 1, 1, "action", 1, 0, 0, 'fulldayend'); } print ''; @@ -1208,7 +1201,7 @@ if ($action == 'create') //Time Type print ''.$langs->trans("TimeType").''; - print $form->selectTypeDuration('offsetunit'); + print $form->selectTypeDuration('offsetunit', 'i'); print ''; //Reminder Type diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php index 2d327cfc409..16384edfcde 100644 --- a/htdocs/comm/action/class/actioncommreminder.class.php +++ b/htdocs/comm/action/class/actioncommreminder.class.php @@ -50,6 +50,9 @@ class ActionCommReminder extends CommonObject */ public $picto = 'generic'; + const STATUS_TODO = 0; + const STATUS_DONE = 1; + /** * 'type' if the field format. @@ -79,7 +82,7 @@ class ActionCommReminder extends CommonObject 'typeremind' => array('type'=>'varchar(32)', 'label'=>'TypeRemind', 'visible'=>-1, 'enabled'=>1, 'position'=>55, 'notnull'=>1, 'comment'=>"email, browser, sms",), 'fk_user' => array('type'=>'integer', 'label'=>'User', 'visible'=>-1, 'enabled'=>1, 'position'=>65, 'notnull'=>1, 'index'=>1,), 'offsetvalue' => array('type'=>'integer', 'label'=>'OffsetValue', 'visible'=>1, 'enabled'=>1, 'position'=>56, 'notnull'=>1,), - 'offsetunit' => array('type'=>'varchar(1)', 'label'=>'OffsetUnit', 'visible'=>1, 'enabled'=>1, 'position'=>57, 'notnull'=>1, 'comment'=>"m, h, d, w",), + 'offsetunit' => array('type'=>'varchar(1)', 'label'=>'OffsetUnit', 'visible'=>1, 'enabled'=>1, 'position'=>57, 'notnull'=>1, 'comment'=>"y, m, d, w, h, i",), 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>58, 'notnull'=>1, 'default'=>0, 'index'=>0, 'arrayofkeyval'=>array('0'=>'ToDo', '1'=>'Done')), 'fk_actioncomm' => array('type'=>'integer', 'label'=>'Project', 'visible'=>1, 'enabled'=>1, 'position'=>59, 'notnull'=>1, 'index'=>1,), 'fk_email_template' => array('type'=>'integer', 'label'=>'EmailTemplate', 'visible'=>1, 'enabled'=>1, 'position'=>60, 'notnull'=>0), @@ -121,9 +124,6 @@ class ActionCommReminder extends CommonObject */ public $fk_email_template; - const STATUS_TODO = 0; - const STATUS_DONE = 1; - // END MODULEBUILDER PROPERTIES diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index ce3a9f26509..b2c38b3e13e 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1207,7 +1207,7 @@ if (empty($action) || $action == 'show_month') // View by month print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); print ''; - print '
'; + print '
'; print ''; print ' '; // Column title of weeks numbers @@ -1215,7 +1215,7 @@ if (empty($action) || $action == 'show_month') // View by month $i = 0; while ($i < 7) { - print ' '; - print ''; - print ''; - print ''; + $colspan = 3; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + $colspan--; + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + $colspan--; + print ''; + } + print ''; print ''; print ''; } diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 9b6de313b65..0f706c3ccae 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -327,21 +327,24 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; // Eat by - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + print ''; + } // Sell by - print ''; - print ''; - + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + print ''; + } // Other attributes $cols = 2; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php index 0fb3c4a0388..ec5e3ebde69 100644 --- a/htdocs/product/stock/productlot_list.php +++ b/htdocs/product/stock/productlot_list.php @@ -99,6 +99,12 @@ $arrayfields = array( 't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), //'t.statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000), ); +if (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + unset($arrayfields['t.sellby']); +} +if (!empty($conf->global->PRODUCT_DISABLE_EATBY)) { + unset($arrayfields['t.eatby']); +} // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index 98826ca6799..88cced3b99d 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -103,14 +103,18 @@ if (!empty($conf->productbatch->enabled) && print ''; print ''; print ''; - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } print ''; } diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index f725a5ebbfe..0164e99bd37 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -107,12 +107,16 @@ if (!empty($conf->productbatch->enabled) && print ''; print ''; - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } print ''; } diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index 131be53c756..329c557e2f8 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -208,14 +208,14 @@ if ($action == 'create_ticket' && GETPOST('add', 'alpha')) { // Send email to customer $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubject', $object->ref, $object->track_id); - $message .= ($conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->transnoentities('TicketNewEmailBody'))."\n\n"; - $message .= $langs->transnoentities('TicketNewEmailBodyInfosTicket')."\n"; + $message = ($conf->global->TICKET_MESSAGE_MAIL_NEW ? $conf->global->TICKET_MESSAGE_MAIL_NEW : $langs->transnoentities('TicketNewEmailBody')) . '

'; + $message .= $langs->transnoentities('TicketNewEmailBodyInfosTicket') . '
'; $url_public_ticket = ($conf->global->TICKET_URL_PUBLIC_INTERFACE ? $conf->global->TICKET_URL_PUBLIC_INTERFACE.'/' : dol_buildpath('/public/ticket/view.php', 2)).'?track_id='.$object->track_id; - $infos_new_ticket = $langs->transnoentities('TicketNewEmailBodyInfosTrackId', ''.$object->track_id.'')."\n"; - $infos_new_ticket .= $langs->transnoentities('TicketNewEmailBodyInfosTrackUrl')."\n\n"; + $infos_new_ticket = $langs->transnoentities('TicketNewEmailBodyInfosTrackId', ''.$object->track_id.'') . '
'; + $infos_new_ticket .= $langs->transnoentities('TicketNewEmailBodyInfosTrackUrl') . '

'; - $message .= dol_nl2br($infos_new_ticket); + $message .= $infos_new_ticket; $message .= $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE ? $conf->global->TICKET_MESSAGE_MAIL_SIGNATURE : $langs->transnoentities('TicketMessageMailSignatureText'); $sendto = GETPOST('email', 'alpha'); @@ -225,14 +225,12 @@ if ($action == 'create_ticket' && GETPOST('add', 'alpha')) { $sendtocc = ''; $deliveryreceipt = 0; - $message = dol_nl2br($message); - if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; } include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1); + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', 'tic'.$object->id, '', 'ticket'); if ($mailfile->error || $mailfile->errors) { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); } else { @@ -247,34 +245,21 @@ if ($action == 'create_ticket' && GETPOST('add', 'alpha')) { if ($sendto) { $subject = '['.$conf->global->MAIN_INFO_SOCIETE_NOM.'] '.$langs->transnoentities('TicketNewEmailSubjectAdmin', $object->ref, $object->track_id); - $message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id)."\n\n"; + $message_admin = $langs->transnoentities('TicketNewEmailBodyAdmin', $object->track_id) . '

'; $message_admin .= ''; $message_admin .= ''; $message_admin .= '

'.$langs->trans('Message').' :
'.$object->message.'

'; @@ -283,14 +268,12 @@ if ($action == 'create_ticket' && GETPOST('add', 'alpha')) { $from = $conf->global->MAIN_INFO_SOCIETE_NOM.' <'.$conf->global->TICKET_NOTIFICATION_EMAIL_FROM.'>'; $replyto = $from; - $message_admin = dol_nl2br($message_admin); - if (!empty($conf->global->TICKET_DISABLE_MAIL_AUTOCOPY_TO)) { $old_MAIN_MAIL_AUTOCOPY_TO = $conf->global->MAIN_MAIL_AUTOCOPY_TO; $conf->global->MAIN_MAIL_AUTOCOPY_TO = ''; } include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1); + $mailfile = new CMailFile($subject, $sendto, $from, $message_admin, $filepath, $mimetype, $filename, $sendtocc, '', $deliveryreceipt, -1, '', '', 'tic'.$object->id, '', 'ticket'); if ($mailfile->error || $mailfile->errors) { setEventMessages($mailfile->error, $mailfile->errors, 'errors'); } else { diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 7bc99977943..27722c29ed4 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -966,8 +966,12 @@ if ($action == 'create') if (!empty($conf->productbatch->enabled)) { print ''; - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } } print "\n"; } @@ -1114,12 +1118,16 @@ if ($action == 'create') if (!empty($product->status_batch)) { print ''; - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } } else { print ''; } @@ -1807,10 +1815,14 @@ if ($action == 'create') if ($conf->productbatch->enabled && !empty($lines[$i]->product->status_batch)) { print ''; } print ''; @@ -1856,11 +1868,14 @@ if ($action == 'create') $detail = ''; if ($lines[$i]->product->status_batch) { - $detail .= $langs->trans("Batch").': '.$lines[$i]->batch; + $detail .= $langs->trans("Batch").': '.$lines[$i]->batch; + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { $detail .= ' - '.$langs->trans("SellByDate").': '.dol_print_date($lines[$i]->sellby, "day"); + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { $detail .= ' - '.$langs->trans("EatByDate").': '.dol_print_date($lines[$i]->eatby, "day"); - - $detail .= '
'; + } + $detail .= '
'; print $form->textwithtooltip(img_picto('', 'object_barcode').' '.$langs->trans("DetailBatchNumber"), $detail); } else { diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 728c076d1c8..efc6391bc58 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -333,7 +333,7 @@ print "\n"; print ''; @@ -383,6 +383,21 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code print ''; } +// Activate iDEAL +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // TODO Not used by current code +{ + print ''; +} + // Warehouse for automatic decrement //if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // warehouse to reduce stock for online payment //{ diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index f3bb30d7efb..4113f49cd04 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -294,8 +294,8 @@ class Stripe extends CommonObject /** * Get the Stripe payment intent. Create it with confirmnow=false * Warning. If a payment was tried and failed, a payment intent was created. - * But if we change something on object to pay (amount or other), reusing same payment intent is not allowed. - * Recommanded solution is to recreate a new payment intent each time we need one (old one will be automatically closed after a delay), + * But if we change something on object to pay (amount or other), reusing same payment intent is not allowed by Stripe. + * Recommended solution is to recreate a new payment intent each time we need one (old one will be automatically closed after a delay), * that's why i comment the part of code to retreive a payment intent with object id (never mind if we cumulate payment intent with old ones that will not be used) * Note: This is used when option STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION is on when making a payment from the public/payment/newpayment.php page * but not when using the STRIPE_USE_NEW_CHECKOUT. @@ -345,14 +345,14 @@ class Stripe extends CommonObject $paymentintent = null; - if (is_object($object)) + if (is_object($object) && ! empty($conf->global->STRIPE_REUSE_EXISTING_INTENT_IF_FOUND)) { // Warning. If a payment was tried and failed, a payment intent was created. - // But if we change someting on object to pay (amount or other that does not change the idempotency key), reusing same payment intent is not allowed. - // Recommanded solution is to recreate a new payment intent each time we need one (old one will be automatically closed after a delay), Stripe will + // But if we change something on object to pay (amount or other that does not change the idempotency key), reusing same payment intent is not allowed by Stripe. + // Recommended solution is to recreate a new payment intent each time we need one (old one will be automatically closed by Stripe after a delay), Stripe will // automatically return the existing payment intent if idempotency is provided when we try to create the new one. // That's why we can comment the part of code to retreive a payment intent with object id (never mind if we cumulate payment intent with old ones that will not be used) - /* + $sql = "SELECT pi.ext_payment_id, pi.entity, pi.fk_facture, pi.sourcetype, pi.ext_payment_site"; $sql.= " FROM " . MAIN_DB_PREFIX . "prelevement_facture_demande as pi"; $sql.= " WHERE pi.fk_facture = " . $object->id; @@ -388,7 +388,7 @@ class Stripe extends CommonObject $this->error = $e->getMessage(); } } - }*/ + } } if (empty($paymentintent)) @@ -402,12 +402,17 @@ class Stripe extends CommonObject if (is_object($object->thirdparty) && $object->thirdparty->id > 0) $metadata['dol_thirdparty_id'] = $object->thirdparty->id; } + // list of payment method types + $paymentmethodtypes = array("card"); + if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT) ) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC()) + if (!empty($conf->global->STRIPE_IDEAL) ) $paymentmethodtypes[] = "ideal"; //&& ($object->thirdparty->isInEEC()) + $dataforintent = array( "confirm" => $confirmnow, // Do not confirm immediatly during creation of intent "confirmation_method" => $mode, "amount" => $stripeamount, "currency" => $currency_code, - "payment_method_types" => array("card"), + "payment_method_types" => $paymentmethodtypes, "description" => $description, "statement_descriptor_suffix" => dol_trunc($tag, 10, 'right', 'UTF-8', 1), // 22 chars that appears on bank receipt (company + description) //"save_payment_method" => true, @@ -566,14 +571,19 @@ class Stripe extends CommonObject if (is_object($object->thirdparty) && $object->thirdparty->id > 0) $metadata['dol_thirdparty_id'] = $object->thirdparty->id; } + // list of payment method types + $paymentmethodtypes = array("card"); + if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT) ) $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC()) + // iDEAL not supported with setupIntent + $dataforintent = array( "confirm" => $confirmnow, // Do not confirm immediatly during creation of intent - "payment_method_types" => array("card"), - "description" => $description, + "payment_method_types" => $paymentmethodtypes, "usage" => "off_session", "metadata" => $metadata ); if (!is_null($customer)) $dataforintent["customer"] = $customer; + if (!is_null($description)) $dataforintent["description"] = $description; // payment_method = // payment_method_types = array('card') //var_dump($dataforintent); diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 2b985bde752..8185ddbec92 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1077,6 +1077,15 @@ table[summary="list_of_modules"] .fa-cog { height: 100px; } +.maxscreenheightless200 { + max-height: px; /* we guarantee height of 500 */ +} +.maxscreenheightless300 { + max-height: px; /* we guarantee height of 500 */ +} + + + /* ============================================================================== */ /* Styles to hide objects */ @@ -2074,90 +2083,7 @@ a.tmenuimage:hover{ /* Do not load menu img for other if hidden to save bandwidth */ - - - - div.mainmenu.home{ - background-image: url(); - background-position-x: center; - } - - div.mainmenu.billing { - background-image: url(); - } - - div.mainmenu.accountancy { - background-image: url(); - } - - div.mainmenu.agenda { - background-image: url(); - } - - div.mainmenu.bank { - background-image: url(); - } - - div.mainmenu.cashdesk { - background-image: url(); - } - - div.mainmenu.takepos { - background-image: url(); - } - - div.mainmenu.companies { - background-image: url(); - } - - div.mainmenu.commercial { - background-image: url(); - } - - div.mainmenu.ecm { - background-image: url(); - } - - div.mainmenu.externalsite { - background-image: url(); - } - - div.mainmenu.ftp { - background-image: url(); - } - - div.mainmenu.hrm { - background-image: url(); - } - - div.mainmenu.members { - background-image: url(); - } - - div.mainmenu.products { - background-image: url(); - } - - div.mainmenu.mrp { - background-image: url(); - } - - div.mainmenu.project { - background-image: url(); - } - - div.mainmenu.ticket { - background-image: url(); - } - - div.mainmenu.tools { - background-image: url(); - } - - div.mainmenu.website { - background-image: url(); - } - + 'name of class for div') @@ -4514,7 +4440,9 @@ table.cal_event td.cal_event_right { padding: 4px 4px !important; } .cal_event_notbusy a.cal_event_title:hover { color: #111111; font-weight: normal !important; color:rgba(255,255,255,.75); } .cal_event_busy { } .cal_peruserviewname { max-width: 140px; height: 22px; } +.cal_event span.badge.badge-status { border: 1px solid #aaa; } table.cal_month tr td table.nobordernopadding tr td { padding: 0 2px 0 2px; } +table.cal_month tr.liste_titre td.tdfordaytitle { min-width: 120px; } a.dayevent-aday { padding-left: 8px; } diff --git a/htdocs/ticket/card.php b/htdocs/ticket/card.php index d5da98b4a84..8ac7d7cad1f 100644 --- a/htdocs/ticket/card.php +++ b/htdocs/ticket/card.php @@ -127,6 +127,7 @@ $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +$error = 0; if (empty($reshook)) { // Purge search criteria if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers{ @@ -157,6 +158,8 @@ if (empty($reshook)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")), null, 'errors'); $action = 'create'; } + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) $error++; if (!$error) { $db->begin(); @@ -174,12 +177,10 @@ if (empty($reshook)) { $object->fk_project = GETPOST('projectid', 'int'); - $ret = $extrafields->setOptionalsFromPost(null, $object); - $id = $object->create($user); if ($id <= 0) { $error++; - setEventMessage($object->error, $object->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $action = 'create'; } @@ -305,7 +306,7 @@ if (empty($reshook)) { $ret = $object->update($user); if ($ret <= 0) { $error++; - setEventMessage($object->error, $object->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $action = 'edit'; } @@ -560,18 +561,22 @@ if (empty($reshook)) { // Action to update one extrafield if ($action == "update_extras" && !empty($permissiontoadd)) { $object->fetch(GETPOST('id', 'int'), '', GETPOST('track_id', 'alpha')); - $attributekey = GETPOST('attribute', 'alpha'); - $attributekeylong = 'options_' . $attributekey; - $object->array_options['options_' . $attributekey] = GETPOST($attributekeylong, ' alpha'); - $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); - if ($result > 0) { - setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); - $action = 'view'; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'edit_extras'; + $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); + if ($ret < 0) $error++; + + if (!$error) { + $result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user); + if ($result > 0) { + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); + $action = 'view'; + } else { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + } } + + if ($error) $action = 'edit_extras'; } if ($action == "change_property" && GETPOST('btn_update_ticket_prop', 'alpha') && $user->rights->ticket->write) { @@ -1022,15 +1027,15 @@ if (empty($action) || $action == 'view' || $action == 'addlink' || $action == 'd } else { // Type print ''; // Group print ''; // Severity print ''; } print '
'; + print ' '; $numdayinweek = (($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7); if (!empty($conf->dol_optimize_smallscreen)) { @@ -1308,12 +1308,12 @@ if (empty($action) || $action == 'show_month') // View by month print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); print ''; - print '
'; + print '
'; print ''; print ' '; $i = 0; while ($i < 7) { - echo ' \n"; + echo ' \n"; $i++; } echo " \n"; @@ -1368,11 +1368,10 @@ if (empty($action) || $action == 'show_month') // View by month print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); print ''; - print '
'; + print '
'; echo '
'.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7))."'.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7))."
'; echo ' '; - echo ' '; echo ' \n"; echo " \n"; diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index cc7db3db852..e4d432b234a 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -348,7 +348,8 @@ class Orders extends DolibarrApi $request_data->fk_unit, $request_data->origin, $request_data->origin_id, - $request_data->multicurrency_subprice + $request_data->multicurrency_subprice, + $request_data->ref_ext ); if ($updateRes > 0) { @@ -406,7 +407,9 @@ class Orders extends DolibarrApi $request_data->special_code, $request_data->array_options, $request_data->fk_unit, - $request_data->multicurrency_subprice + $request_data->multicurrency_subprice, + 0, + $request_data->ref_ext ); if ($updateRes > 0) { @@ -456,6 +459,40 @@ class Orders extends DolibarrApi } } + /** + * Get contacts of given order + * + * Return an array with contact informations + * + * @param int $id ID of order + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * + * @url GET {id}/contacts + * + * @return array data without useless information + * + * @throws RestException + */ + public function getContacts($id, $type = '') + { + if (! DolibarrApiAccess::$user->rights->commande->lire) { + throw new RestException(401); + } + + $result = $this->commande->fetch($id); + if ( ! $result ) { + throw new RestException(404, 'Order not found'); + } + + if ( ! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $contacts = $this->commande->liste_contact(-1, 'external', 0, $type); + + return $this->_cleanObjectDatas($contacts); + } + /** * Add a contact type of given order * @@ -487,15 +524,24 @@ class Orders extends DolibarrApi $result = $this->commande->add_contact($contactid, $type, 'external'); - if (!$result) { + if ($result < 0) { throw new RestException(500, 'Error when added the contact'); } - return $this->commande; + if ($result == 0) { + throw new RestException(304, 'contact already added'); + } + + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contact linked to the order' + ) + ); } /** - * Delete a contact type of given order + * Unlink a contact type of given order * * @param int $id Id of order to update * @param int $rowid Row key of the contact in the array contact_ids. @@ -510,26 +556,31 @@ class Orders extends DolibarrApi */ public function deleteContact($id, $rowid) { - if (!DolibarrApiAccess::$user->rights->commande->creer) { + if (! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); } $result = $this->commande->fetch($id); - if (!$result) { + if (! $result) { throw new RestException(404, 'Order not found'); } - if (!DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { + if (! DolibarrApi::_checkAccessToResource('commande', $this->commande->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->commande->delete_contact($rowid); + $result = $this->commande->delete_linked_contact($rowid); if (!$result) { throw new RestException(500, 'Error when deleted the contact'); } - return $this->commande; + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contact unlinked from order' + ) + ); } /** diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 77ba4456c1c..73dd2cee9fb 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1004,6 +1004,11 @@ class Commande extends CommonOrder $origintype = $this->element; } + // ref_ext + if (empty($line->ref_ext)) { + $line->ref_ext = ''; + } + $result = $this->addline( $line->desc, $line->subprice, @@ -1029,7 +1034,9 @@ class Commande extends CommonOrder $line->array_options, $line->fk_unit, $origintype, - $originid + $originid, + 0, + $line->ref_ext ); if ($result < 0) { @@ -1215,6 +1222,13 @@ class Commande extends CommonOrder $this->date_validation = ''; if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $this->ref_client = ''; + // Do not clone ref_ext + $num = count($this->lines); + for ($i = 0; $i < $num; $i++) + { + $this->lines[$i]->ref_ext = ''; + } + // Create clone $this->context['createfromclone'] = 'createfromclone'; $result = $this->create($user); @@ -1423,6 +1437,7 @@ class Commande extends CommonOrder * @param string $origin Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be 'orderdet', 'propaldet'..., else 'order','propal,'.... * @param int $origin_id Depend on global conf MAIN_CREATEFROM_KEEP_LINE_ORIGIN_INFORMATION can be Id of origin object (aka line id), else object id * @param double $pu_ht_devise Unit price in currency + * @param string $ref_ext line external reference * @return int >0 if OK, <0 if KO * * @see add_product() @@ -1432,13 +1447,13 @@ class Commande extends CommonOrder * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) */ - public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $info_bits = 0, $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $date_start = '', $date_end = '', $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $info_bits = 0, $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $date_start = '', $date_end = '', $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0, $ref_ext = '') { global $mysoc, $conf, $langs, $user; $logtext = "::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent"; $logtext .= ", info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start"; - $logtext .= ", date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit, origin=$origin, origin_id=$origin_id, pu_ht_devise=$pu_ht_devise"; + $logtext .= ", date_end=$date_end, type=$type special_code=$special_code, fk_unit=$fk_unit, origin=$origin, origin_id=$origin_id, pu_ht_devise=$pu_ht_devise, ref_ext=$ref_ext"; dol_syslog(get_class($this).$logtext, LOG_DEBUG); if ($this->statut == self::STATUS_DRAFT) @@ -1446,6 +1461,7 @@ class Commande extends CommonOrder include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Clean parameters + if (empty($remise_percent)) $remise_percent = 0; if (empty($qty)) $qty = 0; if (empty($info_bits)) $info_bits = 0; @@ -1455,6 +1471,7 @@ class Commande extends CommonOrder if (empty($txlocaltax2)) $txlocaltax2 = 0; if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0; if (empty($this->fk_multicurrency)) $this->fk_multicurrency = 0; + if (empty($ref_ext)) $ref_ext = ''; $remise_percent = price2num($remise_percent); $qty = price2num($qty); @@ -1570,6 +1587,7 @@ class Commande extends CommonOrder $this->line->label = $label; $this->line->desc = $desc; $this->line->qty = $qty; + $this->line->ref_ext = $ref_ext; $this->line->vat_src_code = $vat_src_code; $this->line->tva_tx = $txtva; @@ -1977,7 +1995,7 @@ class Commande extends CommonOrder // phpcs:enable $this->lines = array(); - $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx,'; + $sql = 'SELECT l.rowid, l.fk_product, l.fk_parent_line, l.product_type, l.fk_commande, l.label as custom_label, l.description, l.price, l.qty, l.vat_src_code, l.tva_tx, l.ref_ext,'; $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.fk_remise_except, l.remise_percent, l.subprice, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht, l.rang, l.info_bits, l.special_code,'; $sql .= ' l.total_ht, l.total_ttc, l.total_tva, l.total_localtax1, l.total_localtax2, l.date_start, l.date_end,'; $sql .= ' l.fk_unit,'; @@ -2012,6 +2030,7 @@ class Commande extends CommonOrder $line->description = $objp->description; // Description line $line->product_type = $objp->product_type; $line->qty = $objp->qty; + $line->ref_ext = $objp->ref_ext; $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; @@ -2981,13 +3000,14 @@ class Commande extends CommonOrder * @param string $fk_unit Code of the unit to use. Null to use the default one * @param double $pu_ht_devise Amount in currency * @param int $notrigger disable line update trigger + * @param string $ref_ext external reference * @return int < 0 if KO, > 0 if OK */ - public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '') { global $conf, $mysoc, $langs, $user; - dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code"); + dol_syslog(get_class($this)."::updateline id=$rowid, desc=$desc, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, price_base_type=$price_base_type, info_bits=$info_bits, date_start=$date_start, date_end=$date_end, type=$type, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, special_code=$special_code, ref_ext=$ref_ext"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; if ($this->statut == Commande::STATUS_DRAFT) @@ -3000,6 +3020,7 @@ class Commande extends CommonOrder if (empty($txlocaltax2)) $txlocaltax2 = 0; if (empty($remise_percent)) $remise_percent = 0; if (empty($special_code) || $special_code == 3) $special_code = 0; + if (empty($ref_ext)) $ref_ext = ''; if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); @@ -3104,6 +3125,7 @@ class Commande extends CommonOrder $this->line->label = $label; $this->line->desc = $desc; $this->line->qty = $qty; + $this->line->ref_ext = $ref_ext; $this->line->vat_src_code = $vat_src_code; $this->line->tva_tx = $txtva; @@ -3970,6 +3992,8 @@ class OrderLine extends CommonOrderLine */ public $label; + public $ref_ext; + public $fk_remise_except; public $rang = 0; public $fk_fournprice; @@ -4014,7 +4038,7 @@ class OrderLine extends CommonOrderLine public function fetch($rowid) { $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_parent_line, cd.fk_product, cd.product_type, cd.label as custom_label, cd.description, cd.price, cd.qty, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx,'; - $sql .= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,'; + $sql .= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice, cd.ref_ext,'; $sql .= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_localtax1, cd.total_localtax2, cd.total_ttc, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht, cd.rang, cd.special_code,'; $sql .= ' cd.fk_unit,'; $sql .= ' cd.fk_multicurrency, cd.multicurrency_code, cd.multicurrency_subprice, cd.multicurrency_total_ht, cd.multicurrency_total_tva, cd.multicurrency_total_ttc,'; @@ -4036,6 +4060,7 @@ class OrderLine extends CommonOrderLine $this->qty = $objp->qty; $this->price = $objp->price; $this->subprice = $objp->subprice; + $this->ref_ext = $objp->ref_ext; $this->vat_src_code = $objp->vat_src_code; $this->tva_tx = $objp->tva_tx; $this->localtax1_tx = $objp->localtax1_tx; @@ -4205,6 +4230,7 @@ class OrderLine extends CommonOrderLine if (empty($this->special_code)) $this->special_code = 0; if (empty($this->fk_parent_line)) $this->fk_parent_line = 0; if (empty($this->pa_ht)) $this->pa_ht = 0; + if (empty($this->ref_ext)) $this->ref_ext = ''; // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0 && $pa_ht_isemptystring) @@ -4224,7 +4250,7 @@ class OrderLine extends CommonOrderLine // Insertion dans base de la ligne $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commandedet'; - $sql .= ' (fk_commande, fk_parent_line, label, description, qty, '; + $sql .= ' (fk_commande, fk_parent_line, label, description, qty, ref_ext,'; $sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; $sql .= ' fk_product, product_type, remise_percent, subprice, price, remise, fk_remise_except,'; $sql .= ' special_code, rang, fk_product_fournisseur_price, buy_price_ht,'; @@ -4237,6 +4263,7 @@ class OrderLine extends CommonOrderLine $sql .= " ".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null").","; $sql .= " '".$this->db->escape($this->desc)."',"; $sql .= " '".price2num($this->qty)."',"; + $sql .= " '".$this->db->escape($this->ref_ext)."',"; $sql .= " ".(empty($this->vat_src_code) ? "''" : "'".$this->db->escape($this->vat_src_code)."'").","; $sql .= " '".price2num($this->tva_tx)."',"; $sql .= " '".price2num($this->localtax1_tx)."',"; @@ -4347,6 +4374,7 @@ class OrderLine extends CommonOrderLine if (empty($this->product_type)) $this->product_type = 0; if (empty($this->fk_parent_line)) $this->fk_parent_line = 0; if (empty($this->pa_ht)) $this->pa_ht = 0; + if (empty($this->ref_ext)) $this->ref_ext = ''; // if buy price not defined, define buyprice as configured in margin admin if ($this->pa_ht == 0 && $pa_ht_isemptystring) @@ -4372,6 +4400,7 @@ class OrderLine extends CommonOrderLine $sql .= " , localtax1_type='".$this->db->escape($this->localtax1_type)."'"; $sql .= " , localtax2_type='".$this->db->escape($this->localtax2_type)."'"; $sql .= " , qty=".price2num($this->qty); + $sql .= " , ref_ext='".$this->db->escape($this->ref_ext)."'"; $sql .= " , subprice=".price2num($this->subprice).""; $sql .= " , remise_percent=".price2num($this->remise_percent).""; $sql .= " , price=".price2num($this->price).""; // TODO A virer diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index e40c614ea08..20f705a8ed9 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -818,6 +818,11 @@ class Facture extends CommonInvoice $origintype = $this->element; } + // init ref_ext + if (empty($line->ref_ext)) { + $line->ref_ext = ''; + } + $result = $this->addline( $line->desc, $line->subprice, @@ -847,7 +852,8 @@ class Facture extends CommonInvoice $line->situation_percent, $line->fk_prev_id, $line->fk_unit, - $line->pu_ht_devise + $line->pu_ht_devise, + $line->ref_ext ); if ($result < 0) { @@ -1073,6 +1079,7 @@ class Facture extends CommonInvoice $facture->lines[$i]->total_localtax1 = -$facture->lines[$i]->total_localtax1; $facture->lines[$i]->total_localtax2 = -$facture->lines[$i]->total_localtax2; $facture->lines[$i]->total_ttc = -$facture->lines[$i]->total_ttc; + $facture->lines[$i]->ref_ext = ''; } } @@ -1190,6 +1197,8 @@ class Facture extends CommonInvoice $object->lines[$i]->date_end = $newLast; } } + + $object->lines[$i]->ref_ext = ''; // Do not clone ref_ext } // Create clone @@ -1658,7 +1667,7 @@ class Facture extends CommonInvoice $this->lines = array(); $sql = 'SELECT l.rowid, l.fk_facture, l.fk_product, l.fk_parent_line, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; - $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; + $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice, l.ref_ext,'; $sql .= ' l.situation_percent, l.fk_prev_id,'; $sql .= ' l.rang, l.special_code,'; $sql .= ' l.date_start as date_start, l.date_end as date_end,'; @@ -1697,6 +1706,7 @@ class Facture extends CommonInvoice $line->fk_product_type = $objp->fk_product_type; // Type of product $line->qty = $objp->qty; $line->subprice = $objp->subprice; + $line->ref_ext = $objp->ref_ext; // line external ref $line->vat_src_code = $objp->vat_src_code; $line->tva_tx = $objp->tva_tx; @@ -1819,6 +1829,7 @@ class Facture extends CommonInvoice // Clean parameters if (empty($this->type)) $this->type = self::TYPE_STANDARD; if (isset($this->ref)) $this->ref = trim($this->ref); + if (isset($this->ref_ext)) $this->ref_ext = trim($this->ref_ext); if (isset($this->ref_client)) $this->ref_client = trim($this->ref_client); if (isset($this->increment)) $this->increment = trim($this->increment); if (isset($this->close_code)) $this->close_code = trim($this->close_code); @@ -1837,6 +1848,7 @@ class Facture extends CommonInvoice // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."facture SET"; $sql .= " ref=".(isset($this->ref) ? "'".$this->db->escape($this->ref)."'" : "null").","; + $sql .= " ref_ext=".(isset($this->ref_ext) ? "'".$this->db->escape($this->ref_ext)."'" : "null").","; $sql .= " type=".(isset($this->type) ? $this->db->escape($this->type) : "null").","; $sql .= " ref_client=".(isset($this->ref_client) ? "'".$this->db->escape($this->ref_client)."'" : "null").","; $sql .= " increment=".(isset($this->increment) ? "'".$this->db->escape($this->increment)."'" : "null").","; @@ -2930,6 +2942,7 @@ class Facture extends CommonInvoice * @param int $fk_prev_id Previous situation line id reference * @param string $fk_unit Code of the unit to use. Null to use the default one * @param double $pu_ht_devise Unit price in currency + * @param string $ref_ext External reference of the line * @return int <0 if KO, Id of line if OK */ public function addline( @@ -2961,7 +2974,8 @@ class Facture extends CommonInvoice $situation_percent = 100, $fk_prev_id = 0, $fk_unit = null, - $pu_ht_devise = 0 + $pu_ht_devise = 0, + $ref_ext = '' ) { // Deprecation warning if ($label) { @@ -2989,6 +3003,7 @@ class Facture extends CommonInvoice if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0; if (empty($fk_prev_id)) $fk_prev_id = 'null'; if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; + if (empty($ref_ext)) $ref_ext = ''; $remise_percent = price2num($remise_percent); $qty = price2num($qty); @@ -3082,6 +3097,7 @@ class Facture extends CommonInvoice $this->line->fk_facture = $this->id; $this->line->label = $label; // deprecated $this->line->desc = $desc; + $this->line->ref_ext = $ref_ext; $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ?abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ?-abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise @@ -3157,7 +3173,7 @@ class Facture extends CommonInvoice return -2; } } else { - dol_syslog(get_class($this)."::addline status of order must be Draft to allow use of ->addline()", LOG_ERR); + dol_syslog(get_class($this)."::addline status of invoice must be Draft to allow use of ->addline()", LOG_ERR); return -3; } } @@ -3189,9 +3205,10 @@ class Facture extends CommonInvoice * @param string $fk_unit Code of the unit to use. Null to use the default one * @param double $pu_ht_devise Unit price in currency * @param int $notrigger disable line update trigger + * @param string $ref_ext External reference of the line * @return int < 0 if KO, > 0 if OK */ - public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $ref_ext = '') { global $conf, $user; // Deprecation warning @@ -3229,6 +3246,7 @@ class Facture extends CommonInvoice if (empty($fk_parent_line) || $fk_parent_line < 0) $fk_parent_line = 0; if (empty($special_code) || $special_code == 3) $special_code = 0; if (!isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; + if (empty($ref_ext)) $ref_ext = ''; $remise_percent = price2num($remise_percent); $qty = price2num($qty); @@ -3319,6 +3337,7 @@ class Facture extends CommonInvoice $this->line->rowid = $rowid; $this->line->label = $label; $this->line->desc = $desc; + $this->line->ref_ext = $ref_ext; $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ?abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative $this->line->vat_src_code = $vat_src_code; @@ -4722,6 +4741,7 @@ class FactureLigne extends CommonInvoiceLine public $label; //! Description ligne public $desc; + public $ref_ext; // External reference of the line public $localtax1_type; // Local tax 1 type public $localtax2_type; // Local tax 2 type @@ -4792,7 +4812,7 @@ class FactureLigne extends CommonInvoiceLine public function fetch($rowid) { $sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.label as custom_label, fd.description, fd.price, fd.qty, fd.vat_src_code, fd.tva_tx,'; - $sql .= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,'; + $sql .= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice, fd.ref_ext,'; $sql .= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,'; $sql .= ' fd.info_bits, fd.special_code, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,'; $sql .= ' fd.fk_code_ventilation,'; @@ -4820,6 +4840,7 @@ class FactureLigne extends CommonInvoiceLine $this->desc = $objp->description; $this->qty = $objp->qty; $this->subprice = $objp->subprice; + $this->ref_ext = $objp->ref_ext; $this->vat_src_code = $objp->vat_src_code; $this->tva_tx = $objp->tva_tx; $this->localtax1_tx = $objp->localtax1_tx; @@ -4902,6 +4923,7 @@ class FactureLigne extends CommonInvoiceLine if (empty($this->remise_percent)) $this->remise_percent = 0; if (empty($this->info_bits)) $this->info_bits = 0; if (empty($this->subprice)) $this->subprice = 0; + if (empty($this->ref_ext)) $this->ref_ext = ''; if (empty($this->special_code)) $this->special_code = 0; if (empty($this->fk_parent_line)) $this->fk_parent_line = 0; if (empty($this->fk_prev_id)) $this->fk_prev_id = 0; @@ -4948,7 +4970,7 @@ class FactureLigne extends CommonInvoiceLine $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet'; $sql .= ' (fk_facture, fk_parent_line, label, description, qty,'; $sql .= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; - $sql .= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,'; + $sql .= ' fk_product, product_type, remise_percent, subprice, ref_ext, fk_remise_except,'; $sql .= ' date_start, date_end, fk_code_ventilation, '; $sql .= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,'; $sql .= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2,'; @@ -4971,6 +4993,7 @@ class FactureLigne extends CommonInvoiceLine $sql .= " ".((int) $this->product_type).","; $sql .= " ".price2num($this->remise_percent).","; $sql .= " ".price2num($this->subprice).","; + $sql .= " '".$this->db->escape($this->ref_ext)."',"; $sql .= ' '.(!empty($this->fk_remise_except) ? $this->fk_remise_except : "null").','; $sql .= " ".(!empty($this->date_start) ? "'".$this->db->idate($this->date_start)."'" : "null").","; $sql .= " ".(!empty($this->date_end) ? "'".$this->db->idate($this->date_end)."'" : "null").","; @@ -5097,6 +5120,7 @@ class FactureLigne extends CommonInvoiceLine // Clean parameters $this->desc = trim($this->desc); + if (empty($this->ref_ext)) $this->ref_ext = ''; if (empty($this->tva_tx)) $this->tva_tx = 0; if (empty($this->localtax1_tx)) $this->localtax1_tx = 0; if (empty($this->localtax2_tx)) $this->localtax2_tx = 0; @@ -5136,6 +5160,7 @@ class FactureLigne extends CommonInvoiceLine // Mise a jour ligne en base $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet SET"; $sql .= " description='".$this->db->escape($this->desc)."'"; + $sql .= " ref_ext='".$this->db->escape($this->ref_ext)."'"; $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null"); $sql .= ", subprice=".price2num($this->subprice).""; $sql .= ", remise_percent=".price2num($this->remise_percent).""; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index b2f8905aba9..993528464fd 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1231,7 +1231,7 @@ class ExtraFields } else { if (!$notrans) { $translabel = $langs->trans($obj->{$InfoFieldList[1]}); - $labeltoshow = dol_trunc($translabel, 18); + $labeltoshow =$translabel; } if (empty($labeltoshow)) $labeltoshow = '(not defined)'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 3daaf572ca6..7ec1a32f072 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5680,11 +5680,11 @@ class Form * @param string $selected Selected type * @return string HTML select string */ - public function selectTypeDuration($prefix, $selected = 'minute') + public function selectTypeDuration($prefix, $selected = 'i') { global $langs; - $TDurationTypes = array('year'=>$langs->trans('Years'), 'month'=>$langs->trans('Month'), 'week'=>$langs->trans('Weeks'), 'day'=>$langs->trans('Days'), 'hour'=>$langs->trans('Hours'), 'minute'=>$langs->trans('Minutes')); + $TDurationTypes = array('y'=>$langs->trans('Years'), 'm'=>$langs->trans('Month'), 'w'=>$langs->trans('Weeks'), 'd'=>$langs->trans('Days'), 'h'=>$langs->trans('Hours'), 'i'=>$langs->trans('Minutes')); $retstring = ''; if (!empty($conf->productbatch->enabled)) { print ''; - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } } else { print ''; print ''; @@ -819,8 +823,12 @@ if ($id > 0 || !empty($ref)) { print $linktoprod; print ""; print ''; - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } } else { print ''; - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } } } else { print ''; - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } print ''; // Supplier ref + Qty ordered + qty already dispatched } else { $type = 'dispatch'; @@ -1118,8 +1134,12 @@ if ($id > 0 || !empty($ref)) { print ''; if (!empty($conf->productbatch->enabled)) { print ''; - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } } print ''; print ''; @@ -1174,8 +1194,12 @@ if ($id > 0 || !empty($ref)) { $lot=new Productlot($db); $lot->fetch(0, $objp->pid, $objp->batch); print ''; - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } } else { print ''; print ''; diff --git a/htdocs/install/mysql/data/llx_c_forme_juridique.sql b/htdocs/install/mysql/data/llx_c_forme_juridique.sql index 628d42d4144..a51b2bbd70f 100644 --- a/htdocs/install/mysql/data/llx_c_forme_juridique.sql +++ b/htdocs/install/mysql/data/llx_c_forme_juridique.sql @@ -326,3 +326,14 @@ INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (178, INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (178, '17804', 'Sociedad Civil', 1); INSERT INTO llx_c_forme_juridique (fk_pays, code, libelle, active) VALUES (178, '17805', 'Sociedad Anónima', 1); +-- Algeria (id country=13) +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (13, '1300','Personne physique'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (13, '1301','Société à responsabilité limitée (SARL)'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (13, '1302','Entreprise unipersonnelle à responsabilité limitée (EURL)'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (13, '1303','Société en Nom Collectif (SNC)'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (13, '1304','société par actions (SPA)'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (13, '1305','Société en Commandite Simple (SCS)'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (13, '1306','Société en commandite par actions (SCA)'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (13, '1307','Société en participation'); +insert into llx_c_forme_juridique (fk_pays, code, libelle) values (13, '1308','Groupe de sociétés'); + diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index afd3a762ccc..e44a1d42995 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -359,6 +359,10 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (23 insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2322,232, '12','0','VAT 12%',1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (2323,232, '8','0','VAT 8%',1); +-- ALGERIA(id country=13) +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 131, 13, '0','0','TVA 0%', 1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 132, 13, '9','0','TVA 9%',1); +insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 133, 13, '19','0','TVA 19%', 1); -- Example of code to insert a vat rate 0 for each country diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 7dfccac5beb..37fcf0d785f 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -205,6 +205,8 @@ ALTER TABLE llx_recruitment_recruitmentcandidature_extrafields ADD INDEX idx_rec ALTER TABLE llx_recruitment_recruitmentcandidature ADD UNIQUE INDEX uk_recruitmentcandidature_email_msgid(email_msgid); +ALTER TABLE llx_product_attribute ADD COLUMN ref_ext VARCHAR(255) after ref; +ALTER TABLE llx_product_attribute_combination ADD COLUMN variation_ref_ext varchar(255) AFTER variation_weight; CREATE TABLE llx_product_attribute_combination_price_level @@ -312,3 +314,6 @@ ALTER TABLE llx_inventorydet ADD UNIQUE uk_inventorydet(fk_inventory, fk_warehou ALTER TABLE llx_product_attribute ADD COLUMN ref_ext varchar(255) AFTER ref; ALTER TABLE llx_product_attribute_combination ADD COLUMN variation_ref_ext varchar(255) AFTER variation_weight; + +ALTER TABLE llx_commandedet ADD COLUMN ref_ext varchar(255) AFTER label; +ALTER TABLE llx_facturedet ADD COLUMN ref_ext varchar(255) AFTER multicurrency_total_ttc; diff --git a/htdocs/install/mysql/tables/llx_commandedet.sql b/htdocs/install/mysql/tables/llx_commandedet.sql index 615ec8f269c..c7b94a46add 100644 --- a/htdocs/install/mysql/tables/llx_commandedet.sql +++ b/htdocs/install/mysql/tables/llx_commandedet.sql @@ -57,6 +57,7 @@ create table llx_commandedet rang integer DEFAULT 0, fk_unit integer DEFAULT NULL, -- lien vers table des unités import_key varchar(14), + ref_ext varchar(255) DEFAULT NULL, fk_commandefourndet integer DEFAULT NULL, -- link to detail line of commande fourn (resplenish) diff --git a/htdocs/install/mysql/tables/llx_facturedet.sql b/htdocs/install/mysql/tables/llx_facturedet.sql index ff2b28d9a7f..73e64fa1c6a 100644 --- a/htdocs/install/mysql/tables/llx_facturedet.sql +++ b/htdocs/install/mysql/tables/llx_facturedet.sql @@ -74,12 +74,7 @@ create table llx_facturedet multicurrency_subprice double(24,8) DEFAULT 0, multicurrency_total_ht double(24,8) DEFAULT 0, multicurrency_total_tva double(24,8) DEFAULT 0, - multicurrency_total_ttc double(24,8) DEFAULT 0 + multicurrency_total_ttc double(24,8) DEFAULT 0, + ref_ext varchar(255) DEFAULT NULL )ENGINE=innodb; --- --- List of codes for special_code --- --- 1 : frais de port --- 2 : ecotaxe --- diff --git a/htdocs/install/mysql/tables/llx_product_attribute.sql b/htdocs/install/mysql/tables/llx_product_attribute.sql index 7e00b14d17a..362c104b95c 100644 --- a/htdocs/install/mysql/tables/llx_product_attribute.sql +++ b/htdocs/install/mysql/tables/llx_product_attribute.sql @@ -1,5 +1,6 @@ -- ============================================================================ -- Copyright (C) 2016 Marcos García +-- Copyright (C) 2020 Laurent Destailleur -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -14,13 +15,15 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . -- +-- llx_product_attribute is table for labels of product variants attributes. For exemple: COLOR, SIZE, ... +-- The different possible values (for example BLUE, GREEN, ... for COLOR) are defined into llx_product_attribute_value. -- ============================================================================ CREATE TABLE llx_product_attribute ( rowid INT PRIMARY KEY NOT NULL AUTO_INCREMENT, ref VARCHAR(255) NOT NULL, - ref_ext varchar(255) DEFAULT NULL, + ref_ext VARCHAR(255) NULL, label VARCHAR(255) NOT NULL, rang INT DEFAULT 0 NOT NULL, entity INT DEFAULT 1 NOT NULL diff --git a/htdocs/install/mysql/tables/llx_product_attribute_combination.sql b/htdocs/install/mysql/tables/llx_product_attribute_combination.sql index afbb9bcec65..ce64eafde0e 100644 --- a/htdocs/install/mysql/tables/llx_product_attribute_combination.sql +++ b/htdocs/install/mysql/tables/llx_product_attribute_combination.sql @@ -1,5 +1,6 @@ -- ============================================================================ -- Copyright (C) 2016 Marcos García +-- Copyright (C) 2020 Laurent Destailleur -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by @@ -14,7 +15,7 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . -- --- Table to store all product variants of a parent product +-- Table to store links between a parent product and its variant products. -- ============================================================================ CREATE TABLE llx_product_attribute_combination @@ -25,6 +26,6 @@ CREATE TABLE llx_product_attribute_combination variation_price DOUBLE(24,8) NOT NULL, variation_price_percentage INTEGER NULL, variation_weight REAL NOT NULL, - ref_ext varchar(255) DEFAULT NULL, + variation_ref_ext VARCHAR(255) NULL, entity INTEGER DEFAULT 1 NOT NULL )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_product_attribute_value.sql b/htdocs/install/mysql/tables/llx_product_attribute_value.sql index c4e0ec91459..09e7d325d0d 100644 --- a/htdocs/install/mysql/tables/llx_product_attribute_value.sql +++ b/htdocs/install/mysql/tables/llx_product_attribute_value.sql @@ -15,6 +15,8 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . -- +-- llx_product_attribute_value is table for different available values of a product variants attributes. +-- For example BLUE, GREEN, ... for the product attribute COLOR. -- ============================================================================ CREATE TABLE llx_product_attribute_value diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 7b59e33b296..29a857c914b 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -305,6 +305,9 @@ ErrorAccountingJournalIsAlreadyUse=This journal is already use AccountingAccountForSalesTaxAreDefinedInto=Note: Accounting account for Sales tax are defined into menu %s - %s NumberOfAccountancyEntries=Number of entries NumberOfAccountancyMovements=Number of movements +ACCOUNTING_DISABLE_BINDING_ON_SALES=Disable binding & transfer in accountancy on sales (customer invoices will not be taken into account in accounting) +ACCOUNTING_DISABLE_BINDING_ON_PURCHASES=Disable binding & transfer in accountancy on purchases (vendor invoices will not be taken into account in accounting) +ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS=Disable binding & transfer in accountancy on expense reports (expense reports will not be taken into account in accounting) ## Export ExportDraftJournal=Export draft journal diff --git a/htdocs/mrp/mo_movements.php b/htdocs/mrp/mo_movements.php index f43ccd3dcd4..e281d45ee74 100644 --- a/htdocs/mrp/mo_movements.php +++ b/htdocs/mrp/mo_movements.php @@ -143,6 +143,12 @@ $arrayfields = array( //'m.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), //'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) ); +if (!empty($conf->global->PRODUCT_DISABLE_EATBY)) { + unset($arrayfields['pl.eatby']); +} +if (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + unset($arrayfields['pl.sellby']); +} $objectlist->fields = dol_sort_array($objectlist->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index f1b3e91617b..267e3bc2890 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -455,7 +455,7 @@ class Products extends DolibarrApi * @throws RestException 401 * @throws RestException 404 * - * @url DELETE {id}/subproducts/remove + * @url DELETE {id}/subproducts/remove/{subproduct_id} */ public function delSubproducts($id, $subproduct_id) { diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index de49a11fbc7..050d0d12f4b 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -284,8 +284,12 @@ if ($resql) print ''; print ''; print ''; - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } print ''; print ''; print ''; - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } print ''; - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } } print ''; print ''; @@ -202,8 +206,12 @@ if ($resql) if (!empty($conf->productbatch->enabled)) { print ''; - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } } print ''; print ''; if ((!empty($conf->productbatch->enabled)) && $object->hasbatch()) { + $colspan = 3; print ''; print ''; - print ''; - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + $colspan--; + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + $colspan--; + print ''; + } + print ''; print ''; print ''; print ''; @@ -888,13 +900,17 @@ if (!$variants) { print ''; print '
'.$langs->trans("Day".$arraytimestamp['wday'])."'.$langs->trans("Description").''.$langs->trans("batch_number").''.$langs->trans("EatByDate").''.$langs->trans("SellByDate").''.$langs->trans("EatByDate").''.$langs->trans("SellByDate").''; print $linktoprod; @@ -828,8 +836,12 @@ if ($id > 0 || !empty($ref)) { print ''; print $langs->trans("ProductDoesNotUseBatchSerial"); print ''; @@ -896,14 +908,18 @@ if ($id > 0 || !empty($ref)) { print ''; print ''; print ''; - $dlcdatesuffix = dol_mktime(0, 0, 0, GETPOST('dlc'.$suffix.'month'), GETPOST('dlc'.$suffix.'day'), GETPOST('dlc'.$suffix.'year')); - print $form->selectDate($dlcdatesuffix, 'dlc'.$suffix, '', '', 1, ''); - print ''; - $dluodatesuffix = dol_mktime(0, 0, 0, GETPOST('dluo'.$suffix.'month'), GETPOST('dluo'.$suffix.'day'), GETPOST('dluo'.$suffix.'year')); - print $form->selectDate($dluodatesuffix, 'dluo'.$suffix, '', '', 1, ''); - print ''; + $dlcdatesuffix = dol_mktime(0, 0, 0, GETPOST('dlc' . $suffix . 'month'), GETPOST('dlc' . $suffix . 'day'), GETPOST('dlc' . $suffix . 'year')); + print $form->selectDate($dlcdatesuffix, 'dlc' . $suffix, '', '', 1, ''); + print ''; + $dluodatesuffix = dol_mktime(0, 0, 0, GETPOST('dluo'.$suffix.'month'), GETPOST('dluo'.$suffix.'day'), GETPOST('dluo'.$suffix.'year')); + print $form->selectDate($dluodatesuffix, 'dluo'.$suffix, '', '', 1, ''); + print ' '.$langs->trans("DateDeliveryPlanned").''.$langs->trans("batch_number").''.$langs->trans("EatByDate").''.$langs->trans("SellByDate").'' . $langs->trans("EatByDate") . '' . $langs->trans("SellByDate") . ''.$langs->trans("QtyDispatched").''.$langs->trans("Warehouse").''.$lot->getNomUrl(1).''.dol_print_date($lot->eatby, 'day').''.dol_print_date($lot->sellby, 'day').'' . dol_print_date($lot->eatby, 'day') . '' . dol_print_date($lot->sellby, 'day') . '        '; @@ -302,8 +306,12 @@ if ($resql) print_liste_field_titre("Warehouse", $_SERVER["PHP_SELF"], "e.ref", $param, "", '', $sortfield, $sortorder); //print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'',$sortfield,$sortorder, 'right ); print_liste_field_titre("Batch", $_SERVER["PHP_SELF"], "pb.batch", $param, "", '', $sortfield, $sortorder, 'center '); - print_liste_field_titre("EatByDate", $_SERVER["PHP_SELF"], "pb.eatby", $param, "", '', $sortfield, $sortorder, 'center '); - print_liste_field_titre("SellByDate", $_SERVER["PHP_SELF"], "pb.sellby", $param, "", '', $sortfield, $sortorder, 'center '); + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print_liste_field_titre("EatByDate", $_SERVER["PHP_SELF"], "pb.eatby", $param, "", '', $sortfield, $sortorder, 'center '); + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print_liste_field_titre("SellByDate", $_SERVER["PHP_SELF"], "pb.sellby", $param, "", '', $sortfield, $sortorder, 'center '); + } print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stock_physique", $param, "", '', $sortfield, $sortorder, 'right '); // TODO Add info of running suppliers/customers orders //print_liste_field_titre("TheoreticalStock",$_SERVER["PHP_SELF"], "stock_theorique",$param,"",'',$sortfield,$sortorder, 'right '); @@ -400,8 +408,12 @@ if ($resql) } print ''.dol_print_date($db->jdate($objp->eatby), 'day').''.dol_print_date($db->jdate($objp->sellby), 'day').''.dol_print_date($db->jdate($objp->eatby), 'day').''.dol_print_date($db->jdate($objp->sellby), 'day').''; //if ($objp->seuil_stock_alerte && ($objp->stock_physique < $objp->seuil_stock_alerte)) print img_warning($langs->trans("StockTooLow")).' '; print $objp->stock_physique; diff --git a/htdocs/product/stock/index.php b/htdocs/product/stock/index.php index f144fe38a75..1c93d1ee943 100644 --- a/htdocs/product/stock/index.php +++ b/htdocs/product/stock/index.php @@ -170,8 +170,12 @@ if ($resql) if (!empty($conf->productbatch->enabled)) { print ''.$langs->trans("Batch").''.$langs->trans("SellByDate").''.$langs->trans("EatByDate").''.$langs->trans("SellByDate").''.$langs->trans("EatByDate").''.$langs->trans("Warehouse").''.$langs->trans("FullList").''.$objp->batch.''.dol_print_date($db->jdate($objp->sellby), 'day').''.dol_print_date($db->jdate($objp->eatby), 'day').''.dol_print_date($db->jdate($objp->sellby), 'day').''.dol_print_date($db->jdate($objp->eatby), 'day').''; print $warehouse->getNomUrl(1); diff --git a/htdocs/product/stock/movement_list.php b/htdocs/product/stock/movement_list.php index c844bae01e2..ee4c77eb2e4 100644 --- a/htdocs/product/stock/movement_list.php +++ b/htdocs/product/stock/movement_list.php @@ -121,6 +121,12 @@ $arrayfields = array( //'m.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), //'m.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500) ); +if (!empty($conf->global->PRODUCT_DISABLE_EATBY)) { + unset($arrayfields['pl.eatby']); +} +if (!empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + unset($arrayfields['pl.sellby']); +} // Security check if (!$user->rights->stock->mouvement->lire) { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index e7fffeaffb7..fe6e8d3e829 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -1,14 +1,14 @@ - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005 Simon TOSSER - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2013 Cédric Salvador - * Copyright (C) 2013-2018 Juanjo Menent - * Copyright (C) 2014-2015 Cédric Gross - * Copyright (C) 2015 Marcos García - * Copyright (C) 2018-2019 Frédéric France +/* Copyright (C) 2001-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2020 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005 Simon TOSSER + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2013-2018 Juanjo Menent + * Copyright (C) 2014-2015 Cédric Gross + * Copyright (C) 2015 Marcos García + * Copyright (C) 2018-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -67,8 +67,8 @@ $stocklimit = GETPOST('seuil_stock_alerte'); $desiredstock = GETPOST('desiredstock'); $cancel = GETPOST('cancel', 'alpha'); $fieldid = isset($_GET["ref"]) ? 'ref' : 'rowid'; -$d_eatby = dol_mktime(0, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); -$d_sellby = dol_mktime(0, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); +$d_eatby = dol_mktime(0, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int')); +$d_sellby = dol_mktime(0, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int')); $pdluoid = GETPOST('pdluoid', 'int'); $batchnumber = GETPOST('batch_number', 'san_alpha'); if (!empty($batchnumber)) { @@ -224,7 +224,8 @@ if ($action == "correct_stock" && !$cancel) if (!$error) { $priceunit = price2num(GETPOST("unitprice")); - if (is_numeric(GETPOST("nbpiece")) && $id) + $nbpiece = price2num(GETPOST("nbpiece", 'alphanohtml')); + if (is_numeric($nbpiece) && $nbpiece != 0 && $id) { $origin_element = ''; $origin_id = null; @@ -244,14 +245,14 @@ if ($action == "correct_stock" && !$cancel) $result = $object->correct_stock_batch( $user, GETPOST("id_entrepot", 'int'), - GETPOST("nbpiece"), - GETPOST("mouvement"), + $nbpiece, + GETPOST("mouvement", 'int'), GETPOST("label", 'alphanohtml'), // label movement $priceunit, $d_eatby, $d_sellby, $batchnumber, - GETPOST('inventorycode'), + GETPOST('inventorycode', 'alphanohtml'), $origin_element, $origin_id ); // We do not change value of stock for a correction @@ -259,11 +260,11 @@ if ($action == "correct_stock" && !$cancel) $result = $object->correct_stock( $user, GETPOST("id_entrepot", 'int'), - GETPOST("nbpiece"), - GETPOST("mouvement"), + $nbpiece, + GETPOST("mouvement", 'int'), GETPOST("label", 'alphanohtml'), $priceunit, - GETPOST('inventorycode'), + GETPOST('inventorycode', 'alphanohtml'), $origin_element, $origin_id ); // We do not change value of stock for a correction @@ -337,6 +338,8 @@ if ($action == "transfert_stock" && !$cancel) if (isset($object->pmp)) $pricesrc = $object->pmp; $pricedest = $pricesrc; + $nbpiece = price2num(GETPOST("nbpiece", 'alphanohtml')); + if ($object->hasbatch()) { $pdluo = new Productbatch($db); @@ -361,18 +364,20 @@ if ($action == "transfert_stock" && !$cancel) $sellby = $d_sellby; } + $nbpiece = price2num(GETPOST("nbpiece", 'alphanohtml')); + if (!$error) { // Remove stock $result1 = $object->correct_stock_batch( $user, $srcwarehouseid, - GETPOST("nbpiece", 'int'), + $nbpiece, 1, - GETPOST("label", 'san_alpha'), + GETPOST("label", 'alphanohtml'), $pricesrc, $eatby, $sellby, $batch, - GETPOST('inventorycode') + GETPOST('inventorycode', 'alphanohtml') ); if ($result1 < 0) $error++; } @@ -382,12 +387,12 @@ if ($action == "transfert_stock" && !$cancel) $result2 = $object->correct_stock_batch( $user, GETPOST("id_entrepot_destination", 'int'), - GETPOST("nbpiece", 'int'), + $nbpiece, 0, - GETPOST("label", 'san_alpha'), + GETPOST("label", 'alphanohtml'), $pricedest, $eatby, $sellby, $batch, - GETPOST('inventorycode') + GETPOST('inventorycode', 'alphanohtml') ); if ($result2 < 0) $error++; } @@ -398,11 +403,11 @@ if ($action == "transfert_stock" && !$cancel) $result1 = $object->correct_stock( $user, GETPOST("id_entrepot", 'int'), - GETPOST("nbpiece"), + $nbpiece, 1, - GETPOST("label"), + GETPOST("label", 'alphanohtml'), $pricesrc, - GETPOST('inventorycode') + GETPOST('inventorycode', 'alphanohtml') ); if ($result1 < 0) $error++; } @@ -412,11 +417,11 @@ if ($action == "transfert_stock" && !$cancel) $result2 = $object->correct_stock( $user, GETPOST("id_entrepot_destination", 'int'), - GETPOST("nbpiece"), + $nbpiece, 0, - GETPOST("label"), + GETPOST("label", 'alphanohtml'), $pricedest, - GETPOST('inventorycode') + GETPOST('inventorycode', 'alphanohtml') ); if ($result2 < 0) $error++; } @@ -805,11 +810,18 @@ if (!$variants) { print ''.$langs->trans("EstimatedStockValueSellShort").'
'.$langs->trans("batch_number").''.$langs->trans("EatByDate").''.$langs->trans("SellByDate").''.$langs->trans("EatByDate").''.$langs->trans("SellByDate").'
'; print ''; - print ''; - print ''; - print ''; + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print ''; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print ''; + } + print ''; print ''; print '
'; - print $form->selectDate($pdluo->eatby, 'eatby', '', '', 1, '', 1, 0); - print ''; - print $form->selectDate($pdluo->sellby, 'sellby', '', '', 1, '', 1, 0); - print ''.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').''; + print $form->selectDate($pdluo->eatby, 'eatby', '', '', 1, '', 1, 0); + print ''; + print $form->selectDate($pdluo->sellby, 'sellby', '', '', 1, '', 1, 0); + print ''.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').''; print '
'; @@ -911,9 +927,16 @@ if (!$variants) { print '
'; print $product_lot_static->getNomUrl(1); print ''.dol_print_date($pdluo->eatby, 'day').''.dol_print_date($pdluo->sellby, 'day').''.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').''.dol_print_date($pdluo->eatby, 'day').''.dol_print_date($pdluo->sellby, 'day').''.$pdluo->qty.($pdluo->qty < 0 ? ' '.img_warning() : '').'
'; - print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); - print ''; - print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); - print '
'; + print $form->editfieldkey($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + print ''; + print $form->editfieldval($langs->trans('EatByDate'), 'eatby', $object->eatby, $object, $user->rights->stock->creer, 'datepicker'); + print '
'; - print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); - print ''; - print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); - print '
'; + print $form->editfieldkey($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + print ''; + print $form->editfieldval($langs->trans('SellByDate'), 'sellby', $object->sellby, $object, $user->rights->stock->creer, 'datepicker'); + print '
'.$langs->trans("EatByDate").''; - $eatbyselected = dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear')); - print $form->selectDate($eatbyselected, 'eatby', '', '', 1, ""); - print ''.$langs->trans("SellByDate").''; - $sellbyselected = dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear')); - print $form->selectDate($sellbyselected, 'sellby', '', '', 1, ""); - print ''.$langs->trans("EatByDate").''; + $eatbyselected = dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear')); + print $form->selectDate($eatbyselected, 'eatby', '', '', 1, ""); + print ''.$langs->trans("SellByDate").''; + $sellbyselected = dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear')); + print $form->selectDate($sellbyselected, 'sellby', '', '', 1, ""); + print '
'.$langs->trans("EatByDate").''; - print $form->selectDate(($d_eatby ? $d_eatby : $pdluo->eatby), 'eatby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled - print ''.$langs->trans("SellByDate").''; - print $form->selectDate(($d_sellby ? $d_sellby : $pdluo->sellby), 'sellby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled - print ''.$langs->trans("EatByDate").''; + print $form->selectDate(($d_eatby ? $d_eatby : $pdluo->eatby), 'eatby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled + print ''.$langs->trans("SellByDate").''; + print $form->selectDate(($d_sellby ? $d_sellby : $pdluo->sellby), 'sellby', '', '', 1, "", 1, 0, ($pdluoid > 0 ? 1 : 0)); // If form was opened for a specific pdluoid, field is disabled + print '
'.$langs->trans("batch_number").''.$langs->trans("EatByDate").''.$langs->trans("SellByDate").''.$langs->trans("EatByDate").''.$langs->trans("SellByDate").'
'; - print $form->selectDate($dispatchLines[$indiceAsked]['DLC'], 'dlc'.$indiceAsked, '', '', 1, ""); - print ''; - print $form->selectDate($dispatchLines[$indiceAsked]['DLUO'], 'dluo'.$indiceAsked, '', '', 1, ""); - print ''; + print $form->selectDate($dispatchLines[$indiceAsked]['DLC'], 'dlc'.$indiceAsked, '', '', 1, ""); + print ''; + print $form->selectDate($dispatchLines[$indiceAsked]['DLUO'], 'dluo'.$indiceAsked, '', '', 1, ""); + print '
'; - print $langs->trans('EatByDate').' : '; - print $form->selectDate($lines[$i]->eatby, 'dlc'.$line_id, '', '', 1, "").'
'; - print $langs->trans('SellByDate').' : '; - print $form->selectDate($lines[$i]->sellby, 'dluo'.$line_id, '', '', 1, ""); + if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { + print $langs->trans('EatByDate').' : '; + print $form->selectDate($lines[$i]->eatby, 'dlc'.$line_id, '', '', 1, "").'
'; + } + if (empty($conf->global->PRODUCT_DISABLE_SELLBY)) { + print $langs->trans('SellByDate').' : '; + print $form->selectDate($lines[$i]->sellby, 'dluo'.$line_id, '', '', 1, ""); + } print '
'; print $langs->trans("VendorName").''; -print ''; +print ''; print '   '.$langs->trans("Example").': '.$mysoc->name; print '
'; + print $langs->trans("STRIPE_IDEAL").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STRIPE_IDEAL'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STRIPE_IDEAL", $arrval, $conf->global->STRIPE_SEPA_DIRECT_DEBIT); + } + print '   '.$langs->trans("ExampleOnlyForNLCustomers"); + print '
'.$langs->trans("Type").''; - print $langs->getLabelFromKey($db, $object->type_code, 'c_ticket_type', 'code', 'label'); + print $langs->getLabelFromKey($db, 'TicketTypeShort' . $object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code); print '
'.$langs->trans("TicketCategory").''; - print $langs->getLabelFromKey($db, $object->category_code, 'c_ticket_category', 'code', 'label'); + print $langs->getLabelFromKey($db, 'TicketCategoryShort' . $object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code); print '
'.$langs->trans("TicketSeverity").''; - print $langs->getLabelFromKey($db, $object->severity_code, 'c_ticket_severity', 'code', 'label'); + print $langs->getLabelFromKey($db, 'TicketSeverityShort' . $object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code); print '
'; // End table actions diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php index b228339971f..6ea898e92db 100644 --- a/htdocs/ticket/list.php +++ b/htdocs/ticket/list.php @@ -755,9 +755,9 @@ while ($i < min($num, $limit)) if ($cssforfield || $val['css']) print '"'; print '>'; if ($key == 'fk_statut') print $object->getLibStatut(5); - elseif ($key == 'category_code') print $langs->getLabelFromKey($db, $object->category_code, 'c_ticket_category', 'code', 'label'); - elseif ($key == 'severity_code') print $langs->getLabelFromKey($db, $object->severity_code, 'c_ticket_severity', 'code', 'label'); - elseif ($key == 'type_code') print $langs->getLabelFromKey($db, $object->type_code, 'c_ticket_type', 'code', 'label'); + elseif ($key == 'category_code') print $langs->getLabelFromKey($db, 'TicketCategoryShort' . $object->category_code, 'c_ticket_category', 'code', 'label', $object->category_code); + elseif ($key == 'severity_code') print $langs->getLabelFromKey($db, 'TicketSeverityShort' . $object->severity_code, 'c_ticket_severity', 'code', 'label', $object->severity_code); + elseif ($key == 'type_code') print $langs->getLabelFromKey($db, 'TicketTypeShort' . $object->type_code, 'c_ticket_type', 'code', 'label', $object->type_code); elseif ($key == 'tms') print dol_print_date($db->jdate($obj->$key), 'dayhour', 'tzuser'); elseif ($key == 'fk_user_create') { if ($object->fk_user_create > 0) { diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index a449ca5d237..e9e71b41c4a 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -233,72 +233,72 @@ class ProductCombination } } - /** - * Return the product id of the parent product of a variant product (Get fk_product_parent by fk_product_child) - * - * @param int $fk_child Product row id - * @return int >0 if OK, 0 if product is not a variant, <0 if KO - */ - public function getFkProductParentByFkProductChild($fk_child) - { - $sql = "SELECT fk_product_parent FROM ".MAIN_DB_PREFIX."product_attribute_combination"; - $sql .= " WHERE fk_product_child = ".(int) $fk_child." AND entity IN (".getEntity('product').") LIMIT 1"; + /** + * Return the product id of the parent product of a variant product (Get fk_product_parent by fk_product_child) + * + * @param int $fk_child Product row id + * @return int >0 if OK, 0 if product is not a variant, <0 if KO + */ + public function getFkProductParentByFkProductChild($fk_child) + { + $sql = "SELECT fk_product_parent FROM ".MAIN_DB_PREFIX."product_attribute_combination"; + $sql .= " WHERE fk_product_child = ".(int) $fk_child." AND entity IN (".getEntity('product').") LIMIT 1"; - $query = $this->db->query($sql); + $query = $this->db->query($sql); - if (!$query) { - return -1; - } + if (!$query) { + return -1; + } - if (!$this->db->num_rows($query)) { - return 0; - } + if (!$this->db->num_rows($query)) { + return 0; + } - $row = $this->db->fetch_object($query); + $row = $this->db->fetch_object($query); - return (int) $row->fk_product_parent; - } + return (int) $row->fk_product_parent; + } + /** + * Retrieves all product combinations by the child product row id + * + * @param int $fk_child Product row id + * @param int $donotloadpricelevel Avoid loading price impact for each level. If PRODUIT_MULTIPRICES is not set, this has no effect. + * @return int|ProductCombination[] <0 KO + */ + public function fetchAllByFkProductChild($fk_child, $donotloadpricelevel = 0) + { + global $conf; - /** - * Retrieves all product combinations by the child product row id - * - * @param int $fk_child Product row id - * @return int|ProductCombination[] <0 KO - */ - public function fetchAllByFkProductChild($fk_child) - { - global $conf; + $sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight, variation_ref_ext FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_child = ".(int) $fk_child." AND entity IN (".getEntity('product').")"; - $sql = "SELECT rowid, fk_product_parent, fk_product_child, variation_price, variation_price_percentage, variation_weight, variation_ref_ext FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_child = ".(int) $fk_child." AND entity IN (".getEntity('product').")"; + $query = $this->db->query($sql); - $query = $this->db->query($sql); + if (!$query) { + return -1; + } - if (!$query) { - return -1; - } + $return = array(); - $return = array(); + while ($result = $this->db->fetch_object($query)) { + $tmp = new ProductCombination($this->db); + $tmp->id = $result->rowid; + $tmp->fk_product_parent = $result->fk_product_parent; + $tmp->fk_product_child = $result->fk_product_child; + $tmp->variation_price = $result->variation_price; + $tmp->variation_price_percentage = $result->variation_price_percentage; + $tmp->variation_weight = $result->variation_weight; + $tmp->variation_ref_ext = $result->variation_ref_ext; - while ($result = $this->db->fetch_object($query)) { - $tmp = new ProductCombination($this->db); - $tmp->id = $result->rowid; - $tmp->fk_product_parent = $result->fk_product_parent; - $tmp->fk_product_child = $result->fk_product_child; - $tmp->variation_price = $result->variation_price; - $tmp->variation_price_percentage = $result->variation_price_percentage; - $tmp->variation_weight = $result->variation_weight; - $tmp->variation_ref_ext = $result->variation_ref_ext; + if (empty($donotloadpricelevel) && !empty($conf->global->PRODUIT_MULTIPRICES)) { + $tmp->fetchCombinationPriceLevels(); + } - if (!empty($conf->global->PRODUIT_MULTIPRICES)) { - $tmp->fetchCombinationPriceLevels(); - } + $return[] = $tmp; + } - $return[] = $tmp; - } - - return $return; - } + return $return; + } /** * Retrieves all product combinations by the product parent row id