Merge branch 'Dolibarr:develop' into smtp-oauth-patch

This commit is contained in:
fboitel 2022-08-27 17:09:04 +02:00 committed by GitHub
commit 59df9f96ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 499 additions and 307 deletions

View File

@ -875,7 +875,7 @@ if (empty($reshook)) {
} }
} }
} elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('vatforalllines', 'alpha') !== '' && $usercancreate) { } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('vatforalllines', 'alpha') !== '' && $usercancreate) {
// Define vat_rate // Define a vat_rate for all lines
$vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0); $vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0);
$vat_rate = str_replace('*', '', $vat_rate); $vat_rate = str_replace('*', '', $vat_rate);
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc); $localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
@ -884,7 +884,7 @@ if (empty($reshook)) {
$result = $object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice); $result = $object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
} }
} elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) { } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('remiseforalllines', 'alpha') !== '' && $usercancreate) {
// Define vat_rate // Define a discount for all lines
$remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0); $remise_percent = (GETPOST('remiseforalllines') ? GETPOST('remiseforalllines') : 0);
$remise_percent = str_replace('*', '', $remise_percent); $remise_percent = str_replace('*', '', $remise_percent);
foreach ($object->lines as $line) { foreach ($object->lines as $line) {
@ -894,22 +894,36 @@ if (empty($reshook)) {
// Set if we used free entry or predefined product // Set if we used free entry or predefined product
$predef = ''; $predef = '';
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
$price_ttc = price2num(GETPOST('price_ttc'), 'MU', 2);
$price_ttc_devise = price2num(GETPOST('multicurrency_price_ttc'), 'CU', 2);
$prod_entry_mode = GETPOST('prod_entry_mode'); $price_ht = '';
$price_ht_devise = '';
$price_ttc = '';
$price_ttc_devise = '';
if (GETPOST('price_ht') !== '') {
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
}
if (GETPOST('multicurrency_price_ht') !== '') {
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
}
if (GETPOST('price_ttc') !== '') {
$price_ttc = price2num(GETPOST('price_ttc'), 'MU', 2);
}
if (GETPOST('multicurrency_price_ttc') !== '') {
$price_ttc_devise = price2num(GETPOST('multicurrency_price_ttc'), 'CU', 2);
}
$prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09');
if ($prod_entry_mode == 'free') { if ($prod_entry_mode == 'free') {
$idprod = 0; $idprod = 0;
$tva_tx = (GETPOST('tva_tx') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx'))) : 0); $tva_tx = (GETPOST('tva_tx', 'alpha') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx', 'alpha'))) : 0);
} else { } else {
$idprod = GETPOST('idprod', 'int'); $idprod = GETPOST('idprod', 'int');
$tva_tx = ''; $tva_tx = '';
} }
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2); $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2);
$remise_percent = price2num(GETPOST('remise_percent'.$predef), '', 2); $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0);
if (empty($remise_percent)) { if (empty($remise_percent)) {
$remise_percent = 0; $remise_percent = 0;
} }
@ -930,7 +944,7 @@ if (empty($reshook)) {
$error++; $error++;
} }
if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && $price_ht === '' && $price_ht_devise === '') { // Unit price can be 0 but not ''. Also price can be negative for proposal. if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && $price_ht === '' && $price_ht_devise === '' && $price_ttc === '' && $price_ttc_devise === '') { // Unit price can be 0 but not ''. Also price can be negative for proposal.
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
$error++; $error++;
} }
@ -1077,13 +1091,15 @@ if (empty($reshook)) {
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
// if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? // Set unit price to use
if (!empty($price_ht) || $price_ht === '0') { if (!empty($price_ht) || $price_ht === '0') {
$pu_ht = price2num($price_ht, 'MU'); $pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
} elseif (!empty($price_ttc) || $price_ttc === '0') {
$pu_ttc = price2num($price_ttc, 'MU');
$pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
} elseif ($tmpvat != $tmpprodvat) { } elseif ($tmpvat != $tmpprodvat) {
// On reevalue prix selon taux tva car taux tva transaction peut etre different // Is this still used ?
// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
if ($price_base_type != 'HT') { if ($price_base_type != 'HT') {
$pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
} else { } else {
@ -1170,16 +1186,22 @@ if (empty($reshook)) {
$fk_unit = $prod->fk_unit; $fk_unit = $prod->fk_unit;
} else { } else {
$pu_ht = price2num($price_ht, 'MU'); $pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); $pu_ttc = price2num($price_ttc, 'MU');
$tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
if (empty($tva_tx)) {
$tva_npr = 0;
}
$tva_tx = str_replace('*', '', $tva_tx); $tva_tx = str_replace('*', '', $tva_tx);
$label = (GETPOST('product_label') ? GETPOST('product_label') : ''); $label = (GETPOST('product_label') ? GETPOST('product_label') : '');
$desc = $product_desc; $desc = $product_desc;
$type = GETPOST('type'); $type = GETPOST('type');
$fk_unit = GETPOST('units', 'alpha'); $fk_unit = GETPOST('units', 'alpha');
$pu_ht_devise = price2num($price_ht_devise, 'MU'); $pu_ht_devise = price2num($price_ht_devise, 'MU');
$pu_ttc_devise = price2num($price_ttc_devise, 'MU'); $pu_ttc_devise = price2num($price_ttc_devise, 'MU');
if ($pu_ttc && !$pu_ht) {
$price_base_type = 'TTC';
}
} }
// Margin // Margin
@ -1298,7 +1320,7 @@ if (empty($reshook)) {
$buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2); $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
//$pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2); $pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2);
$date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear')); $date_start = dol_mktime(GETPOST('date_starthour'), GETPOST('date_startmin'), GETPOST('date_startsec'), GETPOST('date_startmonth'), GETPOST('date_startday'), GETPOST('date_startyear'));
$date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear'));
@ -1382,7 +1404,14 @@ if (empty($reshook)) {
$qty = price2num(GETPOST('qty', 'alpha'), 'MS'); $qty = price2num(GETPOST('qty', 'alpha'), 'MS');
$result = $object->updateline(GETPOST('lineid', 'int'), $pu_ht, $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $description, 'HT', $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, GETPOST("units"), $pu_ht_devise); $pu = $pu_ht;
$price_base_type = 'HT';
if (empty($pu) && ! empty($pu_ttc)) {
$pu = $pu_ttc;
$price_base_type = 'TTC';
}
$result = $object->updateline(GETPOST('lineid', 'int'), $pu, $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $description, $price_base_type, $info_bits, $special_code, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $type, $date_start, $date_end, $array_options, GETPOST("units"), $pu_ht_devise);
if ($result >= 0) { if ($result >= 0) {
$db->commit(); $db->commit();
@ -2696,7 +2725,7 @@ if ($action == 'create') {
* Lines * Lines
*/ */
// Show object lines // Get object lines
$result = $object->getLinesArray(); $result = $object->getLinesArray();
// Add products/services form // Add products/services form
@ -2704,7 +2733,7 @@ if ($action == 'create') {
global $inputalsopricewithtax; global $inputalsopricewithtax;
$inputalsopricewithtax = 1; $inputalsopricewithtax = 1;
print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '' : '#line_'.GETPOST('lineid', 'int')).'" method="POST"> print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">
<input type="hidden" name="token" value="' . newToken().'"> <input type="hidden" name="token" value="' . newToken().'">
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'"> <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
<input type="hidden" name="mode" value=""> <input type="hidden" name="mode" value="">

View File

@ -932,9 +932,6 @@ class Propal extends CommonObject
$this->line->date_start = $date_start; $this->line->date_start = $date_start;
$this->line->date_end = $date_end; $this->line->date_end = $date_end;
// TODO deprecated
$this->line->price = $price;
if (is_array($array_options) && count($array_options) > 0) { if (is_array($array_options) && count($array_options) > 0) {
// We replace values in this->line->array_options only for entries defined into $array_options // We replace values in this->line->array_options only for entries defined into $array_options
foreach ($array_options as $key => $value) { foreach ($array_options as $key => $value) {

View File

@ -646,22 +646,35 @@ if (empty($reshook)) {
// Set if we used free entry or predefined product // Set if we used free entry or predefined product
$predef = ''; $predef = '';
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
$price_ttc = price2num(GETPOST('price_ttc'), 'MU', 2);
$price_ttc_devise = price2num(GETPOST('multicurrency_price_ttc'), 'CU', 2);
$prod_entry_mode = GETPOST('prod_entry_mode'); $price_ht = '';
$price_ht_devise = '';
$price_ttc = '';
$price_ttc_devise = '';
if (GETPOST('price_ht') !== '') {
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
}
if (GETPOST('multicurrency_price_ht') !== '') {
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
}
if (GETPOST('price_ttc') !== '') {
$price_ttc = price2num(GETPOST('price_ttc'), 'MU', 2);
}
if (GETPOST('multicurrency_price_ttc') !== '') {
$price_ttc_devise = price2num(GETPOST('multicurrency_price_ttc'), 'CU', 2);
}
$prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09');
if ($prod_entry_mode == 'free') { if ($prod_entry_mode == 'free') {
$idprod = 0; $idprod = 0;
$tva_tx = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); $tva_tx = (GETPOST('tva_tx', 'alpha') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx', 'alpha'))) : 0);
} else { } else {
$idprod = GETPOST('idprod', 'int'); $idprod = GETPOST('idprod', 'int');
$tva_tx = ''; $tva_tx = '';
} }
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2);
$remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0); $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0);
if (empty($remise_percent)) { if (empty($remise_percent)) {
$remise_percent = 0; $remise_percent = 0;
@ -686,7 +699,7 @@ if (empty($reshook)) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
$error++; $error++;
} }
if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && $price_ht == '' && $price_ht_devise == '') { // Unit price can be 0 but not ''. Also price can be negative for order. if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && $price_ht === '' && $price_ht_devise === '' && $price_ttc === '' && $price_ttc_devise === '') { // Unit price can be 0 but not ''. Also price can be negative for order.
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors');
$error++; $error++;
} }
@ -835,13 +848,15 @@ if (empty($reshook)) {
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
// if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? // Set unit price to use
if (!empty($price_ht) || $price_ht === '0') { if (!empty($price_ht) || $price_ht === '0') {
$pu_ht = price2num($price_ht, 'MU'); $pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
} elseif (!empty($price_ttc) || $price_ttc === '0') {
$pu_ttc = price2num($price_ttc, 'MU');
$pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
} elseif ($tmpvat != $tmpprodvat) { } elseif ($tmpvat != $tmpprodvat) {
// On reevalue prix selon taux tva car taux tva transaction peut etre different // Is this still used ?
// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
if ($price_base_type != 'HT') { if ($price_base_type != 'HT') {
$pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
} else { } else {
@ -928,14 +943,22 @@ if (empty($reshook)) {
$fk_unit = $prod->fk_unit; $fk_unit = $prod->fk_unit;
} else { } else {
$pu_ht = price2num($price_ht, 'MU'); $pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); $pu_ttc = price2num($price_ttc, 'MU');
$tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
$tva_tx = str_replace('*', '', $tva_tx); $tva_tx = str_replace('*', '', $tva_tx);
if (empty($tva_tx)) {
$tva_npr = 0;
}
$label = (GETPOST('product_label') ? GETPOST('product_label') : ''); $label = (GETPOST('product_label') ? GETPOST('product_label') : '');
$desc = $product_desc; $desc = $product_desc;
$type = GETPOST('type'); $type = GETPOST('type');
$fk_unit = GETPOST('units', 'alpha'); $fk_unit = GETPOST('units', 'alpha');
$pu_ht_devise = price2num($price_ht_devise, 'MU'); $pu_ht_devise = price2num($price_ht_devise, 'MU');
$pu_ttc_devise = price2num($price_ttc_devise, 'MU');
if ($pu_ttc && !$pu_ht) {
$price_base_type = 'TTC';
}
} }
// Margin // Margin
@ -946,13 +969,13 @@ if (empty($reshook)) {
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty); $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty);
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty); $localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty);
$desc = dol_htmlcleanlastbr($desc);
$info_bits = 0; $info_bits = 0;
if ($tva_npr) { if ($tva_npr) {
$info_bits |= 0x01; $info_bits |= 0x01;
} }
$desc = dol_htmlcleanlastbr($desc);
if ($usermustrespectpricemin) { if ($usermustrespectpricemin) {
if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) { if ($pu_ht && $price_min && ((price2num($pu_ht) * (1 - $remise_percent / 100)) < price2num($price_min))) {
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency)); $mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, -1, $conf->currency));
@ -1035,12 +1058,14 @@ if (empty($reshook)) {
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml')); $description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml'));
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx', 'alpha') : 0); $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx', 'alpha') : 0);
$vat_rate = str_replace('*', '', $vat_rate); $vat_rate = str_replace('*', '', $vat_rate);
$pu_ht = price2num(GETPOST('price_ht'), '', 2); $pu_ht = price2num(GETPOST('price_ht'), '', 2);
$pu_ttc = price2num(GETPOST('price_ttc'), '', 2); $pu_ttc = price2num(GETPOST('price_ttc'), '', 2);
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
//$pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2);
$qty = price2num(GETPOST('qty'), 'MS'); $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
$pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2);
$qty = price2num(GETPOST('qty', 'alpha'), 'MS');
// Define info_bits // Define info_bits
$info_bits = 0; $info_bits = 0;
@ -1135,7 +1160,15 @@ if (empty($reshook)) {
} }
} }
} }
$result = $object->updateline(GETPOST('lineid', 'int'), $description, $pu_ht, $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('units'), $pu_ht_devise);
$price_base_type = 'HT';
$pu = $pu_ht;
if (empty($pu) && ! empty($pu_ttc)) {
$pu = $pu_ttc;
$price_base_type = 'TTC';
}
$result = $object->updateline(GETPOST('lineid', 'int'), $description, $pu, $qty, $remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $price_base_type, $info_bits, $date_start, $date_end, $type, GETPOST('fk_parent_line'), 0, $fournprice, $buyingprice, $label, $special_code, $array_options, GETPOST('units'), $pu_ht_devise);
if ($result >= 0) { if ($result >= 0) {
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
@ -2678,9 +2711,16 @@ if ($action == 'create' && $usercancreate) {
/* /*
* Lines * Lines
*/ */
// Get object lines
$result = $object->getLinesArray(); $result = $object->getLinesArray();
print '<form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '' : '#line_'.GETPOST('lineid', 'int')).'" method="POST"> // Add products/services form
//$forceall = 1;
global $inputalsopricewithtax;
$inputalsopricewithtax = 1;
print '<form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">
<input type="hidden" name="token" value="' . newToken().'"> <input type="hidden" name="token" value="' . newToken().'">
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'"> <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
<input type="hidden" name="mode" value=""> <input type="hidden" name="mode" value="">

View File

@ -2008,22 +2008,39 @@ if (empty($reshook)) {
// Set if we used free entry or predefined product // Set if we used free entry or predefined product
$predef = ''; $predef = '';
$product_desc =(GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $product_desc =(GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
$price_ttc = price2num(GETPOST('price_ttc'), 'MU', 2);
$price_ttc_devise = price2num(GETPOST('multicurrency_price_ttc'), 'CU', 2);
$prod_entry_mode = GETPOST('prod_entry_mode', 'alpha'); $price_ht = '';
$price_ht_devise = '';
$price_ttc = '';
$price_ttc_devise = '';
if (GETPOST('price_ht') !== '') {
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
}
if (GETPOST('multicurrency_price_ht') !== '') {
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
}
if (GETPOST('price_ttc') !== '') {
$price_ttc = price2num(GETPOST('price_ttc'), 'MU', 2);
}
if (GETPOST('multicurrency_price_ttc') !== '') {
$price_ttc_devise = price2num(GETPOST('multicurrency_price_ttc'), 'CU', 2);
}
$prod_entry_mode = GETPOST('prod_entry_mode', 'aZ09');
if ($prod_entry_mode == 'free') { if ($prod_entry_mode == 'free') {
$idprod = 0; $idprod = 0;
$tva_tx = (GETPOST('tva_tx', 'alpha') ? GETPOST('tva_tx', 'alpha') : 0); $tva_tx = (GETPOST('tva_tx', 'alpha') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx', 'alpha'))) : 0);
} else { } else {
$idprod = GETPOST('idprod', 'int'); $idprod = GETPOST('idprod', 'int');
$tva_tx = ''; $tva_tx = '';
} }
$qty = price2num(GETPOST('qty'.$predef), 'MS', 2); $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS', 2);
$remise_percent = price2num(GETPOST('remise_percent'.$predef), '', 2); $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef, 'alpha'), '', 2) : 0);
if (empty($remise_percent)) {
$remise_percent = 0;
}
// Extrafields // Extrafields
$extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line);
@ -2050,8 +2067,8 @@ if (empty($reshook)) {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors'); setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), null, 'errors');
$error++; $error++;
} }
if (($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && (($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $price_ht == '') && $price_ht_devise == '') && $object->type != Facture::TYPE_CREDIT_NOTE) { // Unit price can be 0 but not '' if ($prod_entry_mode == 'free' && (empty($idprod) || $idprod < 0) && (($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $price_ht == '') && (($price_ht_devise < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $price_ht_devise == '') && $price_ttc === '' && $price_ttc_devise === '' && $object->type != Facture::TYPE_CREDIT_NOTE) { // Unit price can be 0 but not ''
if ($price_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) { if (($price_ht < 0 || $price_ttc < 0) && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) {
$langs->load("errors"); $langs->load("errors");
if ($object->type == $object::TYPE_DEPOSIT) { if ($object->type == $object::TYPE_DEPOSIT) {
// Using negative lines on deposit lead to headach and blocking problems when you want to consume them. // Using negative lines on deposit lead to headach and blocking problems when you want to consume them.
@ -2131,19 +2148,22 @@ if (empty($reshook)) {
$price_min = $datapriceofproduct['price_min']; $price_min = $datapriceofproduct['price_min'];
$price_min_ttc = $datapriceofproduct['price_min_ttc']; $price_min_ttc = $datapriceofproduct['price_min_ttc'];
$price_base_type = $datapriceofproduct['price_base_type']; $price_base_type = $datapriceofproduct['price_base_type'];
$tva_tx = $datapriceofproduct['tva_tx']; $tva_tx = $datapriceofproduct['tva_tx'];
$tva_npr = $datapriceofproduct['tva_npr']; $tva_npr = $datapriceofproduct['tva_npr'];
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
// if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ? // Set unit price to use
if (!empty($price_ht) || $price_ht === '0') { if (!empty($price_ht) || $price_ht === '0') {
$pu_ht = price2num($price_ht, 'MU'); $pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
} elseif (!empty($price_ttc) || $price_ttc === '0') {
$pu_ttc = price2num($price_ttc, 'MU');
$pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
} elseif ($tmpvat != $tmpprodvat) { } elseif ($tmpvat != $tmpprodvat) {
// On reevalue prix selon taux tva car taux tva transaction peut etre different // Is this still used ?
// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
if ($price_base_type != 'HT') { if ($price_base_type != 'HT') {
$pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
} else { } else {
@ -2231,7 +2251,7 @@ if (empty($reshook)) {
$fk_unit = $prod->fk_unit; $fk_unit = $prod->fk_unit;
} else { } else {
$pu_ht = price2num($price_ht, 'MU'); $pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); $pu_ttc = price2num($price_ttc, 'MU');
$tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0); $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
$tva_tx = str_replace('*', '', $tva_tx); $tva_tx = str_replace('*', '', $tva_tx);
if (empty($tva_tx)) { if (empty($tva_tx)) {
@ -2243,6 +2263,10 @@ if (empty($reshook)) {
$fk_unit = GETPOST('units', 'alpha'); $fk_unit = GETPOST('units', 'alpha');
$pu_ht_devise = price2num($price_ht_devise, 'MU'); $pu_ht_devise = price2num($price_ht_devise, 'MU');
$pu_ttc_devise = price2num($price_ttc_devise, 'MU'); $pu_ttc_devise = price2num($price_ttc_devise, 'MU');
if ($pu_ttc && !$pu_ht) {
$price_base_type = 'TTC';
}
} }
// Margin // Margin
@ -2381,12 +2405,14 @@ if (empty($reshook)) {
$description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml') ? GETPOST('product_desc', 'restricthtml') : GETPOST('desc', 'restricthtml')); $description = dol_htmlcleanlastbr(GETPOST('product_desc', 'restricthtml') ? GETPOST('product_desc', 'restricthtml') : GETPOST('desc', 'restricthtml'));
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0); $vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
$vat_rate = str_replace('*', '', $vat_rate); $vat_rate = str_replace('*', '', $vat_rate);
$pu_ht = price2num(GETPOST('price_ht'), '', 2); $pu_ht = price2num(GETPOST('price_ht'), '', 2);
$pu_ttc = price2num(GETPOST('price_ttc'), '', 2); $pu_ttc = price2num(GETPOST('price_ttc'), '', 2);
$pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
//$pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2);
$qty = GETPOST('qty'); $pu_ht_devise = price2num(GETPOST('multicurrency_subprice'), '', 2);
$pu_ttc_devise = price2num(GETPOST('multicurrency_subprice_ttc'), '', 2);
$qty = price2num(GETPOST('qty', 'alpha'), 'MS');
// Define info_bits // Define info_bits
$info_bits = 0; $info_bits = 0;
@ -2495,8 +2521,8 @@ if (empty($reshook)) {
setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors'); setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors');
$error++; $error++;
} }
if ((empty($productid) && (($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $pu_ht == '') && $pu_ht_devise == '') && $object->type != Facture::TYPE_CREDIT_NOTE) { // Unit price can be 0 but not '' if (empty($productid) && (($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $pu_ht == '') && (($pu_ht_devise < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) || $pu_ht_devise == '') && $pu_ttc === '' && $pu_ttc_devise === '' && $object->type != Facture::TYPE_CREDIT_NOTE) { // Unit price can be 0 but not ''
if ($pu_ht < 0 && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) { if (($pu_ht < 0 || $pu_ttc < 0) && empty($conf->global->FACTURE_ENABLE_NEGATIVE_LINES)) {
$langs->load("errors"); $langs->load("errors");
if ($object->type == $object::TYPE_DEPOSIT) { if ($object->type == $object::TYPE_DEPOSIT) {
// Using negative lines on deposit lead to headach and blocking problems when you want to consume them. // Using negative lines on deposit lead to headach and blocking problems when you want to consume them.
@ -2524,10 +2550,17 @@ if (empty($reshook)) {
} }
} }
$price_base_type = 'HT';
$pu = $pu_ht;
if (empty($pu) && ! empty($pu_ttc)) {
$pu = $pu_ttc;
$price_base_type = 'TTC';
}
$result = $object->updateline( $result = $object->updateline(
GETPOST('lineid', 'int'), GETPOST('lineid', 'int'),
$description, $description,
$pu_ht, $pu,
$qty, $qty,
$remise_percent, $remise_percent,
$date_start, $date_start,
@ -2535,7 +2568,7 @@ if (empty($reshook)) {
$vat_rate, $vat_rate,
$localtax1_rate, $localtax1_rate,
$localtax2_rate, $localtax2_rate,
'HT', $price_base_type,
$info_bits, $info_bits,
$type, $type,
GETPOST('fk_parent_line', 'int'), GETPOST('fk_parent_line', 'int'),
@ -5318,10 +5351,15 @@ if ($action == 'create') {
include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
} }
// Lines // Get object lines
$result = $object->getLinesArray(); $result = $object->getLinesArray();
// Show global modifiers // Add products/services form
//$forceall = 1;
global $inputalsopricewithtax;
$inputalsopricewithtax = 1;
// Show global modifiers for situation invoices
if (!empty($conf->global->INVOICE_USE_SITUATION)) { if (!empty($conf->global->INVOICE_USE_SITUATION)) {
if ($object->situation_cycle_ref && $object->statut == 0) { if ($object->situation_cycle_ref && $object->statut == 0) {
print '<!-- Area to change globally the situation percent -->'."\n"; print '<!-- Area to change globally the situation percent -->'."\n";
@ -5363,7 +5401,7 @@ if ($action == 'create') {
} }
} }
print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '' : '#line_'.GETPOST('lineid', 'int')).'" method="POST"> print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" method="POST">
<input type="hidden" name="token" value="' . newToken().'"> <input type="hidden" name="token" value="' . newToken().'">
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'"> <input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
<input type="hidden" name="mode" value=""> <input type="hidden" name="mode" value="">

View File

@ -396,11 +396,28 @@ if (empty($reshook)) {
// Set if we used free entry or predefined product // Set if we used free entry or predefined product
$predef = ''; $predef = '';
$product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : '');
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2); $price_ht = '';
$price_ht_devise = '';
$price_ttc = '';
$price_ttc_devise = '';
if (GETPOST('price_ht') !== '') {
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
}
if (GETPOST('multicurrency_price_ht') !== '') {
$price_ht_devise = price2num(GETPOST('multicurrency_price_ht'), 'CU', 2);
}
if (GETPOST('price_ttc') !== '') {
$price_ttc = price2num(GETPOST('price_ttc'), 'MU', 2);
}
if (GETPOST('multicurrency_price_ttc') !== '') {
$price_ttc_devise = price2num(GETPOST('multicurrency_price_ttc'), 'CU', 2);
}
if (GETPOST('prod_entry_mode', 'alpha') == 'free') { if (GETPOST('prod_entry_mode', 'alpha') == 'free') {
$idprod = 0; $idprod = 0;
$tva_tx = (GETPOST('tva_tx', 'alpha') ? GETPOST('tva_tx', 'alpha') : 0); $tva_tx = (GETPOST('tva_tx', 'alpha') ? price2num(preg_replace('/\s*\(.*\)/', '', GETPOST('tva_tx', 'alpha'))) : 0);
} else { } else {
$idprod = GETPOST('idprod', 'int'); $idprod = GETPOST('idprod', 'int');
$tva_tx = ''; $tva_tx = '';
@ -408,6 +425,9 @@ if (empty($reshook)) {
$qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS'); $qty = price2num(GETPOST('qty'.$predef, 'alpha'), 'MS');
$remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef), 2) : 0); $remise_percent = (GETPOSTISSET('remise_percent'.$predef) ? price2num(GETPOST('remise_percent'.$predef), 2) : 0);
if (empty($remise_percent)) {
$remise_percent = 0;
}
if ($qty == '') { if ($qty == '') {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Qty")), null, 'errors');
@ -460,6 +480,7 @@ if (empty($reshook)) {
$pu_ht = $prod->price; $pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc; $pu_ttc = $prod->price_ttc;
$price_min = $prod->price_min; $price_min = $prod->price_min;
$price_min_ttc = $prod->price_min_ttc;
$price_base_type = $prod->price_base_type; $price_base_type = $prod->price_base_type;
// On defini prix unitaire // On defini prix unitaire
@ -467,8 +488,10 @@ if (empty($reshook)) {
$pu_ht = $prod->multiprices[$object->thirdparty->price_level]; $pu_ht = $prod->multiprices[$object->thirdparty->price_level];
$pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level]; $pu_ttc = $prod->multiprices_ttc[$object->thirdparty->price_level];
$price_min = $prod->multiprices_min[$object->thirdparty->price_level]; $price_min = $prod->multiprices_min[$object->thirdparty->price_level];
$price_min_ttc = $prod->multiprices_min_ttc[$object->thirdparty->price_level];
$price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level]; $price_base_type = $prod->multiprices_base_type[$object->thirdparty->price_level];
} elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
// If price per customer
require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
$prodcustprice = new Productcustomerprice($db); $prodcustprice = new Productcustomerprice($db);
@ -478,10 +501,12 @@ if (empty($reshook)) {
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter); $result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
if ($result) { if ($result) {
if (count($prodcustprice->lines) > 0) { if (count($prodcustprice->lines) > 0) {
$pu_ht = price($prodcustprice->lines [0]->price); $pu_ht = price($prodcustprice->lines[0]->price);
$pu_ttc = price($prodcustprice->lines [0]->price_ttc); $pu_ttc = price($prodcustprice->lines[0]->price_ttc);
$price_base_type = $prodcustprice->lines [0]->price_base_type; $price_min = price($prodcustprice->lines[0]->price_min);
$tva_tx = $prodcustprice->lines [0]->tva_tx; $price_min_ttc = price($prodcustprice->lines[0]->price_min_ttc);
$price_base_type = $prodcustprice->lines[0]->price_base_type;
$tva_tx = $prodcustprice->lines[0]->tva_tx;
if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) { if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
$tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')'; $tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
} }
@ -496,9 +521,15 @@ if (empty($reshook)) {
$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx)); $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
// On reevalue prix selon taux tva car taux tva transaction peut etre different // Set unit price to use
// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). if (!empty($price_ht) || $price_ht === '0') {
if ($tmpvat != $tmpprodvat) { $pu_ht = price2num($price_ht, 'MU');
$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
} elseif (!empty($price_ttc) || $price_ttc === '0') {
$pu_ttc = price2num($price_ttc, 'MU');
$pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
} elseif ($tmpvat != $tmpprodvat) {
// Is this still used ?
if ($price_base_type != 'HT') { if ($price_base_type != 'HT') {
$pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU'); $pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
} else { } else {
@ -521,12 +552,22 @@ if (empty($reshook)) {
$fk_unit = $prod->fk_unit; $fk_unit = $prod->fk_unit;
} else { } else {
$pu_ht = GETPOST('price_ht'); $pu_ht = price2num($price_ht, 'MU');
$price_base_type = 'HT'; $pu_ttc = price2num($price_ttc, 'MU');
$tva_tx = GETPOST('tva_tx') ?str_replace('*', '', GETPOST('tva_tx')) : 0; // tva_tx field may be disabled, so we use vat rate 0 $tva_npr = (preg_match('/\*/', $tva_tx) ? 1 : 0);
$tva_npr = preg_match('/\*/', GETPOST('tva_tx')) ? 1 : 0; if (empty($tva_tx)) {
$tva_npr = 0;
}
$tva_tx = str_replace('*', '', $tva_tx);
$desc = $product_desc; $desc = $product_desc;
$fk_unit = GETPOST('units', 'alpha'); $fk_unit = GETPOST('units', 'alpha');
$pu_ht_devise = price2num($price_ht_devise, 'MU');
$pu_ttc_devise = price2num($price_ttc_devise, 'MU');
$price_base_type = 'HT';
if ($pu_ttc && !$pu_ht) {
$price_base_type = 'TTC';
}
} }
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr); $localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr);
@ -1427,6 +1468,11 @@ if ($action == 'create') {
* Lines of contracts * Lines of contracts
*/ */
// Add products/services form
//$forceall = 1;
global $inputalsopricewithtax;
$inputalsopricewithtax = 1;
$productstatic = new Product($db); $productstatic = new Product($db);
$usemargins = 0; $usemargins = 0;

View File

@ -1334,4 +1334,74 @@ class Utils
return $result; return $result;
} }
} }
/**
* Clean unfinished cronjob in processing when pid is no longer present in the system
* CAN BE A CRON TASK
*
* @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK)
* @throws Exception
*/
public function cleanUnfinishedCronjob()
{
global $db, $user;
dol_syslog("Utils::cleanUnfinishedCronjob Starting cleaning");
// Import Cronjob class if not present
dol_include_once('/cron/class/cronjob.class.php');
// Get this job object
$this_job = new Cronjob($db);
$this_job->fetch(-1, 'Utils', 'cleanUnfinishedCronjob');
if (empty($this_job->id) || !empty($this_job->error)) {
dol_syslog("Utils::cleanUnfinishedCronjob Unable to fetch himself: ".$this_job->error, LOG_ERR);
return -1;
}
// Set this job processing to 0 to avoid being locked by his processing state
$this_job->processing = 0;
if ($this_job->update($user) < 0) {
dol_syslog("Utils::cleanUnfinishedCronjob Unable to update himself: ".implode(', ', $this_job->errors), LOG_ERR);
return -1;
}
$cron_job = new Cronjob($db);
$cron_job->fetchAll('DESC', 't.rowid', 100, 0, 1, '', 1); // Fetch jobs that are currently running
// Iterate over all jobs in processing (this can't be this job since his state is set to 0 before)
foreach ($cron_job->lines as $job_line) {
// Avoid job with no PID
if (empty($job_line->pid)) {
dol_syslog("Utils::cleanUnfinishedCronjob Cronjob ".$job_line->id." don't have a PID", LOG_DEBUG);
continue;
}
$job = new Cronjob($db);
$job->fetch($job_line->id);
if (empty($job->id) || !empty($job->error)) {
dol_syslog("Utils::cleanUnfinishedCronjob Cronjob ".$job_line->id." can't be fetch: ".$job->error, LOG_ERR);
continue;
}
// Calling posix_kill with the 0 kill signal will return true if the process is running, false otherwise.
if (! posix_kill($job->pid, 0)) {
// Clean processing and pid values
$job->processing = 0;
$job->pid = null;
// Set last result as an error and add the reason on the last output
$job->lastresult = -1;
$job->lastoutput = 'Job killed by job cleanUnfinishedCronjob';
if ($job->update($user) < 0) {
dol_syslog("Utils::cleanUnfinishedCronjob Cronjob ".$job_line->id." can't be updated: ".implode(', ', $job->errors), LOG_ERR);
continue;
}
dol_syslog("Utils::cleanUnfinishedCronjob Cronjob ".$job_line->id." cleaned");
}
}
dol_syslog("Utils::cleanUnfinishedCronjob Cleaning completed");
return 0;
}
} }

View File

@ -432,8 +432,8 @@ function GETPOSTISSET($paramname)
* Can be used before GETPOST to know if the $check param of GETPOST need to check an array or a string * Can be used before GETPOST to know if the $check param of GETPOST need to check an array or a string
* *
* @param string $paramname Name or parameter to test * @param string $paramname Name or parameter to test
* @param int $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get) * @param int $method Type of method (0 = get then post, 1 = only get, 2 = only post, 3 = post then get)
* @return bool True if we have just submit a POST or GET request with the parameter provided (even if param is empty) * @return bool True if we have just submit a POST or GET request with the parameter provided (even if param is empty)
*/ */
function GETPOSTISARRAY($paramname, $method = 0) function GETPOSTISARRAY($paramname, $method = 0)
{ {

View File

@ -101,6 +101,7 @@ class modCron extends DolibarrModules
0=>array('entity'=>0, 'label'=>'PurgeDeleteTemporaryFilesShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'purgeFiles', 'parameters'=>'tempfilesold+logfiles', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>2, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>50, 'status'=>1, 'test'=>true), 0=>array('entity'=>0, 'label'=>'PurgeDeleteTemporaryFilesShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'purgeFiles', 'parameters'=>'tempfilesold+logfiles', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>2, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>50, 'status'=>1, 'test'=>true),
1=>array('entity'=>0, 'label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none,auto,1,auto,10', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>90, 'status'=>0, 'test'=>'in_array($conf->db->type, array(\'mysql\', \'mysqli\'))'), 1=>array('entity'=>0, 'label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none,auto,1,auto,10', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>90, 'status'=>0, 'test'=>'in_array($conf->db->type, array(\'mysql\', \'mysqli\'))'),
2=>array('entity'=>0, 'label'=>'MakeSendLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'sendDumpDatabase', 'parameters'=>',,,,,sql', 'comment'=>'MakeSendLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>604800, 'priority'=>91, 'status'=>0, 'test'=>'!empty($conf->global->MAIN_ALLOW_BACKUP_BY_EMAIL) && in_array($conf->db->type, array(\'mysql\', \'mysqli\'))'), 2=>array('entity'=>0, 'label'=>'MakeSendLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'sendDumpDatabase', 'parameters'=>',,,,,sql', 'comment'=>'MakeSendLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>604800, 'priority'=>91, 'status'=>0, 'test'=>'!empty($conf->global->MAIN_ALLOW_BACKUP_BY_EMAIL) && in_array($conf->db->type, array(\'mysql\', \'mysqli\'))'),
3=>array('entity'=>0, 'label'=>'CleanUnfinishedCronjobShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'cleanUnfinishedCronjob', 'parameters'=>'', 'comment'=>'CleanUnfinishedCronjob', 'frequency'=>5, 'unitfrequency'=>60, 'priority'=>10, 'status'=>0, 'test'=>'getDolGlobalInt("MAIN_FEATURES_LEVEL") >= 2'),
// 1=>array('entity'=>0, 'label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24) // 1=>array('entity'=>0, 'label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24)
); );

View File

@ -261,7 +261,7 @@ class modRecruitment extends DolibarrModules
'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'), 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth"'),
'mainmenu'=>'hrm', 'mainmenu'=>'hrm',
'leftmenu'=>'recruitmentjobposition', 'leftmenu'=>'recruitmentjobposition',
'url'=>'/recruitment/recruitmentindex.php', 'url'=>'/recruitment/index.php',
'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'position'=>1000 + $r, 'position'=>1000 + $r,
'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. 'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled.

View File

@ -146,6 +146,11 @@ if ($action == 'presend') {
$formmail->fromname = (!empty($conf->global->ORDER_SUPPLIER_EMAIL_SENDER_NAME) ? $conf->global->ORDER_SUPPLIER_EMAIL_SENDER_NAME : ''); $formmail->fromname = (!empty($conf->global->ORDER_SUPPLIER_EMAIL_SENDER_NAME) ? $conf->global->ORDER_SUPPLIER_EMAIL_SENDER_NAME : '');
$formmail->fromtype = 'special'; $formmail->fromtype = 'special';
} }
if ($object->element === 'recruitmentcandidature' ) {
$formmail->frommail = (!empty($conf->global->RECRUITMENT_EMAIL_SENDER) ? $conf->global->RECRUITMENT_EMAIL_SENDER : $recruitermail);
$formmail->fromname = (!empty($conf->global->RECRUITMENT_EMAIL_SENDER_NAME) ? $conf->global->RECRUITMENT_EMAIL_SENDER_NAME : (!empty($recruitername) ? $recruitername : ''));
$formmail->fromtype = 'special';
}
$formmail->trackid = empty($trackid) ? '' : $trackid; $formmail->trackid = empty($trackid) ? '' : $trackid;
$formmail->inreplyto = empty($inreplyto) ? '' : $inreplyto; $formmail->inreplyto = empty($inreplyto) ? '' : $inreplyto;

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com> /* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2020 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2010-2022 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr> * Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
* Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr> * Copyright (C) 2012 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr> * Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
@ -325,8 +325,8 @@ $coldisplay++;
<!-- colspan for this td because it replace total_ht+3 td for buttons+... --> <!-- colspan for this td because it replace total_ht+3 td for buttons+... -->
<td class="center valignmiddle" colspan="<?php echo $colspan; ?>"><?php $coldisplay += $colspan; ?> <td class="center valignmiddle" colspan="<?php echo $colspan; ?>"><?php $coldisplay += $colspan; ?>
<input type="submit" class="button buttongen marginbottomonly button-save" id="savelinebutton marginbottomonly" name="save" value="<?php echo $langs->trans("Save"); ?>"><br> <input type="submit" class="reposition button buttongen marginbottomonly button-save" id="savelinebutton marginbottomonly" name="save" value="<?php echo $langs->trans("Save"); ?>"><br>
<input type="submit" class="button buttongen marginbottomonly button-cancel" id="cancellinebutton" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>"> <input type="submit" class="reposition button buttongen marginbottomonly button-cancel" id="cancellinebutton" name="cancel" value="<?php echo $langs->trans("Cancel"); ?>">
</td> </td>
</tr> </tr>

View File

@ -1140,7 +1140,7 @@ class Cronjob extends CommonObject
$this->lastoutput = ''; $this->lastoutput = '';
$this->lastresult = ''; $this->lastresult = '';
$this->processing = 1; // To know job was started $this->processing = 1; // To know job was started
$this->pid = dol_getmypid(); $this->pid = function_exists('getmypid') ? getmypid() : null; // Avoid dol_getmypid to get null if the function is not available
$this->nbrun = $this->nbrun + 1; $this->nbrun = $this->nbrun + 1;
$result = $this->update($user); // This include begin/commit $result = $this->update($user); // This include begin/commit
if ($result < 0) { if ($result < 0) {

View File

@ -49,7 +49,7 @@ if (!empty($conf->project->enabled)) {
} }
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("sendings", "bills", 'deliveries', 'orders')); $langs->loadLangs(array('bills', 'deliveries', 'orders', 'sendings'));
if (!empty($conf->incoterm->enabled)) { if (!empty($conf->incoterm->enabled)) {
$langs->load('incoterm'); $langs->load('incoterm');
@ -89,10 +89,10 @@ $error = 0;
*/ */
$parameters = array(); $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
// Delete Link // Delete Link
$permissiondellink = $user->rights->expedition->delivery->supprimer; // Used by the include of actions_dellink.inc.php $permissiondellink = $user->rights->expedition->delivery->supprimer; // Used by the include of actions_dellink.inc.php
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
if ($action == 'add') { if ($action == 'add') {
$db->begin(); $db->begin();
@ -101,7 +101,7 @@ if ($action == 'add') {
$object->note = GETPOST("note", 'restricthtml'); $object->note = GETPOST("note", 'restricthtml');
$object->note_private = GETPOST("note", 'restricthtml'); $object->note_private = GETPOST("note", 'restricthtml');
$object->commande_id = GETPOST("commande_id", 'int'); $object->commande_id = GETPOST("commande_id", 'int');
$object->fk_incoterms = GETPOST('incoterm_id', 'int'); $object->fk_incoterms = GETPOST('incoterm_id', 'int');
if (!$conf->expedition_bon->enabled && !empty($conf->stock->enabled)) { if (!$conf->expedition_bon->enabled && !empty($conf->stock->enabled)) {
$expedition->entrepot_id = GETPOST('entrepot_id', 'int'); $expedition->entrepot_id = GETPOST('entrepot_id', 'int');

View File

@ -1582,7 +1582,9 @@ class EmailCollector extends CommonObject
$plainmsg = $imapemail->getTextBody(); $plainmsg = $imapemail->getTextBody();
} }
if ($imapemail->hasAttachments()) { if ($imapemail->hasAttachments()) {
$attachments = $imapemail->getAttachments(); $attachments = $imapemail->getAttachments()->all();
} else {
$attachments = [];
} }
} else { } else {
$this->getmsg($connection, $imapemail); $this->getmsg($connection, $imapemail);
@ -2440,6 +2442,20 @@ class EmailCollector extends CommonObject
$errorforactions++; $errorforactions++;
$this->error = 'Failed to create project: '.$langs->trans($projecttocreate->error); $this->error = 'Failed to create project: '.$langs->trans($projecttocreate->error);
$this->errors = $projecttocreate->errors; $this->errors = $projecttocreate->errors;
} else {
if ($attachments) {
$destdir = $conf->project->dir_output.'/'.$projecttocreate->ref;
if (!dol_is_dir($destdir)) {
dol_mkdir($destdir);
}
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
foreach ($attachments as $attachment) {
$attachment->save($destdir.'/');
}
} else {
$this->getmsg($connection, $imapemail, $destdir);
}
}
} }
} }
} }
@ -2550,13 +2566,16 @@ class EmailCollector extends CommonObject
$this->errors = $tickettocreate->errors; $this->errors = $tickettocreate->errors;
} else { } else {
if ($attachments) { if ($attachments) {
$destdir = $conf->ticket->dir_output.'/'.$tickettocreate->ref;
if (!dol_is_dir($destdir)) {
dol_mkdir($destdir);
}
if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) { if (!empty($conf->global->MAIN_IMAP_USE_PHPIMAP)) {
$destdir = $conf->ticket->dir_output.'/'.$tickettocreate->ref; foreach ($attachments as $attachment) {
if (!dol_is_dir($destdir)) { $attachment->save($destdir.'/');
return -1;
dol_mkdir($destdir);
$this->getmsg($connection, $imapemail, $destdir);
} }
} else {
$this->getmsg($connection, $imapemail, $destdir);
} }
} }
} }

View File

@ -120,7 +120,7 @@ $search_project_ref = GETPOST('search_project_ref', 'alpha');
$search_btn = GETPOST('button_search', 'alpha'); $search_btn = GETPOST('button_search', 'alpha');
$search_remove_btn = GETPOST('button_removefilter', 'alpha'); $search_remove_btn = GETPOST('button_removefilter', 'alpha');
if (is_array(GETPOST('search_status', 'none'))) { // 'none' because we want to know type before sanitizing if (GETPOSTISARRAY('search_status')) {
$search_status = join(',', GETPOST('search_status', 'array:intcomma')); $search_status = join(',', GETPOST('search_status', 'array:intcomma'));
} else { } else {
$search_status = (GETPOST('search_status', 'intcomma') != '' ? GETPOST('search_status', 'intcomma') : GETPOST('statut', 'intcomma')); $search_status = (GETPOST('search_status', 'intcomma') != '' ? GETPOST('search_status', 'intcomma') : GETPOST('statut', 'intcomma'));

View File

@ -13,4 +13,5 @@
./vendor/phpdocumentor ./vendor/phpdocumentor
./vendor/nesbot/carbon/src/Carbon/Lang ./vendor/nesbot/carbon/src/Carbon/Lang
./vendor/doctrine ./vendor/doctrine
./vendor/bin
./tests ./tests

View File

@ -31,7 +31,7 @@ class ComposerStaticInit4da13270269c89a28e472e1f7324e6d1
), ),
'T' => 'T' =>
array ( array (
'Tests\\' => 6, // 'Tests\\' => 6,
), ),
'S' => 'S' =>
array ( array (

View File

@ -84,6 +84,8 @@ MakeLocalDatabaseDumpShort=Local database backup
MakeLocalDatabaseDump=Create a local database dump. Parameters are: compression ('gz' or 'bz' or 'none'), backup type ('mysql', 'pgsql', 'auto'), 1, 'auto' or filename to build, number of backup files to keep MakeLocalDatabaseDump=Create a local database dump. Parameters are: compression ('gz' or 'bz' or 'none'), backup type ('mysql', 'pgsql', 'auto'), 1, 'auto' or filename to build, number of backup files to keep
MakeSendLocalDatabaseDumpShort=Send local database backup MakeSendLocalDatabaseDumpShort=Send local database backup
MakeSendLocalDatabaseDump=Send local database backup by email. Parameters are: to, from, subject, message, filename (Name of file sent), filter ('sql' for backup of database only) MakeSendLocalDatabaseDump=Send local database backup by email. Parameters are: to, from, subject, message, filename (Name of file sent), filter ('sql' for backup of database only)
CleanUnfinishedCronjobShort=Clean unfinished cronjob
CleanUnfinishedCronjob=Clean cronjob stuck in processing when the process is no longer running
WarningCronDelayed=Attention, for performance purpose, whatever is next date of execution of enabled jobs, your jobs may be delayed to a maximum of %s hours, before being run. WarningCronDelayed=Attention, for performance purpose, whatever is next date of execution of enabled jobs, your jobs may be delayed to a maximum of %s hours, before being run.
DATAPOLICYJob=Data cleaner and anonymizer DATAPOLICYJob=Data cleaner and anonymizer
JobXMustBeEnabled=Job %s must be enabled JobXMustBeEnabled=Job %s must be enabled

View File

@ -57,8 +57,9 @@ EmailRecruiter=Email recruiter
ToUseAGenericEmail=To use a generic email. If not defined, the email of the responsible of recruitment will be used ToUseAGenericEmail=To use a generic email. If not defined, the email of the responsible of recruitment will be used
NewCandidature=New application NewCandidature=New application
ListOfCandidatures=List of applications ListOfCandidatures=List of applications
RequestedRemuneration=Requested remuneration Remuneration=Salary
ProposedRemuneration=Proposed remuneration RequestedRemuneration=Requested salary
ProposedRemuneration=Proposed salary
ContractProposed=Contract proposed ContractProposed=Contract proposed
ContractSigned=Contract signed ContractSigned=Contract signed
ContractRefused=Contract refused ContractRefused=Contract refused

View File

@ -50,7 +50,7 @@ class RecruitmentCandidature extends CommonObject
* @var int Does this object support multicompany module ? * @var int Does this object support multicompany module ?
* 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table * 0=No test on entity, 1=Test with field entity, 'field@table'=Test with link by field@table
*/ */
public $ismultientitymanaged = 0; public $ismultientitymanaged = 1;
/** /**
* @var int Does object support extrafields ? 0=No, 1=Yes * @var int Does object support extrafields ? 0=No, 1=Yes

View File

@ -19,7 +19,7 @@
*/ */
/** /**
* \file recruitment/recruitmentindex.php * \file recruitment/index.php
* \ingroup recruitment * \ingroup recruitment
* \brief Home page of recruitment top menu * \brief Home page of recruitment top menu
*/ */

View File

@ -41,12 +41,12 @@ function recruitmentCandidaturePrepareHead($object)
$head[$h][2] = 'card'; $head[$h][2] = 'card';
$h++; $h++;
if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
$head[$h][0] = dol_buildpath("/recruitment/recruitmentrating_card.php", 1).'?id='.$object->id; // $head[$h][0] = dol_buildpath("/recruitment/recruitmentrating_card.php", 1).'?id='.$object->id;
$head[$h][1] = $langs->trans("Rating"); // $head[$h][1] = $langs->trans("Rating");
$head[$h][2] = 'rating'; // $head[$h][2] = 'rating';
$h++; // $h++;
} // }
if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) { if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
$nbNote = 0; $nbNote = 0;

View File

@ -42,7 +42,7 @@ function recruitmentjobpositionPrepareHead($object)
$h++; $h++;
$head[$h][0] = dol_buildpath("/recruitment/recruitmentcandidature_list.php", 1).'?id='.$object->id; $head[$h][0] = dol_buildpath("/recruitment/recruitmentcandidature_list.php", 1).'?id='.$object->id;
$head[$h][1] = $langs->trans("Candidatures"); $head[$h][1] = $langs->trans("RecruitmentCandidatures");
$sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature WHERE fk_recruitmentjobposition = ".((int) $object->id); $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."recruitment_recruitmentcandidature WHERE fk_recruitmentjobposition = ".((int) $object->id);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {

View File

@ -124,7 +124,7 @@ if (empty($reshook)) {
$form = new Form($db); $form = new Form($db);
if ($object->id > 0) { if ($object->id > 0) {
$title = $langs->trans("Agenda"); $title = $object->ref." - ".$langs->trans('Agenda');
//if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
$help_url = 'Module_Agenda_En'; $help_url = 'Module_Agenda_En';
llxHeader('', $title, $help_url); llxHeader('', $title, $help_url);

View File

@ -257,10 +257,15 @@ $form = new Form($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
$formproject = new FormProjets($db); $formproject = new FormProjets($db);
$title = $langs->trans("RecruitmentCandidature"); if ($action == 'create') {
$help_url = ''; $title = $langs->trans('NewCandidature');
llxHeader('', $title, $help_url); $help_url = '';
} else {
$title = $object->ref." - ".$langs->trans('Card');
$help_url = '';
}
llxHeader('', $title, $help_url);
// Part to create // Part to create
if ($action == 'create') { if ($action == 'create') {
@ -651,6 +656,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$trackid = 'recruitmentcandidature'.$object->id; $trackid = 'recruitmentcandidature'.$object->id;
$inreplyto = $object->email_msgid; $inreplyto = $object->email_msgid;
$job = new RecruitmentJobPosition($db);
$job->fetch($object->fk_recruitmentjobposition);
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
$recruiter = new User($db);
$recruiter->fetch($job->fk_user_recruiter);
$recruitername = $recruiter->getFullName('');
$recruitermail = (!empty($job->email_recruiter) ? $job->email_recruiter : $recruiter->email);
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
} }

View File

@ -97,9 +97,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
$form = new Form($db); $form = new Form($db);
$title = $langs->trans("RecruitmentJobPosition").' - '.$langs->trans("Files"); $title = $object->ref." - ".$langs->trans('Files');
$help_url = ''; $help_url = '';
//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url); llxHeader('', $title, $help_url);
if ($object->id) { if ($object->id) {

View File

@ -556,7 +556,7 @@ $newcardbutton = '';
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-bars imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ((empty($mode) || $mode == 'common') ? 2 : 1), array('morecss'=>'reposition'));
$newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition')); $newcardbutton .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=kanban'.preg_replace('/(&|\?)*mode=[^&]+/', '', $param), '', ($mode == 'kanban' ? 2 : 1), array('morecss'=>'reposition'));
$newcardbutton .= dolGetButtonTitleSeparator(); $newcardbutton .= dolGetButtonTitleSeparator();
$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/recruitment/recruitmentcandidature_card.php', 1).'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.((int) $id)), '', $permissiontoadd); $newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', dol_buildpath('/recruitment/recruitmentcandidature_card.php', 1).'?action=create&fk_recruitmentjobposition='.$id, '', $permissiontoadd);
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'object_'.$object->picto, 0, $newcardbutton, '', $limit, 0, 0, 1);

View File

@ -80,9 +80,9 @@ if (empty($reshook)) {
$form = new Form($db); $form = new Form($db);
//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'; $title = $object->ref." - ".$langs->trans('Notes');
$help_url = ''; $help_url = '';
llxHeader('', $langs->trans('RecruitmentCandidature'), $help_url); llxHeader('', $title, $help_url);
if ($id > 0 || !empty($ref)) { if ($id > 0 || !empty($ref)) {
$object->fetch_thirdparty(); $object->fetch_thirdparty();

View File

@ -124,7 +124,7 @@ if (empty($reshook)) {
$form = new Form($db); $form = new Form($db);
if ($object->id > 0) { if ($object->id > 0) {
$title = $langs->trans("Agenda"); $title = $object->ref." - ".$langs->trans('Agenda');
//if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title; //if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name." - ".$title;
$help_url = ''; $help_url = '';
llxHeader('', $title, $help_url); llxHeader('', $title, $help_url);

View File

@ -177,7 +177,7 @@ $form = new Form($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
$formproject = new FormProjets($db); $formproject = new FormProjets($db);
$title = $langs->trans("PositionToBeFilled"); $title = $object->ref." - ".$langs->trans('Card');
$help_url = ''; $help_url = '';
llxHeader('', $title, $help_url); llxHeader('', $title, $help_url);

View File

@ -97,7 +97,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
$form = new Form($db); $form = new Form($db);
$title = $langs->trans("RecruitmentJobPosition").' - '.$langs->trans("Files"); $title = $object->ref." - ".$langs->trans('Files');
$help_url = ''; $help_url = '';
//$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; //$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas';
llxHeader('', $title, $help_url); llxHeader('', $title, $help_url);

View File

@ -85,9 +85,9 @@ if (empty($reshook)) {
$form = new Form($db); $form = new Form($db);
//$help_url='EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'; $title = $object->ref." - ".$langs->trans('Notes');
$help_url = ''; $help_url = '';
llxHeader('', $langs->trans('RecruitmentJobPosition'), $help_url); llxHeader('', $title, $help_url);
if ($id > 0 || !empty($ref)) { if ($id > 0 || !empty($ref)) {
$object->fetch_thirdparty(); $object->fetch_thirdparty();

View File

@ -35,12 +35,12 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->load("companies"); $langs->load('companies');
// Get parameters // Get parameters
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha');
@ -52,6 +52,7 @@ if (GETPOST('actioncode', 'array')) {
} else { } else {
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
} }
$search_agenda_label = GETPOST('search_agenda_label'); $search_agenda_label = GETPOST('search_agenda_label');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
@ -72,7 +73,7 @@ if (!$sortorder) {
} }
// Initialize technical objects // Initialize technical objects
//$object=new MyObject($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$hookmanager->initHooks(array('agendaresource')); $hookmanager->initHooks(array('agendaresource'));
@ -94,7 +95,7 @@ if (!$user->rights->resource->read) {
*/ */
$parameters = array('id'=>$id); $parameters = array('id'=>$id);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) { if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
} }
@ -126,7 +127,6 @@ if ($object->id > 0) {
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$langs->load("companies");
$picto = 'resource'; $picto = 'resource';
$title = $langs->trans("Agenda"); $title = $langs->trans("Agenda");

View File

@ -1,10 +1,13 @@
<?php <?php
/* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com> /* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2016 Gilles Poirier <glgpoirier@gmail.com> * Copyright (C) 2016 Gilles Poirier <glgpoirier@gmail.com>
* *
*/
/**
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
@ -22,7 +25,7 @@
/** /**
* \file htdocs/resource/contact.php * \file htdocs/resource/contact.php
* \ingroup resource * \ingroup resource
* \brief Onglet de gestion des contacts des resources * \brief Contacts management tab for resources
*/ */
require '../main.inc.php'; require '../main.inc.php';
@ -32,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('resource', 'sendings', 'companies')); $langs->loadLangs(array('companies', 'resource', 'sendings'));
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
@ -41,7 +44,7 @@ $action = GETPOST('action', 'aZ09');
$object = new DolResource($db); $object = new DolResource($db);
// Load object // Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
// Security check // Security check
if ($user->socid) { if ($user->socid) {
@ -55,10 +58,12 @@ if (!$user->rights->resource->read) {
} }
/* /*
* Add a new contact * Actions
*/ */
// Add a new contact
if ($action == 'addcontact' && $user->rights->resource->write) { if ($action == 'addcontact' && $user->rights->resource->write) {
if ($result > 0 && $id > 0) { if ($result > 0 && $id > 0) {
$contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int'));
@ -106,7 +111,7 @@ $userstatic = new User($db);
llxHeader('', $langs->trans("Resource")); llxHeader('', $langs->trans("Resource"));
// Mode vue et edition // View and edit mode
if ($id > 0 || !empty($ref)) { if ($id > 0 || !empty($ref)) {
$soc = new Societe($db); $soc = new Societe($db);

View File

@ -1,4 +1,5 @@
<?php <?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2020 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr> * Copyright (C) 2020 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
@ -17,7 +18,7 @@
*/ */
/** /**
* \file workstation_agenda.php * \file htdocs/workstation/workstation_agenda.php
* \ingroup workstation * \ingroup workstation
* \brief Tab of events on Workstation * \brief Tab of events on Workstation
*/ */
@ -32,12 +33,12 @@ require_once DOL_DOCUMENT_ROOT.'/workstation/lib/workstation_workstation.lib.php
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("workstation", "other")); $langs->loadLangs(array('workstation', 'other'));
// Get parameters // Get parameters
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha');
@ -49,6 +50,7 @@ if (GETPOST('actioncode', 'array')) {
} else { } else {
$actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
} }
$search_agenda_label = GETPOST('search_agenda_label'); $search_agenda_label = GETPOST('search_agenda_label');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
@ -73,6 +75,7 @@ $object = new Workstation($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->workstation->dir_output.'/temp/massgeneration/'.$user->id; $diroutputmassaction = $conf->workstation->dir_output.'/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('workstationagenda', 'globalcard')); // Note that conf->hooks_modules contains array $hookmanager->initHooks(array('workstationagenda', 'globalcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels // Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element); $extrafields->fetch_name_optionals_label($object->table_element);

View File

@ -1,4 +1,5 @@
<?php <?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -16,7 +17,7 @@
*/ */
/** /**
* \file workstation_card.php * \file htdocs/workstation/workstation_card.php
* \ingroup workstation * \ingroup workstation
* \brief Page to create/edit/view workstation * \brief Page to create/edit/view workstation
*/ */
@ -24,32 +25,33 @@
// Load Dolibarr environment // Load Dolibarr environment
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php';
require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php';
require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php';
require_once DOL_DOCUMENT_ROOT.'/workstation/lib/workstation_workstation.lib.php';
require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstationusergroup.class.php'; require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstationusergroup.class.php';
require_once DOL_DOCUMENT_ROOT.'/workstation/lib/workstation_workstation.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("workstation", "other")); $langs->loadLangs(array('workstation', 'other'));
// Get parameters // Get parameters
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha'); $confirm = GETPOST('confirm', 'alpha');
$cancel = GETPOST('cancel', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'workstationcard'; // To manage different context of search $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'workstationcard'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha');
$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha'); $backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
$groups = GETPOST('groups', 'array:int'); $groups = GETPOST('groups', 'array:int');
$resources = GETPOST('resources', 'array:int'); $resources = GETPOST('resources', 'array:int');
//$lineid = GETPOST('lineid', 'int'); //$lineid = GETPOST('lineid', 'int');
// Initialize technical objects // Initialize technical objects
$object = new Workstation($db); $object = new Workstation($db);
//$extrafields = new ExtraFields($db); //$extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->workstation->dir_output.'/temp/massgeneration/'.$user->id; $diroutputmassaction = $conf->workstation->dir_output.'/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('workstationcard', 'globalcard')); // Note that conf->hooks_modules contains array $hookmanager->initHooks(array('workstationcard', 'globalcard')); // Note that conf->hooks_modules contains array
@ -142,7 +144,6 @@ if (empty($reshook)) {
/* /*
* View * View
* *

View File

@ -1,4 +1,5 @@
<?php <?php
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2020 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr> * Copyright (C) 2020 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
@ -17,22 +18,22 @@
*/ */
/** /**
* \file workstation_document.php * \file htdocs/workstation/workstation_document.php
* \ingroup workstation * \ingroup workstation
* \brief Tab for documents linked to Workstation * \brief Tab for documents linked to Workstation
*/ */
// Load Dolibarr environment // Load Dolibarr environment
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php';
require_once DOL_DOCUMENT_ROOT.'/workstation/lib/workstation_workstation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/workstation/lib/workstation_workstation.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("workstation", "companies", "other", "mails")); $langs->loadLangs(array('companies', 'mails', 'other', 'workstation'));
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -64,6 +65,7 @@ $object = new Workstation($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->workstation->dir_output.'/temp/massgeneration/'.$user->id; $diroutputmassaction = $conf->workstation->dir_output.'/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('workstationdocument', 'globalcard')); // Note that conf->hooks_modules contains array $hookmanager->initHooks(array('workstationdocument', 'globalcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels // Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element); $extrafields->fetch_name_optionals_label($object->table_element);

View File

@ -1,4 +1,5 @@
<?php <?php
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2020 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr> * Copyright (C) 2020 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
@ -17,7 +18,7 @@
*/ */
/** /**
* \file workstation_list.php * \file htdocs/workstation/workstation_list.php
* \ingroup workstation * \ingroup workstation
* \brief List page for workstation * \brief List page for workstation
*/ */
@ -25,24 +26,24 @@
// Load Dolibarr environment // Load Dolibarr environment
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php';
require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php'; require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("workstation", "other")); $langs->loadLangs(array('workstation', 'other'));
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ... $action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists) $massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
$show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ? $show_files = GETPOST('show_files', 'int'); // Show files area generated by bulk actions ?
$confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation
$cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'workstationlist'; // To manage different context of search $contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'workstationlist'; // To manage different context of search
$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
$mode = GETPOST('mode', 'aZ'); $mode = GETPOST('mode', 'aZ');
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
@ -63,7 +64,7 @@ $pagenext = $page + 1;
$object = new Workstation($db); $object = new Workstation($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->workstation->dir_output.'/temp/massgeneration/'.$user->id; $diroutputmassaction = $conf->workstation->dir_output.'/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('workstationlist')); // Note that conf->hooks_modules contains array $hookmanager->initHooks(array('workstationlist')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels // Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element); $extrafields->fetch_name_optionals_label($object->table_element);

View File

@ -1,4 +1,5 @@
<?php <?php
/* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2020 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr> * Copyright (C) 2020 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* *
@ -17,7 +18,7 @@
*/ */
/** /**
* \file workstation_note.php * \file htdocs/workstation/workstation_note.php
* \ingroup workstation * \ingroup workstation
* \brief Tab for notes on Workstation * \brief Tab for notes on Workstation
*/ */
@ -29,12 +30,12 @@ require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php';
require_once DOL_DOCUMENT_ROOT.'/workstation/lib/workstation_workstation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/workstation/lib/workstation_workstation.lib.php';
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array("workstation", "companies")); $langs->loadLangs(array('workstation', 'companies'));
// Get parameters // Get parameters
$id = GETPOST('id', 'int'); $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09');
$backtopage = GETPOST('backtopage', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha');
@ -42,18 +43,19 @@ $backtopage = GETPOST('backtopage', 'alpha');
$object = new Workstation($db); $object = new Workstation($db);
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
$diroutputmassaction = $conf->workstation->dir_output.'/temp/massgeneration/'.$user->id; $diroutputmassaction = $conf->workstation->dir_output.'/temp/massgeneration/'.$user->id;
$hookmanager->initHooks(array('workstationnote', 'globalcard')); // Note that conf->hooks_modules contains array $hookmanager->initHooks(array('workstationnote', 'globalcard')); // Note that conf->hooks_modules contains array
// Fetch optionals attributes and labels // Fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element); $extrafields->fetch_name_optionals_label($object->table_element);
// Load object // Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
if ($id > 0 || !empty($ref)) { if ($id > 0 || !empty($ref)) {
$upload_dir = $conf->workstation->multidir_output[$object->entity]."/".$object->id; $upload_dir = $conf->workstation->multidir_output[$object->entity]."/".$object->id;
} }
$permissionnote = $user->rights->workstation->workstation->write; // Used by the include of actions_setnotes.inc.php $permissionnote = $user->rights->workstation->workstation->write; // Used by the include of actions_setnotes.inc.php
$permissiontoadd = $user->rights->workstation->workstation->write; // Used by the include of actions_addupdatedelete.inc.php $permissiontoadd = $user->rights->workstation->workstation->write; // Used by the include of actions_addupdatedelete.inc.php
// Security check // Security check
$isdraft = 0; $isdraft = 0;
@ -63,7 +65,8 @@ restrictedArea($user, $object->element, $object->id, $object->table_element, 'wo
/* /*
* Actions * Actions
*/ */
$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) { if ($reshook < 0) {
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
} }

View File

@ -26,11 +26,11 @@
require '../../main.inc.php'; require '../../main.inc.php';
// Libraries // Libraries
require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/zapier/lib/zapier.lib.php'; require_once DOL_DOCUMENT_ROOT.'/zapier/lib/zapier.lib.php';
// Translations // Translations
$langs->loadLangs(array("admin", "zapier")); $langs->loadLangs(array('admin', 'zapier'));
// Access control // Access control
if (!$user->admin) { if (!$user->admin) {
@ -63,7 +63,7 @@ if ((float) DOL_VERSION >= 6) {
* View * View
*/ */
$page_name = "ZapierForDolibarrSetup"; $page_name = 'ZapierForDolibarrSetup';
$help_url = 'EN:Module_Zapier'; $help_url = 'EN:Module_Zapier';
llxHeader('', $langs->trans($page_name), $help_url); llxHeader('', $langs->trans($page_name), $help_url);

View File

@ -1,4 +1,5 @@
<?php <?php
/* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr> /* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2019-2020 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2019-2020 Frédéric France <frederic.france@netlogic.fr>
* *
@ -16,16 +17,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
use Luracast\Restler\RestException;
require_once DOL_DOCUMENT_ROOT.'/zapier/class/hook.class.php';
/** /**
* \file htdocs/zapier/class/api_zapier.class.php * \file htdocs/zapier/class/api_zapier.class.php
* \ingroup zapier * \ingroup zapier
* \brief File for API management of hook. * \brief File for API management of hook.
*/ */
use Luracast\Restler\RestException;
require_once DOL_DOCUMENT_ROOT.'/zapier/class/hook.class.php';
/** /**
* API class for zapier hook * API class for zapier hook
* *

View File

@ -1,90 +0,0 @@
<?php
/* Copyright (C) ---Put here your own copyright and developer email---
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/modulebuilder/template/lib/mymodule_myobject.lib.php
* \ingroup mymodule
* \brief Library files with common functions for MyObject
*/
/**
* Prepare array of tabs for MyObject
*
* @param MyObject $object MyObject
* @return array Array of tabs
*/
function myobjectPrepareHead($object)
{
global $db, $langs, $conf;
$langs->load("mymodule@mymodule");
$h = 0;
$head = array();
$head[$h][0] = dol_buildpath("/mymodule/myobject_card.php", 1).'?id='.$object->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
$nbNote = 0;
if (!empty($object->note_private)) {
$nbNote++;
}
if (!empty($object->note_public)) {
$nbNote++;
}
$head[$h][0] = dol_buildpath('/mymodule/myobject_note.php', 1).'?id='.$object->id;
$head[$h][1] = $langs->trans('Notes');
if ($nbNote > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
}
$head[$h][2] = 'note';
$h++;
}
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
$upload_dir = $conf->mymodule->dir_output."/myobject/".dol_sanitizeFileName($object->ref);
$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
$nbLinks = Link::count($db, $object->element, $object->id);
$head[$h][0] = dol_buildpath("/mymodule/myobject_document.php", 1).'?id='.$object->id;
$head[$h][1] = $langs->trans('Documents');
if (($nbFiles + $nbLinks) > 0) {
$head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
}
$head[$h][2] = 'document';
$h++;
$head[$h][0] = dol_buildpath("/mymodule/myobject_agenda.php", 1).'?id='.$object->id;
$head[$h][1] = $langs->trans("Events");
$head[$h][2] = 'agenda';
$h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
//$this->tabs = array(
// 'entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'
//); // to add new tab
//$this->tabs = array(
// 'entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'
//); // to remove a tab
complete_head_from_modules($conf, $langs, $object, $head, $h, 'myobject@mymodule');
return $head;
}

View File

@ -464,7 +464,9 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
//var_dump($val); //var_dump($val);
if (!in_array($val[1], array( if (!in_array($val[1], array(
"'replacestring'", "'htmlheader'", "'WEBSITE_HTML_HEADER'", "'WEBSITE_CSS_INLINE'", "'WEBSITE_JS_INLINE'", "'WEBSITE_MANIFEST_JSON'", "'PAGE_CONTENT'", "'WEBSITE_README'", "'replacestring'", "'htmlheader'", "'WEBSITE_HTML_HEADER'", "'WEBSITE_CSS_INLINE'", "'WEBSITE_JS_INLINE'", "'WEBSITE_MANIFEST_JSON'", "'PAGE_CONTENT'", "'WEBSITE_README'",
"'search_status'", '"mysqldump"', '"postgresqldump"', "'db_pass_root'", "'db_pass'", '"pass"', '"pass1"', '"pass2"', '"password"', "'password'", '"MAIN_MAIL_SMTPS_PW"'))) { '"mysqldump"', '"postgresqldump"',
"'db_pass_root'", "'db_pass'", '"pass"', '"pass1"', '"pass2"', '"password"', "'password'",
'"MAIN_MAIL_SMTPS_PW"', '"MAIN_MAIL_SMTPS_PW_EMAILING"', '"MAIN_MAIL_SMTPS_PW_TICKET"'))) {
$ok=false; $ok=false;
break; break;
} }