Merge branch 'Dolibarr:develop' into develop

This commit is contained in:
Benjamin Chantalat 2021-09-24 14:09:14 +02:00 committed by GitHub
commit 95342777d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
88 changed files with 846 additions and 503 deletions

View File

@ -924,7 +924,7 @@ class AccountancyExport
$date_creation = dol_print_date($line->date_creation, '%Y%m%d'); $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
$date_document = dol_print_date($line->doc_date, '%Y%m%d'); $date_document = dol_print_date($line->doc_date, '%Y%m%d');
$date_lettering = dol_print_date($line->date_lettering, '%Y%m%d'); $date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
$date_validation = dol_print_date($line->date_validated, '%Y%m%d'); $date_validation = dol_print_date($line->date_validation, '%Y%m%d');
$date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d'); $date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d');
// FEC:JournalCode // FEC:JournalCode
@ -1030,7 +1030,7 @@ class AccountancyExport
$date_creation = dol_print_date($line->date_creation, '%Y%m%d'); $date_creation = dol_print_date($line->date_creation, '%Y%m%d');
$date_document = dol_print_date($line->doc_date, '%Y%m%d'); $date_document = dol_print_date($line->doc_date, '%Y%m%d');
$date_lettering = dol_print_date($line->date_lettering, '%Y%m%d'); $date_lettering = dol_print_date($line->date_lettering, '%Y%m%d');
$date_validation = dol_print_date($line->date_validated, '%Y%m%d'); $date_validation = dol_print_date($line->date_validation, '%Y%m%d');
$date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d'); $date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d');
// FEC:JournalCode // FEC:JournalCode

View File

@ -369,9 +369,9 @@ if ($result) {
print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
print '<span class="opacitymedium">'.$langs->trans("DescVentilDoneCustomer").'</span><br>'; print '<span class="opacitymedium">'.$langs->trans("DescVentilDoneCustomer").'</span><br>';
print '<br><div class="inline-block divButAction">'.$langs->trans("ChangeAccount").'<br>'; print '<br><div class="inline-block divButAction paddingbottom">'.$langs->trans("ChangeAccount").' ';
print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle');
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("ChangeBinding").'"/></div>'; print '<input type="submit" class="button small valignmiddle" value="'.$langs->trans("ChangeBinding").'"/></div>';
$moreforfilter = ''; $moreforfilter = '';

View File

@ -369,9 +369,9 @@ if ($result) {
print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); print_barre_liste($langs->trans("InvoiceLinesDone"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
print '<span class="opacitymedium">'.$langs->trans("DescVentilDoneSupplier").'</span><br>'; print '<span class="opacitymedium">'.$langs->trans("DescVentilDoneSupplier").'</span><br>';
print '<br><div class="inline-block divButAction">'.$langs->trans("ChangeAccount").'<br>'; print '<br><div class="inline-block divButAction paddingbottom">'.$langs->trans("ChangeAccount").' ';
print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle'); print $formaccounting->select_account($account_parent, 'account_parent', 2, array(), 0, 0, 'maxwidth300 maxwidthonsmartphone valignmiddle');
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("ChangeBinding").'"/></div>'; print '<input type="submit" class="button small valignmiddle" value="'.$langs->trans("ChangeBinding").'"/></div>';
$moreforfilter = ''; $moreforfilter = '';

View File

@ -1839,7 +1839,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '</td></tr>'; print '</td></tr>';
} }
// Login Dolibarr // Login Dolibarr - Link to user
print '<tr><td>'; print '<tr><td>';
$editenable = $user->rights->adherent->creer && $user->rights->user->user->creer; $editenable = $user->rights->adherent->creer && $user->rights->user->user->creer;
print $form->editfieldkey('LinkedToDolibarrUser', 'login', '', $object, $editenable); print $form->editfieldkey('LinkedToDolibarrUser', 'login', '', $object, $editenable);

View File

@ -623,7 +623,7 @@ if ($rowid > 0) {
print '</td></tr>'; print '</td></tr>';
} }
// Login Dolibarr // Login Dolibarr - Link to user
print '<tr><td>'; print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>'; print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans("LinkedToDolibarrUser"); print $langs->trans("LinkedToDolibarrUser");
@ -641,7 +641,9 @@ if ($rowid > 0) {
$form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'userid', ''); $form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'userid', '');
} else { } else {
if ($object->user_id) { if ($object->user_id) {
$form->form_users($_SERVER['PHP_SELF'].'?rowid='.$object->id, $object->user_id, 'none'); $linkeduser = new User($db);
$linkeduser->fetch($object->user_id);
print $linkeduser->getNomUrl(-1);
} else { } else {
print '<span class="opacitymedium">'.$langs->trans("NoDolibarrAccess").'</span>'; print '<span class="opacitymedium">'.$langs->trans("NoDolibarrAccess").'</span>';
} }

View File

@ -90,7 +90,7 @@ print '<input type="hidden" name="action" value="set">';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td>'; print '<td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td>';
print '<td class="right"><input type="submit" class="button" '.$option.' value="'.$langs->trans("Modify").'"></td>'; print '<td class="right"><input type="submit" class="button button-edit" '.$option.' value="'.$langs->trans("Modify").'"></td>';
print "</tr>\n"; print "</tr>\n";
print '<tr class="oddeven"><td>'.$langs->trans("DEBUGBAR_LOGS_LINES_NUMBER").'</td>'; print '<tr class="oddeven"><td>'.$langs->trans("DEBUGBAR_LOGS_LINES_NUMBER").'</td>';

View File

@ -319,7 +319,7 @@ foreach ($rules as $rule) {
echo '<a class="editfielda paddingright paddingleft" href="'.$_SERVER['PHP_SELF'].'?action=edit&token='.newToken().'&id='.$rule->id.'">'.img_edit().'</a>&nbsp;'; echo '<a class="editfielda paddingright paddingleft" href="'.$_SERVER['PHP_SELF'].'?action=edit&token='.newToken().'&id='.$rule->id.'">'.img_edit().'</a>&nbsp;';
echo '<a class="paddingright paddingleft" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$rule->id.'">'.img_delete().'</a>'; echo '<a class="paddingright paddingleft" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&id='.$rule->id.'">'.img_delete().'</a>';
} else { } else {
echo '<input type="submit" class="button" value="'.$langs->trans('Update').'" />&nbsp;'; echo '<input type="submit" class="button button-edit" value="'.$langs->trans('Update').'" />&nbsp;';
echo '<a href="'.$_SERVER['PHP_SELF'].'" class="button button-cancel">'.$langs->trans("Cancel").'</a>'; echo '<a href="'.$_SERVER['PHP_SELF'].'" class="button button-cancel">'.$langs->trans("Cancel").'</a>';
} }
echo '</td>'; echo '</td>';

View File

@ -186,10 +186,7 @@ if ($action == 'create') {
print dol_get_fiche_end(); print dol_get_fiche_end();
print '<div align="center">'; print $form->buttonsSaveCancel("CreateBookmark");
print '<input type="submit" class="button" value="'.$langs->trans("CreateBookmark").'" name="create"> &nbsp; ';
print '<input type="submit" class="button button-cancel" value="'.$langs->trans("Cancel").'" name="cancel">';
print '</div>';
print '</form>'; print '</form>';
} }

View File

@ -749,7 +749,7 @@ if ($action == 'create') {
print dol_get_fiche_end(); print dol_get_fiche_end();
print '<div class="center"><input type="submit" class="button" value="'.$langs->trans("CreateMailing").'"></div>'; print $form->buttonsSaveCancel("CreateMailing", '');
print '</form>'; print '</form>';
} else { } else {

View File

@ -424,7 +424,7 @@ if ($object->fetch($id) >= 0) {
print '<div class="tagtd right">'; print '<div class="tagtd right">';
if ($allowaddtarget) { if ($allowaddtarget) {
print '<input type="submit" class="button" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">'; print '<input type="submit" class="button button-add" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">';
} else { } else {
print '<input type="submit" class="button disabled" disabled="disabled" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">'; print '<input type="submit" class="button disabled" disabled="disabled" name="button_'.$modulename.'" value="'.$langs->trans("Add").'">';
//print $langs->trans("MailNoChangePossible"); //print $langs->trans("MailNoChangePossible");

View File

@ -1974,6 +1974,21 @@ if ($action == 'create') {
$text .= $notify->confirmMessage('PROPAL_VALIDATE', $object->socid, $object); $text .= $notify->confirmMessage('PROPAL_VALIDATE', $object->socid, $object);
} }
// mandatoryPeriod
$nbMandated = 0;
foreach ($object->lines as $line) {
$res = $line->fetch_product();
if ($res > 0 ) {
if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end) )) {
$nbMandated++;
break;
}
}
}
if ($nbMandated > 0) {
$text .= '<div><span class="clearboth nowraponall warning">'.$langs->trans("mandatoryPeriodNeedTobeSetMsgValidate").'</span></div>';
}
if (!$error) { if (!$error) {
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate', '', 0, 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate', '', 0, 1);
} }

View File

@ -294,6 +294,7 @@ if (empty($reshook)) {
if (!empty($origin) && !empty($originid)) { if (!empty($origin) && !empty($originid)) {
// Parse element/subelement (ex: project_task) // Parse element/subelement (ex: project_task)
$element = $subelement = $origin; $element = $subelement = $origin;
$regs = array();
if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) { if (preg_match('/^([^_]+)_([^_]+)/i', $origin, $regs)) {
$element = $regs [1]; $element = $regs [1];
$subelement = $regs [2]; $subelement = $regs [2];
@ -1410,6 +1411,7 @@ if (empty($reshook)) {
/* /*
* View * View
*/ */
$title = $langs->trans('Order')." - ".$langs->trans('Card'); $title = $langs->trans('Order')." - ".$langs->trans('Card');
$help_url = 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge'; $help_url = 'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes|DE:Modul_Kundenaufträge';
llxHeader('', $title, $help_url); llxHeader('', $title, $help_url);
@ -1922,6 +1924,21 @@ if ($action == 'create' && $usercancreate) {
); );
} }
// mandatoryPeriod
$nbMandated = 0;
foreach ($object->lines as $line) {
$res = $line->fetch_product();
if ($res > 0 ) {
if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end) )) {
$nbMandated++;
break;
}
}
}
if ($nbMandated > 0 ) $text .= '<div><span class="clearboth nowraponall warning">'.$langs->trans("mandatoryPeriodNeedTobeSetMsgValidate").'</span></div>';
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateOrder'), $text, 'confirm_validate', $formquestion, 0, 1, 220);
} }
@ -2358,17 +2375,17 @@ if ($action == 'create' && $usercancreate) {
if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) { if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) {
// Multicurrency Amount HT // Multicurrency Amount HT
print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>'; print '<tr><td class="titlefieldmiddle">'.$form->editfieldkey('MulticurrencyAmountHT', 'multicurrency_total_ht', '', $object, 0).'</td>';
print '<td class="valuefield nowrap">'.price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '<td class="valuefield nowrap">'.price($object->multicurrency_total_ht, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
print '</tr>'; print '</tr>';
// Multicurrency Amount VAT // Multicurrency Amount VAT
print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).'</td>'; print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountVAT', 'multicurrency_total_tva', '', $object, 0).'</td>';
print '<td class="valuefield nowrap">'.price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '<td class="valuefield nowrap">'.price($object->multicurrency_total_tva, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
print '</tr>'; print '</tr>';
// Multicurrency Amount TTC // Multicurrency Amount TTC
print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).'</td>'; print '<tr><td>'.$form->editfieldkey('MulticurrencyAmountTTC', 'multicurrency_total_ttc', '', $object, 0).'</td>';
print '<td class="valuefield nowrap">'.price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>'; print '<td class="valuefield nowrap">'.price($object->multicurrency_total_ttc, '', $langs, 0, -1, -1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).'</td>';
print '</tr>'; print '</tr>';
} }
@ -2378,23 +2395,23 @@ if ($action == 'create' && $usercancreate) {
$alert = ' '.img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->order_min_amount)); $alert = ' '.img_warning($langs->trans('OrderMinAmount').': '.price($object->thirdparty->order_min_amount));
} }
print '<tr><td class="titlefieldmiddle">'.$langs->trans('AmountHT').'</td>'; print '<tr><td class="titlefieldmiddle">'.$langs->trans('AmountHT').'</td>';
print '<td class="valuefield">'.price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency).$alert.'</td>'; print '<td class="valuefield">'.price($object->total_ht, 1, '', 1, -1, -1, $conf->currency).$alert.'</td>';
// Total VAT // Total VAT
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td class="valuefield">'.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>'; print '<tr><td>'.$langs->trans('AmountVAT').'</td><td class="valuefield">'.price($object->total_tva, 1, '', 1, -1, -1, $conf->currency).'</td></tr>';
// Amount Local Taxes // Amount Local Taxes
if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { // Localtax1 if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { // Localtax1
print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>'; print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>';
print '<td class="valuefield">'.price($object->total_localtax1, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>'; print '<td class="valuefield">'.price($object->total_localtax1, 1, '', 1, -1, -1, $conf->currency).'</td></tr>';
} }
if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { // Localtax2 IRPF if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { // Localtax2 IRPF
print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>'; print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>';
print '<td class="valuefield">'.price($object->total_localtax2, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>'; print '<td class="valuefield">'.price($object->total_localtax2, 1, '', 1, -1, -1, $conf->currency).'</td></tr>';
} }
// Total TTC // Total TTC
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td class="valuefield">'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'</td></tr>'; print '<tr><td>'.$langs->trans('AmountTTC').'</td><td class="valuefield">'.price($object->total_ttc, 1, '', 1, -1, -1, $conf->currency).'</td></tr>';
// Statut // Statut
//print '<tr><td>' . $langs->trans('Status') . '</td><td>' . $object->getLibStatut(4) . '</td></tr>'; //print '<tr><td>' . $langs->trans('Status') . '</td><td>' . $object->getLibStatut(4) . '</td></tr>';

View File

@ -408,13 +408,21 @@ if (empty($reshook)) {
} elseif ($action == 'setinvoicedate' && $usercancreate) { } elseif ($action == 'setinvoicedate' && $usercancreate) {
$object->fetch($id); $object->fetch($id);
$old_date_lim_reglement = $object->date_lim_reglement; $old_date_lim_reglement = $object->date_lim_reglement;
$date = dol_mktime(12, 0, 0, GETPOST('invoicedatemonth', 'int'), GETPOST('invoicedateday', 'int'), GETPOST('invoicedateyear', 'int')); $newdate = dol_mktime(0, 0, 0, GETPOST('invoicedatemonth', 'int'), GETPOST('invoicedateday', 'int'), GETPOST('invoicedateyear', 'int'), 'tzserver');
if (empty($date)) { if (empty($newdate)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id.'&action=editinvoicedate'); header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$id.'&action=editinvoicedate&token='.newToken());
exit; exit;
} }
$object->date = $date; if ($newdate > (dol_now('tzuserrel') + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) {
if (empty($conf->global->INVOICE_MAX_FUTURE_DELAY)) {
setEventMessages($langs->trans("WarningInvoiceDateInFuture"), null, 'warnings');
} else {
setEventMessages($langs->trans("WarningInvoiceDateTooFarInFuture"), null, 'warnings');
}
}
$object->date = $newdate;
$new_date_lim_reglement = $object->calculate_date_lim_reglement(); $new_date_lim_reglement = $object->calculate_date_lim_reglement();
if ($new_date_lim_reglement > $old_date_lim_reglement) { if ($new_date_lim_reglement > $old_date_lim_reglement) {
$object->date_lim_reglement = $new_date_lim_reglement; $object->date_lim_reglement = $new_date_lim_reglement;
@ -428,7 +436,9 @@ if (empty($reshook)) {
} }
} elseif ($action == 'setdate_pointoftax' && $usercancreate) { } elseif ($action == 'setdate_pointoftax' && $usercancreate) {
$object->fetch($id); $object->fetch($id);
$date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']);
$date_pointoftax = dol_mktime(0, 0, 0, GETPOST('date_pointoftaxmonth', 'int'), GETPOST('date_pointoftaxday', 'int'), GETPOST('date_pointoftaxyear', 'int'), 'tzserver');
$object->date_pointoftax = $date_pointoftax; $object->date_pointoftax = $date_pointoftax;
$result = $object->update($user); $result = $object->update($user);
if ($result < 0) { if ($result < 0) {
@ -1001,14 +1011,16 @@ if (empty($reshook)) {
$error++; $error++;
} }
$dateinvoice = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server
$date_pointoftax = dol_mktime(0, 0, 0, GETPOST('date_pointoftaxmonth', 'int'), GETPOST('date_pointoftaxday', 'int'), GETPOST('date_pointoftaxyear', 'int'), 'tzserver');
// Replacement invoice // Replacement invoice
if (GETPOST('type') == Facture::TYPE_REPLACEMENT) { if (GETPOST('type') == Facture::TYPE_REPLACEMENT) {
$dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
if (empty($dateinvoice)) { if (empty($dateinvoice)) {
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
$action = 'create'; $action = 'create';
} elseif ($dateinvoice > (dol_get_last_hour(dol_now()) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { } elseif ($dateinvoice > (dol_get_last_hour(dol_now('tzuserrel')) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) {
$error++; $error++;
setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors');
$action = 'create'; $action = 'create';
@ -1020,8 +1032,6 @@ if (empty($reshook)) {
$action = 'create'; $action = 'create';
} }
$date_pointoftax = dol_mktime(12, 0, 0, GETPOST('date_pointoftaxmonth', 'int'), GETPOST('date_pointoftaxday', 'int'), GETPOST('date_pointoftaxyear', 'int'));
if (!$error) { if (!$error) {
// This is a replacement invoice // This is a replacement invoice
$result = $object->fetch(GETPOST('fac_replacement', 'int')); $result = $object->fetch(GETPOST('fac_replacement', 'int'));
@ -1064,19 +1074,16 @@ if (empty($reshook)) {
$action = 'create'; $action = 'create';
} }
$dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
if (empty($dateinvoice)) { if (empty($dateinvoice)) {
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
$action = 'create'; $action = 'create';
} elseif ($dateinvoice > (dol_get_last_hour(dol_now()) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { } elseif ($dateinvoice > (dol_get_last_hour(dol_now('tzuserrel')) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) {
$error++; $error++;
setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors');
$action = 'create'; $action = 'create';
} }
$date_pointoftax = dol_mktime(12, 0, 0, GETPOST('date_pointoftaxmonth', 'int'), GETPOST('date_pointoftaxday', 'int'), GETPOST('date_pointoftaxyear', 'int'));
if (!$error) { if (!$error) {
if (!empty($originentity)) { if (!empty($originentity)) {
$object->entity = $originentity; $object->entity = $originentity;
@ -1280,19 +1287,16 @@ if (empty($reshook)) {
// Standard invoice or Deposit invoice, created from a Predefined template invoice // Standard invoice or Deposit invoice, created from a Predefined template invoice
if ((GETPOST('type') == Facture::TYPE_STANDARD || GETPOST('type') == Facture::TYPE_DEPOSIT) && GETPOST('fac_rec', 'int') > 0) { if ((GETPOST('type') == Facture::TYPE_STANDARD || GETPOST('type') == Facture::TYPE_DEPOSIT) && GETPOST('fac_rec', 'int') > 0) {
$dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
if (empty($dateinvoice)) { if (empty($dateinvoice)) {
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
$action = 'create'; $action = 'create';
} elseif ($dateinvoice > (dol_get_last_hour(dol_now()) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { } elseif ($dateinvoice > (dol_get_last_hour(dol_now('tzuserrel')) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) {
$error++; $error++;
setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors');
$action = 'create'; $action = 'create';
} }
$date_pointoftax = dol_mktime(12, 0, 0, $_POST['date_pointoftaxmonth'], $_POST['date_pointoftaxday'], $_POST['date_pointoftaxyear']);
if (!$error) { if (!$error) {
$object->socid = GETPOST('socid', 'int'); $object->socid = GETPOST('socid', 'int');
$object->type = GETPOST('type'); $object->type = GETPOST('type');
@ -1327,8 +1331,6 @@ if (empty($reshook)) {
$typeamount = GETPOST('typedeposit', 'aZ09'); $typeamount = GETPOST('typedeposit', 'aZ09');
$valuestandardinvoice = price2num(str_replace('%', '', GETPOST('valuestandardinvoice', 'alpha')), 'MU'); $valuestandardinvoice = price2num(str_replace('%', '', GETPOST('valuestandardinvoice', 'alpha')), 'MU');
$valuedeposit = price2num(str_replace('%', '', GETPOST('valuedeposit', 'alpha')), 'MU'); $valuedeposit = price2num(str_replace('%', '', GETPOST('valuedeposit', 'alpha')), 'MU');
$dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
$date_pointoftax = dol_mktime(12, 0, 0, GETPOST('date_pointoftaxmonth', 'int'), GETPOST('date_pointoftaxday', 'int'), GETPOST('date_pointoftaxyear', 'int'));
if (GETPOST('socid', 'int') < 1) { if (GETPOST('socid', 'int') < 1) {
$error++; $error++;
@ -1340,7 +1342,7 @@ if (empty($reshook)) {
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
$action = 'create'; $action = 'create';
} elseif ($dateinvoice > (dol_get_last_hour(dol_now()) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { } elseif ($dateinvoice > (dol_get_last_hour(dol_now('tzuserrel')) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) {
$error++; $error++;
setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors');
$action = 'create'; $action = 'create';
@ -1822,19 +1824,16 @@ if (empty($reshook)) {
// Situation invoices // Situation invoices
if (GETPOST('type') == Facture::TYPE_SITUATION && GETPOST('situations')) { if (GETPOST('type') == Facture::TYPE_SITUATION && GETPOST('situations')) {
$dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
if (empty($dateinvoice)) { if (empty($dateinvoice)) {
$error++; $error++;
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")); $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date"));
setEventMessages($mesg, null, 'errors'); setEventMessages($mesg, null, 'errors');
} elseif ($dateinvoice > (dol_get_last_hour(dol_now()) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { } elseif ($dateinvoice > (dol_get_last_hour(dol_now('tzuserrel')) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) {
$error++; $error++;
setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors');
$action = 'create'; $action = 'create';
} }
$date_pointoftax = dol_mktime(12, 0, 0, GETPOST('date_pointoftaxmonth', 'int'), GETPOST('date_pointoftaxday', 'int'), GETPOST('date_pointoftaxyear', 'int'));
if (!(GETPOST('situations', 'int') > 0)) { if (!(GETPOST('situations', 'int') > 0)) {
$error++; $error++;
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("InvoiceSituation")); $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("InvoiceSituation"));
@ -3529,7 +3528,8 @@ if ($action == 'create') {
print '</td></tr>'; print '</td></tr>';
} }
$newdateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $newdateinvoice = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'), 'tzserver');
$date_pointoftax = dol_mktime(0, 0, 0, GETPOST('date_pointoftaxmonth', 'int'), GETPOST('date_pointoftaxday', 'int'), GETPOST('date_pointoftaxyear', 'int'), 'tzserver');
// Date invoice // Date invoice
print '<tr><td class="fieldrequired">'.$langs->trans('DateInvoice').'</td><td colspan="2">'; print '<tr><td class="fieldrequired">'.$langs->trans('DateInvoice').'</td><td colspan="2">';
@ -3539,7 +3539,6 @@ if ($action == 'create') {
// Date point of tax // Date point of tax
if (!empty($conf->global->INVOICE_POINTOFTAX_DATE)) { if (!empty($conf->global->INVOICE_POINTOFTAX_DATE)) {
print '<tr><td class="fieldrequired">'.$langs->trans('DatePointOfTax').'</td><td colspan="2">'; print '<tr><td class="fieldrequired">'.$langs->trans('DatePointOfTax').'</td><td colspan="2">';
$date_pointoftax = dol_mktime(12, 0, 0, GETPOST('date_pointoftaxmonth', 'int'), GETPOST('date_pointoftaxday', 'int'), GETPOST('date_pointoftaxyear', 'int'));
print $form->selectDate($date_pointoftax ? $date_pointoftax : -1, 'date_pointoftax', '', '', '', "add", 1, 1); print $form->selectDate($date_pointoftax ? $date_pointoftax : -1, 'date_pointoftax', '', '', '', "add", 1, 1);
print '</td></tr>'; print '</td></tr>';
} }
@ -4014,6 +4013,21 @@ if ($action == 'create') {
if ($object->type != Facture::TYPE_CREDIT_NOTE && $object->total_ttc < 0) { // Can happen only if $conf->global->FACTURE_ENABLE_NEGATIVE is on if ($object->type != Facture::TYPE_CREDIT_NOTE && $object->total_ttc < 0) { // Can happen only if $conf->global->FACTURE_ENABLE_NEGATIVE is on
$text .= '<br>'.img_warning().' '.$langs->trans("ErrorInvoiceOfThisTypeMustBePositive"); $text .= '<br>'.img_warning().' '.$langs->trans("ErrorInvoiceOfThisTypeMustBePositive");
} }
// mandatoryPeriod
$nbMandated = 0;
foreach ($object->lines as $line) {
$res = $line->fetch_product();
if ($res > 0 ) {
if ($line->product->isService() && $line->product->isMandatoryPeriod() && (empty($line->date_start) || empty($line->date_end) )) {
$nbMandated++;
break;
}
}
}
if ($nbMandated > 0 ) $text .= '<div><span class="clearboth nowraponall warning">'.$langs->trans("mandatoryPeriodNeedTobeSetMsgValidate").'</span></div>';
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ValidateBill'), $text, 'confirm_valid', $formquestion, (($object->type != Facture::TYPE_CREDIT_NOTE && $object->total_ttc < 0) ? "no" : "yes"), 2); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?facid='.$object->id, $langs->trans('ValidateBill'), $text, 'confirm_valid', $formquestion, (($object->type != Facture::TYPE_CREDIT_NOTE && $object->total_ttc < 0) ? "no" : "yes"), 2);
} }

View File

@ -2267,7 +2267,6 @@ class Facture extends CommonInvoice
$sql .= ' SET fk_facture = NULL, fk_facture_line = NULL'; $sql .= ' SET fk_facture = NULL, fk_facture_line = NULL';
$sql .= ' WHERE fk_facture_line IN ('.$this->db->sanitize(join(',', $list_rowid_det)).')'; $sql .= ' WHERE fk_facture_line IN ('.$this->db->sanitize(join(',', $list_rowid_det)).')';
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
if (!$this->db->query($sql)) { if (!$this->db->query($sql)) {
$this->error = $this->db->error()." sql=".$sql; $this->error = $this->db->error()." sql=".$sql;
$this->errors[] = $this->error; $this->errors[] = $this->error;
@ -2276,6 +2275,30 @@ class Facture extends CommonInvoice
} }
} }
// Remove other links to the deleted invoice
$sql = 'UPDATE '.MAIN_DB_PREFIX.'eventorganization_conferenceorboothattendee';
$sql .= ' SET fk_invoice = NULL';
$sql .= ' WHERE fk_invoice = '.((int) $rowid);
if (!$this->db->query($sql)) {
$this->error = $this->db->error()." sql=".$sql;
$this->errors[] = $this->error;
$this->db->rollback();
return -5;
}
$sql = 'UPDATE '.MAIN_DB_PREFIX.'projet_task_time';
$sql .= ' SET invoice_id = NULL, invoice_line_id = NULL';
$sql .= ' WHERE invoice_id = '.((int) $rowid);
if (!$this->db->query($sql)) {
$this->error = $this->db->error()." sql=".$sql;
$this->errors[] = $this->error;
$this->db->rollback();
return -5;
}
// If we decrease stock on invoice validation, we increase back if a warehouse id was provided // If we decrease stock on invoice validation, we increase back if a warehouse id was provided
if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse != -1) { if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && !empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse != -1) {
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
@ -2299,17 +2322,13 @@ class Facture extends CommonInvoice
// Invoice line extrafileds // Invoice line extrafileds
$main = MAIN_DB_PREFIX.'facturedet'; $main = MAIN_DB_PREFIX.'facturedet';
$ef = $main."_extrafields"; $ef = $main."_extrafields";
$sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM ".$main." WHERE fk_facture = ".((int) $rowid).")"; $sqlef = "DELETE FROM ".$ef." WHERE fk_object IN (SELECT rowid FROM ".$main." WHERE fk_facture = ".((int) $rowid).")";
// Delete invoice line // Delete invoice line
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.((int) $rowid); $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facturedet WHERE fk_facture = '.((int) $rowid);
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
if ($this->db->query($sqlef) && $this->db->query($sql) && $this->delete_linked_contact()) { if ($this->db->query($sqlef) && $this->db->query($sql) && $this->delete_linked_contact()) {
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture WHERE rowid = '.((int) $rowid); $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'facture WHERE rowid = '.((int) $rowid);
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
// Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive

View File

@ -42,7 +42,7 @@ $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
// Load translation files required by the page // Load translation files required by the page
$langs->loadLangs(array('bills', 'companies', 'other')); $langs->loadLangs(array('bills', 'companies', 'other'));
$mode = GETPOST("mode") ?GETPOST("mode") : 'customer'; $mode = GETPOST("mode") ? GETPOST("mode") : 'customer';
if ($mode == 'customer' && !$user->rights->facture->lire) { if ($mode == 'customer' && !$user->rights->facture->lire) {
accessforbidden(); accessforbidden();
} }
@ -244,7 +244,7 @@ if (!count($arrayyears)) {
$h = 0; $h = 0;
$head = array(); $head = array();
$head[$h][0] = DOL_URL_ROOT.'/compta/facture/stats/index.php?mode='.$mode; $head[$h][0] = DOL_URL_ROOT.'/compta/facture/stats/index.php?mode='.urlencode($mode);
$head[$h][1] = $langs->trans("ByMonthYear"); $head[$h][1] = $langs->trans("ByMonthYear");
$head[$h][2] = 'byyear'; $head[$h][2] = 'byyear';
$h++; $h++;
@ -261,12 +261,12 @@ complete_head_from_modules($conf, $langs, null, $head, $h, $type);
print dol_get_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1); print dol_get_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1);
// We use select_thirdparty_list instead of select_company so we can use $filter and share same code for customer and supplier. // We use select_thirdparty_list instead of select_company so we can use $filter and share same code for customer and supplier.
$tmp_companies = $form->select_thirdparty_list($socid, 'socid', $filter, 1, 0, 0, array(), '', 1); $filter = '';
//Array passed as an argument to Form::selectarray to build a proper select input if ($mode == 'customer') {
$companies = array(); $filter = 's.client in (1,2,3)';
}
foreach ($tmp_companies as $value) { if ($mode == 'supplier') {
$companies[$value['key']] = $value['label']; $filter = 's.fournisseur = 1';
} }
print '<div class="fichecenter"><div class="fichethirdleft">'; print '<div class="fichecenter"><div class="fichethirdleft">';
@ -281,14 +281,8 @@ print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>'; print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
// Company // Company
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>'; print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
if ($mode == 'customer') {
$filter = 's.client in (1,2,3)';
}
if ($mode == 'supplier') {
$filter = 's.fournisseur = 1';
}
print img_picto('', 'company', 'class="pictofixedwidth"'); print img_picto('', 'company', 'class="pictofixedwidth"');
print $form->selectarray('socid', $companies, $socid, 1, 0, 0, '', 0, 0, 0, '', 'widthcentpercentminusx maxwidth300', 1); print $form->select_company($socid, 'socid', $filter, 1, 0, 0, array(), 0, 'widthcentpercentminusx maxwidth300');
print '</td></tr>'; print '</td></tr>';
// ThirdParty Type // ThirdParty Type

View File

@ -222,7 +222,7 @@ if ($id) {
print '</table><br>'; print '</table><br>';
//Confirm Button //Confirm Button
print '<div class="center"><input type="submit" class="button" value='.$langs->trans("Confirm").'></div>'; print '<div class="center"><input type="submit" class="button button-save" value='.$langs->trans("Confirm").'></div>';
print '</form>'; print '</form>';
} }

View File

@ -1288,7 +1288,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
if ($objsoc->id > 0) { if ($objsoc->id > 0) {
$morehtmlref .= $objsoc->getNomUrl(1, 'contact'); $morehtmlref .= $objsoc->getNomUrl(1, 'contact');
} else { } else {
$morehtmlref .= $langs->trans("ContactNotLinkedToCompany"); $morehtmlref .= '<span class="opacitymedium">'.$langs->trans("ContactNotLinkedToCompany").'</span>';
} }
} }
$morehtmlref .= '</div>'; $morehtmlref .= '</div>';

View File

@ -54,7 +54,6 @@ $action = GETPOST('action', 'aZ09');
$idticketgroup = GETPOST('idticketgroup', 'aZ09'); $idticketgroup = GETPOST('idticketgroup', 'aZ09');
$idticketgroup = GETPOST('idticketgroup', 'aZ09'); $idticketgroup = GETPOST('idticketgroup', 'aZ09');
$lang = GETPOST('lang', 'aZ09'); $lang = GETPOST('lang', 'aZ09');
$popupurl = GETPOST('popupurl', 'bool');
/* /*
* Actions * Actions
@ -69,13 +68,12 @@ $popupurl = GETPOST('popupurl', 'bool');
if ($action == "getKnowledgeRecord") { if ($action == "getKnowledgeRecord") {
$response = ''; $response = '';
$sql = "SELECT kr.rowid, kr.ref, kr.question, kr.answer,l.url,ctc.code"; $sql = "SELECT kr.rowid, kr.ref, kr.question, kr.answer,kr.url,ctc.code";
$sql .= " FROM ".MAIN_DB_PREFIX."links as l"; $sql .= " FROM ".MAIN_DB_PREFIX."knowledgemanagement_knowledgerecord as kr ";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."knowledgemanagement_knowledgerecord as kr ON kr.rowid = l.objectid"; $sql .= " JOIN ".MAIN_DB_PREFIX."c_ticket_category as ctc ON ctc.rowid = kr.fk_c_ticket_category";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."c_ticket_category as ctc ON ctc.rowid = kr.fk_c_ticket_category";
$sql .= " WHERE ctc.code = '".$db->escape($idticketgroup)."'"; $sql .= " WHERE ctc.code = '".$db->escape($idticketgroup)."'";
$sql .= " AND ctc.active = 1 AND ctc.public = 1 AND (kr.lang = '".$db->escape($lang)."' OR kr.lang = 0)"; $sql .= " AND ctc.active = 1 AND ctc.public = 1 AND (kr.lang = '".$db->escape($lang)."' OR kr.lang = 0 OR kr.lang IS NULL)";
$sql .= " AND kr.status = 1"; $sql .= " AND kr.status = 1 AND (kr.answer IS NOT NULL AND kr.answer <> '')";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
@ -83,33 +81,7 @@ if ($action == "getKnowledgeRecord") {
$response = array(); $response = array();
while ($i < $num) { while ($i < $num) {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($popupurl == "false") { $response[] = array('title'=>$obj->question,'ref'=>$obj->ref,'answer'=>dol_escape_htmltag(preg_replace('/\\r|\\r\\n|\\n/', "", $obj->answer)),'url'=>$obj->url);
$url = "<a href=\"".$obj->url. "\" target=\"_blank\">".$obj->url."</a></li>";
$response[] = array('title'=>$obj->question,'ref'=>$obj->url,'answer'=>$obj->answer,'url'=>$url);
} else {
$name = $obj->ref;
$buttonstring = $obj->url;
$url = $obj->url;
$urltoprint = '<a class="button_'.$name.'" style="cursor:pointer">'.$buttonstring.'</a>';
$urltoprint .= '<!-- Add js code to open dialog popup on dialog -->';
$urltoprint .= '<script language="javascript">
jQuery(document).ready(function () {
jQuery(".button_'.$name.'").click(function () {
console.log("Open popup with jQuery(...).dialog() on URL '.dol_escape_js($url).'")
var $dialog = $(\'<div></div>\').html(\'<iframe class="iframedialog" style="border: 0px;" src="'.$url.'" width="100%" height="98%"></iframe>\')
.dialog({
autoOpen: false,
modal: true,
height: (window.innerHeight - 150),
width: \'80%\',
title: "'.dol_escape_js($label).'"
});
$dialog.dialog(\'open\');
});
});
</script>';
$response[] = array('title'=>$obj->question,'ref'=>$obj->url,'answer'=>$obj->answer,'url'=>$urltoprint);
}
$i++; $i++;
} }
} else { } else {

View File

@ -99,6 +99,8 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3)
$perm = 1; $perm = 1;
} elseif ($table_element_line == 'ecm_files' && $fk_element == 'fk_ticket' && !empty($user->rights->ticket->write)) { } elseif ($table_element_line == 'ecm_files' && $fk_element == 'fk_ticket' && !empty($user->rights->ticket->write)) {
$perm = 1; $perm = 1;
} elseif ($table_element_line == 'projet_task' && $fk_element == 'fk_projet' && $user->rights->projet->creer) {
$perm = 1;
} else { } else {
$tmparray = explode('_', $table_element_line); $tmparray = explode('_', $table_element_line);
$tmpmodule = $tmparray[0]; $tmpobject = preg_replace('/line$/', '', $tmparray[1]); $tmpmodule = $tmparray[0]; $tmpobject = preg_replace('/line$/', '', $tmparray[1]);
@ -111,7 +113,7 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3)
// We should not be here. If we are not allowed to reorder rows, feature should not be visible on script. // We should not be here. If we are not allowed to reorder rows, feature should not be visible on script.
// If we are here, it is a hack attempt, so we report a warning. // If we are here, it is a hack attempt, so we report a warning.
print 'Bad permission to modify position of lines for object in table '.$table_element_line; print 'Bad permission to modify position of lines for object in table '.$table_element_line;
dol_syslog('Bad permission to modify position of lines for object in table '.$table_element_line.', fk_element '.$fk_element, LOG_WARNING); dol_syslog('Bad permission to modify position of lines for object in table='.$table_element_line.', fk_element='.$fk_element, LOG_WARNING);
accessforbidden('Bad permission to modify position of lines for object in table '.$table_element_line); accessforbidden('Bad permission to modify position of lines for object in table '.$table_element_line);
} }

View File

@ -145,9 +145,9 @@ class box_graph_invoices_permonth extends ModeleBoxes
$filenamenb = $dir."/".$prefix."invoicesnbinyear-".$endyear.".png"; $filenamenb = $dir."/".$prefix."invoicesnbinyear-".$endyear.".png";
// default value for customer mode // default value for customer mode
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesnbinyear-'.$endyear.'.png'; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$endyear.'.png';
if ($mode == 'supplier') { if ($mode == 'supplier') {
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&amp;file=invoicessuppliernbinyear-'.$endyear.'.png'; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessuppliernbinyear-'.$endyear.'.png';
} }
$px1 = new DolGraph(); $px1 = new DolGraph();

View File

@ -129,8 +129,10 @@ class box_graph_invoices_peryear extends ModeleBoxes
$filenamenb = $dir."/".$prefix."invoicesamountyears-".$endyear.".png"; $filenamenb = $dir."/".$prefix."invoicesamountyears-".$endyear.".png";
// default value for customer mode // default value for customer mode
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&amp;file=invoicesamountyears-'.$endyear.'.png'; $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountyears-'.$endyear.'.png';
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&amp;file=invoicessupplieramountyears-'.$endyear.'.png'; if ($mode == 'supplier') {
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessupplieramountyears-'.$endyear.'.png';
}
$px2 = new DolGraph(); $px2 = new DolGraph();
$mesg = $px2->isGraphKo(); $mesg = $px2->isGraphKo();

View File

@ -3539,7 +3539,7 @@ abstract class CommonObject
$this->db->free($resql); $this->db->free($resql);
// Now update global field total_ht, total_ttc and tva // Now update global field total_ht, total_ttc, total_tva, total_localtax1, total_localtax2, multicurrency_total_*
$fieldht = 'total_ht'; $fieldht = 'total_ht';
$fieldtva = 'tva'; $fieldtva = 'tva';
$fieldlocaltax1 = 'localtax1'; $fieldlocaltax1 = 'localtax1';
@ -3582,6 +3582,7 @@ abstract class CommonObject
dol_syslog(get_class($this)."::update_price", LOG_DEBUG); dol_syslog(get_class($this)."::update_price", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) { if (!$resql) {
$error++; $error++;
$this->error = $this->db->lasterror(); $this->error = $this->db->lasterror();

View File

@ -26,6 +26,8 @@
/** /**
* Parent class for class inheritance lines of business objects * Parent class for class inheritance lines of business objects
* This class is useless for the moment so no inherit are done on it * This class is useless for the moment so no inherit are done on it
*
* TODO For the moment we use the extends on CommonObject until PHP min is 5.4 so we can use Traits.
*/ */
abstract class CommonObjectLine extends CommonObject abstract class CommonObjectLine extends CommonObject
{ {
@ -61,7 +63,7 @@ abstract class CommonObjectLine extends CommonObject
} }
/** /**
* Returns the label, shot_label or code found in units dictionary from ->fk_unit. * Returns the label, short_label or code found in units dictionary from ->fk_unit.
* A langs->trans() must be called on result to get translated value. * A langs->trans() must be called on result to get translated value.
* *
* @param string $type Label type ('long', 'short' or 'code'). This can be a translation key. * @param string $type Label type ('long', 'short' or 'code'). This can be a translation key.
@ -104,7 +106,4 @@ abstract class CommonObjectLine extends CommonObject
return -1; return -1;
} }
} }
// Currently we need function at end of file CommonObject for all object lines. Should find a way to avoid duplicate code.
// For the moment we use the extends on CommonObject until PHP min is 5.4 so use Traits.
} }

View File

@ -7874,6 +7874,11 @@ class Form
if (empty($conf->expedition->enabled)) { if (empty($conf->expedition->enabled)) {
continue; // Do not show if module disabled continue; // Do not show if module disabled
} }
} elseif ($objecttype == 'mo') {
$tplpath = 'mrp/mo';
if (empty($conf->mrp->enabled)) {
continue; // Do not show if module disabled
}
} elseif ($objecttype == 'ficheinter') { } elseif ($objecttype == 'ficheinter') {
$tplpath = 'fichinter'; $tplpath = 'fichinter';
if (empty($conf->ficheinter->enabled)) { if (empty($conf->ficheinter->enabled)) {

View File

@ -221,13 +221,14 @@ class FormActions
if ($typeelement == 'project') { if ($typeelement == 'project') {
$projectid = $object->id; $projectid = $object->id;
} }
$taskid = 0;
if ($typeelement == 'task') { if ($typeelement == 'task') {
$taskid = $object->id; $taskid = $object->id;
} }
$newcardbutton = ''; $newcardbutton = '';
if (!empty($conf->agenda->enabled) && !empty($user->rights->agenda->myactions->create)) { if (!empty($conf->agenda->enabled) && !empty($user->rights->agenda->myactions->create)) {
$url = DOL_URL_ROOT.'/comm/action/card.php?action=create&amp;datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog', 'tzuser')).'&amp;origin='.urlencode($typeelement).'&amp;originid='.$object->id.((!empty($object->socid) && $object->socid > 0) ? '&amp;socid='.$object->socid : ((!empty($socid) && $socid > 0) ? '&amp;socid='.$socid : '')).($projectid > 0 ? '&amp;projectid='.$projectid : '').($taskid > 0 ? '&amp;taskid='.$taskid : '').'&amp;backtopage='.urlencode($urlbacktopage); $url = DOL_URL_ROOT.'/comm/action/card.php?action=create&token='.newToken().'&datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog', 'tzuser')).'&origin='.urlencode($typeelement).'&originid='.((int) $object->id).((!empty($object->socid) && $object->socid > 0) ? '&socid='.((int) $object->socid) : ((!empty($socid) && $socid > 0) ? '&socid='.((int) $socid) : '')).($projectid > 0 ? '&projectid='.((int) $projectid) : '').($taskid > 0 ? '&taskid='.((int) $taskid) : '').'&backtopage='.urlencode($urlbacktopage);
$newcardbutton .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', $url); $newcardbutton .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', $url);
} }

View File

@ -761,20 +761,21 @@ class FormCompany extends Form
/** /**
* Return a select list with types of contacts * Return a select list with types of contacts
* *
* @param object $object Object to use to find type of contact * @param object $object Object to use to find type of contact
* @param string $selected Default selected value * @param string $selected Default selected value
* @param string $htmlname HTML select name * @param string $htmlname HTML select name
* @param string $source Source ('internal' or 'external') * @param string $source Source ('internal' or 'external')
* @param string $sortorder Sort criteria ('position', 'code', ...) * @param string $sortorder Sort criteria ('position', 'code', ...)
* @param int $showempty 1=Add en empty line * @param int $showempty 1=Add en empty line
* @param string $morecss Add more css to select component * @param string $morecss Add more css to select component
* @param int $output 0=return HTML, 1= direct print * @param int $output 0=return HTML, 1= direct print
* @param int $forcehidetooltip Force hide tooltip for admin * @param int $forcehidetooltip Force hide tooltip for admin
* @return void * @return string|void Depending on $output param, return the HTML select list (recommended method) or nothing
*/ */
public function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '', $output = 1, $forcehidetooltip = 0) public function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '', $output = 1, $forcehidetooltip = 0)
{ {
global $user, $langs; global $user, $langs;
$out = ''; $out = '';
if (is_object($object) && method_exists($object, 'liste_type_contact')) { if (is_object($object) && method_exists($object, 'liste_type_contact')) {
$lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1); $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1);

View File

@ -2033,8 +2033,8 @@ class FormFile
print '<td class="center">'.dol_print_date(dol_now(), "dayhour", "tzuser").'</td>'; print '<td class="center">'.dol_print_date(dol_now(), "dayhour", "tzuser").'</td>';
print '<td class="right"></td>'; print '<td class="right"></td>';
print '<td class="right">'; print '<td class="right">';
print '<input type="submit" name="save" class="button button-save" value="'.dol_escape_htmltag($langs->trans("Save")).'">'; print '<input type="submit" class="button button-save" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
print '<input type="submit" name="cancel" class="button button-cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">'; print '<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
print '</td>'; print '</td>';
} else { } else {
print '<td>'; print '<td>';

View File

@ -956,15 +956,14 @@ class FormMail extends Form
$out .= '</table>'."\n"; $out .= '</table>'."\n";
if ($this->withform == 1 || $this->withform == -1) { if ($this->withform == 1 || $this->withform == -1) {
$out .= '<br><div class="center">'; $out .= '<div class="center">';
$out .= '<input type="submit" class="button" id="sendmail" name="sendmail" value="'.$langs->trans("SendMail").'"'; $out .= '<input type="submit" class="button button-add" id="sendmail" name="sendmail" value="'.$langs->trans("SendMail").'"';
// Add a javascript test to avoid to forget to submit file before sending email // Add a javascript test to avoid to forget to submit file before sending email
if ($this->withfile == 2 && $conf->use_javascript_ajax) { if ($this->withfile == 2 && $conf->use_javascript_ajax) {
$out .= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; $out .= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"';
} }
$out .= ' />'; $out .= ' />';
if ($this->withcancel) { if ($this->withcancel) {
$out .= ' &nbsp; &nbsp; ';
$out .= '<input class="button button-cancel" type="submit" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'" />'; $out .= '<input class="button button-cancel" type="submit" id="cancel" name="cancel" value="'.$langs->trans("Cancel").'" />';
} }
$out .= '</div>'."\n"; $out .= '</div>'."\n";

View File

@ -39,6 +39,8 @@ class FormProjets
*/ */
public $error = ''; public $error = '';
public $nboftasks;
/** /**
* Constructor * Constructor
@ -307,11 +309,11 @@ class FormProjets
* @param int $disabled Disabled * @param int $disabled Disabled
* @param string $morecss More css added to the select component * @param string $morecss More css added to the select component
* @param string $projectsListId ''=Automatic filter on project allowed. List of id=Filter on project ids. * @param string $projectsListId ''=Automatic filter on project allowed. List of id=Filter on project ids.
* @param string $showproject 'all' = Show project info, ''=Hide project info * @param string $showmore 'all' = Show project info, 'progress' = Show task progression, ''=Show nothing more
* @param User $usertofilter User object to use for filtering * @param User $usertofilter User object to use for filtering
* @return int Nbr of tasks if OK, <0 if KO * @return int Nbr of tasks if OK, <0 if KO
*/ */
public function selectTasks($socid = -1, $selected = '', $htmlname = 'taskid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showproject = 'all', $usertofilter = null) public function selectTasks($socid = -1, $selected = '', $htmlname = 'taskid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showmore = 'all', $usertofilter = null)
{ {
global $user, $conf, $langs; global $user, $conf, $langs;
@ -336,7 +338,8 @@ class FormProjets
} }
// Search all projects // Search all projects
$sql = 'SELECT t.rowid, t.ref as tref, t.label as tlabel, p.rowid as pid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public,'; $sql = 'SELECT t.rowid, t.ref as tref, t.label as tlabel, t.progress,';
$sql .= ' p.rowid as pid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public, p.usage_task,';
$sql .= ' s.nom as name'; $sql .= ' s.nom as name';
$sql .= ' FROM '.MAIN_DB_PREFIX.'projet as p'; $sql .= ' FROM '.MAIN_DB_PREFIX.'projet as p';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc,'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc,';
@ -407,7 +410,7 @@ class FormProjets
$disabled = 1; $disabled = 1;
} }
if ($showproject == 'all') { if (preg_match('/all/', $showmore)) {
$labeltoshow .= dol_trunc($obj->ref, 18); // Project ref $labeltoshow .= dol_trunc($obj->ref, 18); // Project ref
//if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')'; //if ($obj->public) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
//else $labeltoshow.=' ('.$langs->trans("Private").')'; //else $labeltoshow.=' ('.$langs->trans("Private").')';
@ -442,6 +445,10 @@ class FormProjets
// Label for task // Label for task
$labeltoshow .= $obj->tref.' '.dol_trunc($obj->tlabel, $maxlength); $labeltoshow .= $obj->tref.' '.dol_trunc($obj->tlabel, $maxlength);
$titletoshow .= $obj->tref.' '.dol_trunc($obj->tlabel, $maxlength); $titletoshow .= $obj->tref.' '.dol_trunc($obj->tlabel, $maxlength);
if ($obj->usage_task && preg_match('/progress/', $showmore)) {
$labeltoshow .= ' <span class="opacitymedium">('.$obj->progress.'%)</span>';
$titletoshow .= ' <span class="opacitymedium">('.$obj->progress.'%)</span>';
}
if (!empty($selected) && $selected == $obj->rowid) { if (!empty($selected) && $selected == $obj->rowid) {
$out .= '<option value="'.$obj->rowid.'" selected'; $out .= '<option value="'.$obj->rowid.'" selected';
@ -473,6 +480,8 @@ class FormProjets
$out .= '</select>'; $out .= '</select>';
} }
$this->nboftasks = $num;
print $out; print $out;
$this->db->free($resql); $this->db->free($resql);

View File

@ -21,7 +21,7 @@
/** /**
* \file htdocs/core/class/html.formticket.class.php * \file htdocs/core/class/html.formticket.class.php
* \ingroup ticket * \ingroup ticket
* \brief Fichier de la classe permettant la generation du formulaire html d'envoi de mail unitaire * \brief File of class to generate the form for creating a new ticket.
*/ */
require_once DOL_DOCUMENT_ROOT."/core/class/html.form.class.php"; require_once DOL_DOCUMENT_ROOT."/core/class/html.form.class.php";
require_once DOL_DOCUMENT_ROOT."/core/class/html.formmail.class.php"; require_once DOL_DOCUMENT_ROOT."/core/class/html.formmail.class.php";
@ -32,12 +32,12 @@ if (!class_exists('FormCompany')) {
} }
/** /**
* Classe permettant la generation du formulaire d'un nouveau ticket. * Class to generate the form for creating a new ticket.
* Usage: $formticket = new FormTicket($db)
* $formticket->proprietes=1 ou chaine ou tableau de valeurs
* $formticket->show_form() affiche le formulaire
* *
* @package Ticket * @package Ticket
* \remarks Utilisation: $formticket = new FormTicket($db)
* \remarks $formticket->proprietes=1 ou chaine ou tableau de valeurs
* \remarks $formticket->show_form() affiche le formulaire
*/ */
class FormTicket class FormTicket
{ {
@ -258,43 +258,41 @@ class FormTicket
if (idgroupticket != "") { if (idgroupticket != "") {
$.ajax({ url: \''.DOL_URL_ROOT.'/core/ajax/fetchKnowledgeRecord.php\', $.ajax({ url: \''.DOL_URL_ROOT.'/core/ajax/fetchKnowledgeRecord.php\',
data: { action: \'getKnowledgeRecord\', idticketgroup: idgroupticket, token: \''.newToken().'\', lang:\''.$langs->defaultlang.'\', popupurl:false}, data: { action: \'getKnowledgeRecord\', idticketgroup: idgroupticket, token: \''.newToken().'\', lang:\''.$langs->defaultlang.'\'},
type: \'GET\', type: \'GET\',
success: function(response) { success: function(response) {
var urllist = \'\'; var urllist = \'\';
console.log("We received response "+response); console.log("We received response "+response);
response = JSON.parse(response) response = JSON.parse(response)
for (key in response) { for (key in response) {
console.log(response[key]) answer = response[key].answer;
urllist += "<li>" + response[key].title + ": " +response[key].url+"</li>"; urllist += \'<li><a href="#" title="\'+response[key].title+\'" class="button_KMpopup" data-html="\'+answer+\'">\' +response[key].title+\'</a></li>\';
} }
if (urllist != "") { if (urllist != "") {
console.log(urllist) $("#KWwithajax").html(\'<td>'.$langs->trans("KMFoundForTicketGroup").'</td><td><ul>\'+urllist+\'</ul></td>\');
$("#KWwithajax").html(\'<td>'.$langs->trans("KMFoundForTicketGroup").'</td><td><ul style="list-style:none;padding-left: 0;">\'+urllist+\'</ul></td>\');
$("#KWwithajax").show(); $("#KWwithajax").show();
$(".button_KMpopup").on("click",function(){
console.log("Open popup with jQuery(...).dialog() with KM article")
var $dialog = $("<div></div>").html($(this).attr("data-html"))
.dialog({
autoOpen: false,
modal: true,
height: (window.innerHeight - 150),
width: "80%",
title: $(this).attr("title"),
});
$dialog.dialog("open");
console.log($dialog);
})
} }
}, },
error : function(output) { error : function(output) {
console.log("error"); console.error("Error on Fetch of KM articles");
}, },
}); });
} }
}; };
$("#selectcategory_code").bind("change",function() { groupticketchange(); }); $("#selectcategory_code").on("change",function() { groupticketchange(); });
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
var trackChange = function(element) {
var observer = new MutationObserver(function(mutations, observer) {
if (mutations[0].attributeName == "value") {
$(element).trigger("change");
}
});
observer.observe(element, {
attributes: true
});
}
trackChange($("#selectcategory_code")[0]);
if ($("#selectcategory_code").val() != "") { if ($("#selectcategory_code").val() != "") {
groupticketchange(); groupticketchange();
} }
@ -666,7 +664,7 @@ class FormTicket
dol_syslog(get_class($this)."::selectCategoryTickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG); dol_syslog(get_class($this)."::selectCategoryTickets ".$selected.", ".$htmlname.", ".$filtertype.", ".$format, LOG_DEBUG);
if (empty($outputlangs)) { if (is_null($outputlangs) || !is_object($outputlangs)) {
$outputlangs = $langs; $outputlangs = $langs;
} }
$outputlangs->load("ticket"); $outputlangs->load("ticket");

View File

@ -2508,7 +2508,7 @@ function dol_getdate($timestamp, $fast = false, $forcetimezone = '')
* False or 0 or 'tzserver' = local to server TZ * False or 0 or 'tzserver' = local to server TZ
* 'auto' * 'auto'
* 'tzuser' = local to user TZ taking dst into account at the current date. Not yet implemented. * 'tzuser' = local to user TZ taking dst into account at the current date. Not yet implemented.
* 'tzuserrel' = local to user TZ taking dst into account at the given date. Use this one to convert date input from user. * 'tzuserrel' = local to user TZ taking dst into account at the given date. Use this one to convert date input from user into a GMT date.
* 'tz,TimeZone' = use specified timezone * 'tz,TimeZone' = use specified timezone
* @param int $check 0=No check on parameters (Can use day 32, etc...) * @param int $check 0=No check on parameters (Can use day 32, etc...)
* @return int|string Date as a timestamp, '' or false if error * @return int|string Date as a timestamp, '' or false if error

View File

@ -126,7 +126,7 @@ function project_prepare_head(Project $project, $moreparam = '')
if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) if (((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))
|| !empty($conf->propal->enabled) || !empty($conf->commande->enabled) || !empty($conf->propal->enabled) || !empty($conf->commande->enabled)
|| !empty($conf->facture->enabled) || !empty($conf->contrat->enabled) || !empty($conf->facture->enabled) || !empty($conf->contrat->enabled)
|| !empty($conf->ficheinter->enabled) || !empty($conf->agenda->enabled) || !empty($conf->deplacement->enabled)) { || !empty($conf->ficheinter->enabled) || !empty($conf->agenda->enabled) || !empty($conf->deplacement->enabled) || !empty($conf->stock->enabled)) {
$nbElements = 0; $nbElements = 0;
// Enable caching of thirdrparty count Contacts // Enable caching of thirdrparty count Contacts
$cachekey = 'count_elements_project_'.$project->id; $cachekey = 'count_elements_project_'.$project->id;
@ -134,6 +134,9 @@ function project_prepare_head(Project $project, $moreparam = '')
if (!is_null($dataretrieved)) { if (!is_null($dataretrieved)) {
$nbElements = $dataretrieved; $nbElements = $dataretrieved;
} else { } else {
if (!empty($conf->stock->enabled)) {
$nbElements += $project->getElementCount('stock', 'entrepot', 'fk_project');
}
if (!empty($conf->propal->enabled)) { if (!empty($conf->propal->enabled)) {
$nbElements += $project->getElementCount('propal', 'propal'); $nbElements += $project->getElementCount('propal', 'propal');
} }
@ -974,6 +977,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
} }
} }
// Computed progress
if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_calculated']['checked'])) { if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_calculated']['checked'])) {
print '<td class="nowrap liste_total right">'; print '<td class="nowrap liste_total right">';
if ($total_projectlinesa_planned) { if ($total_projectlinesa_planned) {
@ -981,6 +985,8 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
} }
print '</td>'; print '</td>';
} }
// Declared progress
if (count($arrayfields) > 0 && !empty($arrayfields['t.progress']['checked'])) { if (count($arrayfields) > 0 && !empty($arrayfields['t.progress']['checked'])) {
print '<td class="nowrap liste_total right">'; print '<td class="nowrap liste_total right">';
if ($total_projectlinesa_planned) { if ($total_projectlinesa_planned) {

View File

@ -513,8 +513,8 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
if (!$user->rights->salaries->delete) { if (!$user->rights->salaries->delete) {
$deleteok = 0; $deleteok = 0;
} }
} elseif ($feature == 'salaries') { } elseif ($feature == 'adherent') {
if (!$user->rights->salaries->delete) { if (!$user->rights->adherent->supprimer) {
$deleteok = 0; $deleteok = 0;
} }
} elseif (!empty($feature2)) { // This is for permissions on 2 levels } elseif (!empty($feature2)) { // This is for permissions on 2 levels

View File

@ -175,10 +175,11 @@ class pdf_standard extends ModeleExpenseReport
//$this->posxdate=88; //$this->posxdate=88;
//$this->posxtype=107; //$this->posxtype=107;
//$this->posxprojet=120; //$this->posxprojet=120;
$this->posxtva = 130; $this->posxtva = 112;
$this->posxup = 145; $this->posxup = 127;
$this->posxqty = 168; $this->posxqty = 150;
$this->postotalttc = 178; $this->postotalht = 160;
$this->postotalttc = 180;
// if (empty($conf->projet->enabled)) { // if (empty($conf->projet->enabled)) {
// $this->posxtva-=20; // $this->posxtva-=20;
// $this->posxup-=20; // $this->posxup-=20;
@ -642,11 +643,15 @@ class pdf_standard extends ModeleExpenseReport
// Quantity // Quantity
$pdf->SetXY($this->posxqty, $curY); $pdf->SetXY($this->posxqty, $curY);
$pdf->MultiCell($this->postotalttc - $this->posxqty - 0.8, 4, $object->lines[$linenumber]->qty, 0, 'R'); $pdf->MultiCell($this->postotalht - $this->posxqty - 0.8, 4, $object->lines[$linenumber]->qty, 0, 'R');
// Total without taxes
$pdf->SetXY($this->postotalht, $curY);
$pdf->MultiCell($this->postotalttc - $this->postotalht - 0.8, 4, price($object->lines[$linenumber]->total_ht), 0, 'R');
// Total with all taxes // Total with all taxes
$pdf->SetXY($this->postotalttc - 1, $curY); $pdf->SetXY($this->postotalttc - 1, $curY);
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 4, price($object->lines[$linenumber]->total_ttc), 0, 'R'); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc + 1, 4, price($object->lines[$linenumber]->total_ttc), 0, 'R');
// Comments // Comments
$pdf->SetXY($this->posxcomment, $curY); $pdf->SetXY($this->posxcomment, $curY);
@ -950,14 +955,14 @@ class pdf_standard extends ModeleExpenseReport
// Accountancy piece // Accountancy piece
if (empty($hidetop)) { if (empty($hidetop)) {
$pdf->SetXY($this->posxpiece - 1, $tab_top + 1); $pdf->SetXY($this->posxpiece - 1, $tab_top + 1);
$pdf->MultiCell($this->posxcomment - $this->posxpiece - 1, 1, '', '', 'R'); $pdf->MultiCell($this->posxcomment - $this->posxpiece - 0.8, 1, '', '', 'R');
} }
// Comments // Comments
$pdf->line($this->posxcomment - 1, $tab_top, $this->posxcomment - 1, $tab_top + $tab_height); $pdf->line($this->posxcomment - 1, $tab_top, $this->posxcomment - 1, $tab_top + $tab_height);
if (empty($hidetop)) { if (empty($hidetop)) {
$pdf->SetXY($this->posxcomment - 1, $tab_top + 1); $pdf->SetXY($this->posxcomment - 1, $tab_top + 1);
$pdf->MultiCell($this->posxdate - $this->posxcomment - 1, 1, $outputlangs->transnoentities("Description"), '', 'L'); $pdf->MultiCell($this->posxdate - $this->posxcomment - 0.8, 1, $outputlangs->transnoentities("Description"), '', 'L');
} }
// Date // Date
@ -990,7 +995,7 @@ class pdf_standard extends ModeleExpenseReport
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
$pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height); $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
if (empty($hidetop)) { if (empty($hidetop)) {
$pdf->SetXY($this->posxtva - 1, $tab_top + 1); $pdf->SetXY($this->posxtva - 0.8, $tab_top + 1);
$pdf->MultiCell($this->posxup - $this->posxtva - 1, 2, $outputlangs->transnoentities("VAT"), '', 'C'); $pdf->MultiCell($this->posxup - $this->posxtva - 1, 2, $outputlangs->transnoentities("VAT"), '', 'C');
} }
} }
@ -998,22 +1003,29 @@ class pdf_standard extends ModeleExpenseReport
// Unit price // Unit price
$pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height); $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
if (empty($hidetop)) { if (empty($hidetop)) {
$pdf->SetXY($this->posxup - 1, $tab_top + 1); $pdf->SetXY($this->posxup - 0.8, $tab_top + 1);
$pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceU"), '', 'C'); $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUTTC"), '', 'C');
} }
// Quantity // Quantity
$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height); $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
if (empty($hidetop)) { if (empty($hidetop)) {
$pdf->SetXY($this->posxqty - 1, $tab_top + 1); $pdf->SetXY($this->posxqty - 0.8, $tab_top + 1);
$pdf->MultiCell($this->postotalttc - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); $pdf->MultiCell($this->postotalht - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
}
// Total without taxes
$pdf->line($this->postotalht - 1, $tab_top, $this->postotalht - 1, $tab_top + $tab_height);
if (empty($hidetop)) {
$pdf->SetXY($this->postotalht - 0.8, $tab_top + 1);
$pdf->MultiCell($this->postotalttc - $this->postotalht + 1, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
} }
// Total with all taxes // Total with all taxes
$pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height); $pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height);
if (empty($hidetop)) { if (empty($hidetop)) {
$pdf->SetXY($this->postotalttc - 1, $tab_top + 1); $pdf->SetXY($this->postotalttc - 0.8, $tab_top + 1);
$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"), '', 'R'); $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc + 1, 2, $outputlangs->transnoentities("TotalTTC"), '', 'R');
} }
$pdf->SetTextColor(0, 0, 0); $pdf->SetTextColor(0, 0, 0);

View File

@ -68,6 +68,7 @@ if (!empty($conf->multicurrency->enabled) && $this->multicurrency_code != $conf-
if (in_array($object->element, array('propal', 'commande', 'order', 'facture', 'facturerec', 'invoice', 'supplier_proposal', 'order_supplier', 'invoice_supplier'))) { if (in_array($object->element, array('propal', 'commande', 'order', 'facture', 'facturerec', 'invoice', 'supplier_proposal', 'order_supplier', 'invoice_supplier'))) {
$colspan++; // With this, there is a column move button $colspan++; // With this, there is a column move button
} }
//print $object->element; //print $object->element;
// Lines for extrafield // Lines for extrafield
$objectline = null; $objectline = null;
@ -673,15 +674,27 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
$("#prod_entry_mode_predef").click(); $("#prod_entry_mode_predef").click();
<?php <?php
} }
?>
if (in_array($this->table_element_line, array('propaldet', 'commandedet', 'facturedet'))) { ?>
$("#date_start, #date_end").focusout(function() {
let type = $(this).attr('type');
let mandatoryP = $(this).attr('mandatoryperiod');
if (type == 1 && mandatoryP == 1) {
if ($(this).val() == '' && !$(this).hasClass('inputmandatory')) {
$(this).addClass('inputmandatory');
}else{
$(this).removeClass('inputmandatory');
}
}
});
<?php
} ?>
/* When changing predefined product, we reload list of supplier prices required for margin combo */ /* When changing predefined product, we reload list of supplier prices required for margin combo */
$("#idprod, #idprodfournprice").change(function() $("#idprod, #idprodfournprice").change(function()
{ {
console.log("Call method change() after change on #idprod or #idprodfournprice (senderissupplier=<?php echo $senderissupplier; ?>). this.val = "+$(this).val()); console.log("Call method change() after change on #idprod or #idprodfournprice (senderissupplier=<?php echo $senderissupplier; ?>). this.val = "+$(this).val());
setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva setforpredef(); // TODO Keep vat combo visible and set it to first entry into list that match result of get_default_tva
jQuery('#trlinefordates').show(); jQuery('#trlinefordates').show();
<?php <?php
@ -703,6 +716,26 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
{ 'id': $(this).val(), 'socid': <?php print $object->socid; ?> }, { 'id': $(this).val(), 'socid': <?php print $object->socid; ?> },
function(data) { function(data) {
console.log("Load unit price end, we got value "+data.price_ht); console.log("Load unit price end, we got value "+data.price_ht);
$('#date_start').removeAttr('type');
$('#date_end').removeAttr('type');
$('#date_start').attr('type', data.type);
$('#date_end').attr('type', data.type);
$('#date_start').removeAttr('mandatoryperiod');
$('#date_end').removeAttr('mandatoryperiod');
$('#date_start').attr('mandatoryperiod', data.mandatory_period);
$('#date_end').attr('mandatoryperiod', data.mandatory_period);
// service and we setted mandatory_period to true
if (data.mandatory_period == 1 && data.type == 1) {
jQuery('#date_start').addClass('inputmandatory');
jQuery('#date_end').addClass('inputmandatory');
}else{
jQuery('#date_start').removeClass('inputmandatory');
jQuery('#date_end').removeClass('inputmandatory');
}
jQuery("#price_ht").val(data.price_ht); jQuery("#price_ht").val(data.price_ht);
<?php <?php
if (!empty($conf->global->PRODUIT_AUTOFILL_DESC) && $conf->global->PRODUIT_AUTOFILL_DESC == 1) { if (!empty($conf->global->PRODUIT_AUTOFILL_DESC) && $conf->global->PRODUIT_AUTOFILL_DESC == 1) {
@ -984,6 +1017,7 @@ if (!empty($usemargins) && $user->rights->margins->creer) {
jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").show(); jQuery("#np_marginRate, #np_markRate, .np_marginRate, .np_markRate, #units, #title_units").show();
jQuery("#fournprice_predef").hide(); jQuery("#fournprice_predef").hide();
} }
function setforpredef() { function setforpredef() {
console.log("Call setforpredef. We hide some fields and show dates"); console.log("Call setforpredef. We hide some fields and show dates");
jQuery("#select_type").val(-1); jQuery("#select_type").val(-1);

View File

@ -333,9 +333,18 @@ $coldisplay++;
if (isset($conf->global->MAIN_DEFAULT_DATE_START_HOUR)) { if (isset($conf->global->MAIN_DEFAULT_DATE_START_HOUR)) {
print 'jQuery("#date_starthour").val("'.$conf->global->MAIN_DEFAULT_DATE_START_HOUR.'");'; print 'jQuery("#date_starthour").val("'.$conf->global->MAIN_DEFAULT_DATE_START_HOUR.'");';
} }
if (isset($conf->global->MAIN_DEFAULT_DATE_START_MIN)) { if (isset($conf->global->MAIN_DEFAULT_DATE_START_MIN)) {
print 'jQuery("#date_startmin").val("'.$conf->global->MAIN_DEFAULT_DATE_START_MIN.'");'; print 'jQuery("#date_startmin").val("'.$conf->global->MAIN_DEFAULT_DATE_START_MIN.'");';
} }
$res = $line->fetch_product();
if ($res > 0 ) {
if ( $line->product->isMandatoryPeriod() && $line->product->isService()) {
print 'jQuery("#date_start").addClass("error");';
}
}
} }
if (!$line->date_end) { if (!$line->date_end) {
if (isset($conf->global->MAIN_DEFAULT_DATE_END_HOUR)) { if (isset($conf->global->MAIN_DEFAULT_DATE_END_HOUR)) {
@ -344,6 +353,14 @@ $coldisplay++;
if (isset($conf->global->MAIN_DEFAULT_DATE_END_MIN)) { if (isset($conf->global->MAIN_DEFAULT_DATE_END_MIN)) {
print 'jQuery("#date_endmin").val("'.$conf->global->MAIN_DEFAULT_DATE_END_MIN.'");'; print 'jQuery("#date_endmin").val("'.$conf->global->MAIN_DEFAULT_DATE_END_MIN.'");';
} }
$res = $line->fetch_product();
// on doit fetch le product là !!! pour connaître le type
if ($res > 0 ) {
if ($line->product->isMandatoryperiod() && $line->product->isService()) {
print 'jQuery("#date_end").addClass("error");';
}
}
} }
print '</script>' print '</script>'
?> ?>
@ -451,7 +468,17 @@ jQuery(document).ready(function()
} }
}); });
<?php <?php if (in_array($this->table_element_line, array('propaldet', 'commandedet', 'facturedet'))) { ?>
$("#date_start, #date_end").focusout(function() {
if ( $(this).val() == '' && !$(this).hasClass('inputmandatory') ) {
$(this).addClass('inputmandatory');
} else {
$(this).removeClass('inputmandatory');
}
});
<?php
}
if (!empty($conf->margin->enabled)) { if (!empty($conf->margin->enabled)) {
?> ?>
/* Add rule to clear margin when we change some data, so when we change sell or buy price, margin will be recalculated after submitting form */ /* Add rule to clear margin when we change some data, so when we change sell or buy price, margin will be recalculated after submitting form */

View File

@ -182,6 +182,22 @@ if (($line->info_bits & 2) == 2) {
if ($line->date_start || $line->date_end) { if ($line->date_start || $line->date_end) {
print '<div class="clearboth nowraponall opacitymedium daterangeofline">'.get_date_range($line->date_start, $line->date_end, $format).'</div>'; print '<div class="clearboth nowraponall opacitymedium daterangeofline">'.get_date_range($line->date_start, $line->date_end, $format).'</div>';
} }
if (!$line->date_start || !$line->date_end) {
// show warning under line
// we need to fetch product associated to line for some test
if ($object->element == 'propal' || $object->element == 'order' || $object->element == 'propal_supplier' || $object->element == 'supplier_proposal' || $object->element == 'commande') {
$res = $line->fetch_product();
if ($res > 0 ) {
if ($line->product->isService() && $line->product->isMandatoryPeriod()) {
print '<div><span class="clearboth nowraponall warning">'.$langs->trans("mandatoryPeriodNeedTobeSet").'</span></div>';
}
}
}
}
//print get_date_range($line->date_start, $line->date_end, $format); //print get_date_range($line->date_start, $line->date_end, $format);
} }

View File

@ -101,8 +101,11 @@ class InterfaceEventOrganization extends DolibarrTriggers
$defaultref = ''; $defaultref = '';
} }
$task->ref = $defaultref; $task->ref = $defaultref;
$task->date_start = $object->date_start;
$task->date_end = $object->date_end; // TODO Can set offset for start date or endline from setup of task to create when creating event
$task->date_start = null;
$task->date_end = null;
$result = $task->create($user); $result = $task->create($user);
if ($result < 0) { if ($result < 0) {
$this->errors=array_merge($this->errors, $task->errors); $this->errors=array_merge($this->errors, $task->errors);

View File

@ -729,10 +729,10 @@ class EcmDirectory extends CommonObject
// We count number of _ to have level (we use strlen that is faster than dol_strlen) // We count number of _ to have level (we use strlen that is faster than dol_strlen)
$this->cats[$id_categ]['level'] = strlen(preg_replace('/([^_])/i', '', $this->cats[$id_categ]['fullpath'])); $this->cats[$id_categ]['level'] = strlen(preg_replace('/([^_])/i', '', $this->cats[$id_categ]['fullpath']));
// Traite ces enfants // Process children
$protection++; $protection++;
if ($protection > 20) { if ($protection > 20) {
return; // On ne traite pas plus de 20 niveaux return; // We never go more than 20 levels
} }
if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) { if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) {
foreach ($this->cats[$id_categ]['id_children'] as $key => $val) { foreach ($this->cats[$id_categ]['id_children'] as $key => $val) {

View File

@ -55,9 +55,10 @@ class FormEcm
* @param int $selected Id of preselected section * @param int $selected Id of preselected section
* @param string $select_name Name of HTML select component * @param string $select_name Name of HTML select component
* @param string $module Module ('ecm', 'medias', ...) * @param string $module Module ('ecm', 'medias', ...)
* @param array $ids_to_ignore Array of id to ignore
* @return string String with HTML select * @return string String with HTML select
*/ */
public function selectAllSections($selected = 0, $select_name = '', $module = 'ecm') public function selectAllSections($selected = 0, $select_name = '', $module = 'ecm', $ids_to_ignore = array())
{ {
global $conf, $langs; global $conf, $langs;
$langs->load("ecm"); $langs->load("ecm");
@ -65,6 +66,9 @@ class FormEcm
if ($select_name == '') { if ($select_name == '') {
$select_name = "catParent"; $select_name = "catParent";
} }
if (!is_array($ids_to_ignore)) {
$ids_to_ignore = array($ids_to_ignore);
}
$cate_arbo = null; $cate_arbo = null;
if ($module == 'ecm') { if ($module == 'ecm') {
@ -83,13 +87,15 @@ class FormEcm
} else { } else {
$output .= '<option value="-1">&nbsp;</option>'; $output .= '<option value="-1">&nbsp;</option>';
foreach ($cate_arbo as $key => $value) { foreach ($cate_arbo as $key => $value) {
$valueforoption = empty($cate_arbo[$key]['id']) ? $cate_arbo[$key]['relativename'] : $cate_arbo[$key]['id']; if (!in_array($cate_arbo[$key]['id'], $ids_to_ignore)) {
if ($selected && $valueforoption == $selected) { $valueforoption = empty($cate_arbo[$key]['id']) ? $cate_arbo[$key]['relativename'] : $cate_arbo[$key]['id'];
$add = 'selected '; if ($selected && $valueforoption == $selected) {
} else { $add = 'selected ';
$add = ''; } else {
$add = '';
}
$output .= '<option '.$add.'value="'.dol_escape_htmltag($valueforoption).'">'.(empty($cate_arbo[$key]['fulllabel']) ? $cate_arbo[$key]['relativename'] : $cate_arbo[$key]['fulllabel']).'</option>';
} }
$output .= '<option '.$add.'value="'.dol_escape_htmltag($valueforoption).'">'.(empty($cate_arbo[$key]['fulllabel']) ? $cate_arbo[$key]['relativename'] : $cate_arbo[$key]['fulllabel']).'</option>';
} }
} }
} }

View File

@ -28,6 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.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/ecm.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ecm.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/ecm/class/htmlecm.form.class.php';
// Load translation files required by page // Load translation files required by page
$langs->loadLangs(array('ecm', 'companies', 'other')); $langs->loadLangs(array('ecm', 'companies', 'other'));
@ -204,6 +205,12 @@ if ($action == 'update' && !GETPOST('cancel', 'alpha') && $permtoadd) {
// Fetch was already done // Fetch was already done
$ecmdir->label = dol_sanitizeFileName(GETPOST("label")); $ecmdir->label = dol_sanitizeFileName(GETPOST("label"));
$fk_parent = GETPOST("catParent", 'int');
if ($fk_parent == "-1") {
$ecmdir->fk_parent = "0";
} else {
$ecmdir->fk_parent = $fk_parent;
}
$ecmdir->description = GETPOST("description"); $ecmdir->description = GETPOST("description");
$ret = $extrafields->setOptionalsFromPost(null, $ecmdir); $ret = $extrafields->setOptionalsFromPost(null, $ecmdir);
if ($ret < 0) { if ($ret < 0) {
@ -219,8 +226,10 @@ if ($action == 'update' && !GETPOST('cancel', 'alpha') && $permtoadd) {
} }
$result = $ecmdir->update($user); $result = $ecmdir->update($user);
if ($result > 0) { if ($result > 0) {
$newdir = $ecmdir->getRelativePath(1);
$newdir = $conf->ecm->dir_output.'/'.$newdir;
// Try to rename file if changed // Try to rename file if changed
if ($oldlabel != $ecmdir->label && file_exists($olddir)) { if (($oldlabel != $ecmdir->label && file_exists($olddir)) || ($olddir != $newdir && file_exists($olddir))) {
$newdir = $ecmdir->getRelativePath(1); // return "xxx/zzz/" from ecm directory $newdir = $ecmdir->getRelativePath(1); // return "xxx/zzz/" from ecm directory
$newdir = $conf->ecm->dir_output.'/'.$newdir; $newdir = $conf->ecm->dir_output.'/'.$newdir;
//print $olddir.'-'.$newdir; //print $olddir.'-'.$newdir;
@ -270,6 +279,7 @@ if ($action == 'update' && !GETPOST('cancel', 'alpha') && $permtoadd) {
*/ */
$form = new Form($db); $form = new Form($db);
$formecm = new FormEcm($db);
$object = new EcmDirectory($db); // Need to create a new one instance $object = new EcmDirectory($db); // Need to create a new one instance
$extrafields = new ExtraFields($db); $extrafields = new ExtraFields($db);
@ -317,11 +327,7 @@ if ($module == 'ecm') {
$tmpecmdir->fetch($ecmdir->id); $tmpecmdir->fetch($ecmdir->id);
while ($tmpecmdir && $result > 0) { while ($tmpecmdir && $result > 0) {
$tmpecmdir->ref = $tmpecmdir->label; $tmpecmdir->ref = $tmpecmdir->label;
if ($i == 0 && $action == 'edit') { $s = $tmpecmdir->getNomUrl(1).$s;
$s = '<input type="text" name="label" class="minwidth300" maxlength="32" value="'.$tmpecmdir->label.'">';
} else {
$s = $tmpecmdir->getNomUrl(1).$s;
}
if ($tmpecmdir->fk_parent) { if ($tmpecmdir->fk_parent) {
$s = ' -> '.$s; $s = ' -> '.$s;
$result = $tmpecmdir->fetch($tmpecmdir->fk_parent); $result = $tmpecmdir->fetch($tmpecmdir->fk_parent);
@ -371,6 +377,16 @@ print img_picto('','object_dir').' <a href="'.DOL_URL_ROOT.'/ecm/index.php">'.$l
print $s; print $s;
print '</td></tr>';*/ print '</td></tr>';*/
if ($module == 'ecm') { if ($module == 'ecm') {
if ($action == 'edit') {
print '<tr><td class="titlefield tdtop">'.$langs->trans("ECMDirName").'</td><td>';
print '<input type="text" name="label" class="minwidth300" maxlength="32" value="'.$ecmdir->label.'">';
print '</td></tr>';
print '<tr><td class="titlefield tdtop">'.$langs->trans("ECMParentDirectory").'</td><td>';
print $formecm->selectAllSections($ecmdir->fk_parent, '', 'ecm', array($ecmdir->id));
print '</td><td>';
print '</td></tr>';
}
print '<tr><td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'; print '<tr><td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
if ($action == 'edit') { if ($action == 'edit') {
print '<textarea class="flat quatrevingtpercent" name="description">'; print '<textarea class="flat quatrevingtpercent" name="description">';

View File

@ -966,7 +966,7 @@ class EmailCollector extends CommonObject
dol_syslog("EmailCollector::doCollectOneCollector start for id=".$this->id, LOG_DEBUG); dol_syslog("EmailCollector::doCollectOneCollector start for id=".$this->id, LOG_DEBUG);
$langs->loadLangs(array("project", "companies", "mails", "errors", "ticket", "agenda")); $langs->loadLangs(array("project", "companies", "mails", "errors", "ticket", "agenda", "commercial"));
$error = 0; $error = 0;
$this->output = ''; $this->output = '';

View File

@ -205,13 +205,12 @@ if (!empty($projectstatic->socid)) {
$projectstatic->fetch_thirdparty(); $projectstatic->fetch_thirdparty();
} }
$withProjectUrl='';
$object->project = clone $projectstatic; $object->project = clone $projectstatic;
if (!empty($withproject)) { if (!empty($withproject)) {
// Tabs for project // Tabs for project
$tab = 'eventorganisation'; $tab = 'eventorganisation';
$withProjectUrl = "&withproject=1";
$head = project_prepare_head($projectstatic); $head = project_prepare_head($projectstatic);
print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', '');
@ -421,8 +420,10 @@ if (!empty($withproject)) {
if ($action == 'create') { if ($action == 'create') {
print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("ConferenceOrBoothAttendee")), '', 'object_'.$object->picto); print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("ConferenceOrBoothAttendee")), '', 'object_'.$object->picto);
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].(!empty($withProjectUrl)?'?'.$withProjectUrl:'').'">';
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].(empty($withproject) ? '' : '?withproject=1').'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
if ($confOrBooth->id > 0) { if ($confOrBooth->id > 0) {
print '<input type="hidden" name="conforboothid" value="'.$confOrBooth->id.'">'; print '<input type="hidden" name="conforboothid" value="'.$confOrBooth->id.'">';
@ -432,8 +433,6 @@ if ($action == 'create') {
print '<input type="hidden" name="projectid" value="'.$projectstatic->id.'">'; print '<input type="hidden" name="projectid" value="'.$projectstatic->id.'">';
} }
print '<input type="hidden" name="action" value="add">';
if ($backtopage) { if ($backtopage) {
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">'; print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
} }

View File

@ -2549,7 +2549,7 @@ if ($action == 'create') {
// Presend form // Presend form
$modelmail = 'shipping_send'; $modelmail = 'shipping_send';
$defaulttopic = 'SendShippingRef'; $defaulttopic = 'SendShippingRef';
$diroutput = $conf->expedition->dir_output.'/sending'; $diroutput = $conf->expedition->dir_output;
$trackid = 'shi'.$object->id; $trackid = 'shi'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';

View File

@ -235,7 +235,7 @@ if (empty($reshook)) {
$object->fk_user_author = $user->id; $object->fk_user_author = $user->id;
} }
// Check that expense report is for a user inside the hierarchy or advanced permission for all is set // Check that expense report is for a user inside the hierarchy, or that advanced permission for all is set
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->expensereport->creer)) if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->expensereport->creer))
|| (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->expensereport->creer) && empty($user->rights->expensereport->writeall_advance))) { || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->expensereport->creer) && empty($user->rights->expensereport->writeall_advance))) {
$error++; $error++;
@ -1110,7 +1110,7 @@ if (empty($reshook)) {
$action = ''; $action = '';
} }
if ((int) $tmpvat < 0 || $tmpvat == '') { if ((float) $tmpvat < 0 || $tmpvat === '') {
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("VAT")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("VAT")), null, 'errors');
$action = ''; $action = '';
@ -1205,7 +1205,6 @@ if (empty($reshook)) {
} }
} }
$object->update_totaux_del($object_ligne->total_ht, $object_ligne->total_tva);
header("Location: ".$_SERVER["PHP_SELF"]."?id=".GETPOST('id', 'int')); header("Location: ".$_SERVER["PHP_SELF"]."?id=".GETPOST('id', 'int'));
exit; exit;
} else { } else {
@ -1255,7 +1254,7 @@ if (empty($reshook)) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
$action = ''; $action = '';
} }
if ((int) $tmpvat < 0 || $tmpvat == '') { if ((float) $tmpvat < 0 || $tmpvat == '') {
$error++; $error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Vat")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Vat")), null, 'errors');
$action = ''; $action = '';
@ -1292,8 +1291,6 @@ if (empty($reshook)) {
} }
} }
$result = $object->recalculer($id);
//header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); //header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
//exit; //exit;
} else { } else {
@ -1453,8 +1450,6 @@ if ($action == 'create') {
} elseif ($id > 0 || $ref) { } elseif ($id > 0 || $ref) {
$result = $object->fetch($id, $ref); $result = $object->fetch($id, $ref);
$res = $object->fetch_optionals();
if ($result > 0) { if ($result > 0) {
if (!in_array($object->fk_user_author, $user->getAllChildIds(1))) { if (!in_array($object->fk_user_author, $user->getAllChildIds(1))) {
if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous) if (empty($user->rights->expensereport->readall) && empty($user->rights->expensereport->lire_tous)
@ -1852,12 +1847,22 @@ if ($action == 'create') {
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("AmountVAT").'</td>'; print '<td>'.$langs->trans("AmountVAT").'</td>';
print '<td class="nowrap amountcard">'.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency).'</td>'; print '<td class="nowrap amountcard">'.price($object->total_tva, 1, '', 1, -1, -1, $conf->currency).'</td>';
print '</tr>'; print '</tr>';
// Amount Local Taxes
if ($mysoc->localtax1_assuj == "1" || $object->total_localtax1 != 0) { // Localtax1
print '<tr><td>'.$langs->transcountry("AmountLT1", $mysoc->country_code).'</td>';
print '<td class="valuefield">'.price($object->total_localtax1, 1, '', 1, -1, -1, $conf->currency).'</td></tr>';
}
if ($mysoc->localtax2_assuj == "1" || $object->total_localtax2 != 0) { // Localtax2 IRPF
print '<tr><td>'.$langs->transcountry("AmountLT2", $mysoc->country_code).'</td>';
print '<td class="valuefield">'.price($object->total_localtax2, 1, '', 1, -1, -1, $conf->currency).'</td></tr>';
}
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("AmountTTC").'</td>'; print '<td>'.$langs->trans("AmountTTC").'</td>';
print '<td class="nowrap amountcard">'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency).'</td>'; print '<td class="nowrap amountcard">'.price($object->total_ttc, 1, '', 1, -1, -1, $conf->currency).'</td>';
print '</tr>'; print '</tr>';
// List of payments already done // List of payments already done
@ -2062,7 +2067,7 @@ if ($action == 'create') {
// Comment // Comment
print '<td class="left">'.dol_nl2br($line->comments).'</td>'; print '<td class="left">'.dol_nl2br($line->comments).'</td>';
// VAT rate // VAT rate
print '<td class="right">'.vatrate($line->vatrate, true).'</td>'; print '<td class="right">'.vatrate($line->vatrate.($line->vat_src_code ? ' ('.$line->vat_src_code.')' : ''), true).'</td>';
// Unit price HT // Unit price HT
print '<td class="right">'; print '<td class="right">';
if (!empty($line->value_unit_ht)) { if (!empty($line->value_unit_ht)) {
@ -2269,8 +2274,9 @@ if ($action == 'create') {
print '</td>'; print '</td>';
// VAT // VAT
$selectedvat = price2num($line->vatrate).($line->vat_src_code ? ' ('.$line->vat_src_code.')' : '');
print '<td class="right">'; print '<td class="right">';
print $form->load_tva('vatrate', (GETPOSTISSET("vatrate") ? GETPOST("vatrate") : $line->vatrate), $mysoc, '', 0, 0, '', false, 1); print $form->load_tva('vatrate', (GETPOSTISSET("vatrate") ? GETPOST("vatrate") : $selectedvat), $mysoc, '', 0, 0, '', false, 1);
print '</td>'; print '</td>';
// Unit price // Unit price

View File

@ -80,8 +80,6 @@ class ExpenseReport extends CommonObject
*/ */
public $fk_statut; public $fk_statut;
public $vat_src_code;
public $fk_c_paiement; public $fk_c_paiement;
public $paid; public $paid;
@ -124,6 +122,9 @@ class ExpenseReport extends CommonObject
// Paiement // Paiement
public $user_paid_infos; public $user_paid_infos;
public $localtax1; // for backward compatibility (real field should be total_localtax1 defined into CommonObject)
public $localtax2; // for backward compatibility (real field should be total_localtax2 defined into CommonObject)
/** /**
* Draft status * Draft status
@ -213,6 +214,10 @@ class ExpenseReport extends CommonObject
$this->total_ht = 0; $this->total_ht = 0;
$this->total_ttc = 0; $this->total_ttc = 0;
$this->total_tva = 0; $this->total_tva = 0;
$this->total_localtax1 = 0;
$this->total_localtax2 = 0;
$this->localtax1 = 0; // For backward compatibility
$this->localtax2 = 0; // For backward compatibility
$this->modepaymentid = 0; $this->modepaymentid = 0;
// List of language codes for status // List of language codes for status
@ -314,12 +319,18 @@ class ExpenseReport extends CommonObject
$newndfline->fk_project = $line->fk_project; $newndfline->fk_project = $line->fk_project;
$newndfline->vatrate = $line->vatrate; $newndfline->vatrate = $line->vatrate;
$newndfline->vat_src_code = $line->vat_src_code; $newndfline->vat_src_code = $line->vat_src_code;
$newndfline->localtax1_tx = $line->localtax1_tx;
$newndfline->localtax2_tx = $line->localtax2_tx;
$newndfline->localtax1_type = $line->localtax1_type;
$newndfline->localtax2_type = $line->localtax2_type;
$newndfline->comments = $line->comments; $newndfline->comments = $line->comments;
$newndfline->qty = $line->qty; $newndfline->qty = $line->qty;
$newndfline->value_unit = $line->value_unit; $newndfline->value_unit = $line->value_unit;
$newndfline->total_ht = $line->total_ht; $newndfline->total_ht = $line->total_ht;
$newndfline->total_ttc = $line->total_ttc; $newndfline->total_ttc = $line->total_ttc;
$newndfline->total_tva = $line->total_tva; $newndfline->total_tva = $line->total_tva;
$newndfline->total_localtax1 = $line->total_localtax1;
$newndfline->total_localtax2 = $line->total_localtax2;
$newndfline->date = $line->date; $newndfline->date = $line->date;
$newndfline->rule_warning_message = $line->rule_warning_message; $newndfline->rule_warning_message = $line->rule_warning_message;
$newndfline->fk_c_exp_tax_cat = $line->fk_c_exp_tax_cat; $newndfline->fk_c_exp_tax_cat = $line->fk_c_exp_tax_cat;
@ -539,7 +550,8 @@ class ExpenseReport extends CommonObject
$sql = "SELECT d.rowid, d.entity, d.ref, d.note_public, d.note_private,"; // DEFAULT $sql = "SELECT d.rowid, d.entity, d.ref, d.note_public, d.note_private,"; // DEFAULT
$sql .= " d.detail_refuse, d.detail_cancel, d.fk_user_refuse, d.fk_user_cancel,"; // ACTIONS $sql .= " d.detail_refuse, d.detail_cancel, d.fk_user_refuse, d.fk_user_cancel,"; // ACTIONS
$sql .= " d.date_refuse, d.date_cancel,"; // ACTIONS $sql .= " d.date_refuse, d.date_cancel,"; // ACTIONS
$sql .= " d.total_ht, d.total_ttc, d.total_tva,"; // TOTAUX (int) $sql .= " d.total_ht, d.total_ttc, d.total_tva,";
$sql .= " d.localtax1 as total_localtax1, d.localtax2 as total_localtax2,";
$sql .= " d.date_debut, d.date_fin, d.date_create, d.tms as date_modif, d.date_valid, d.date_approve,"; // DATES (datetime) $sql .= " d.date_debut, d.date_fin, d.date_create, d.tms as date_modif, d.date_valid, d.date_approve,"; // DATES (datetime)
$sql .= " d.fk_user_creat, d.fk_user_author, d.fk_user_modif, d.fk_user_validator,"; $sql .= " d.fk_user_creat, d.fk_user_author, d.fk_user_modif, d.fk_user_validator,";
$sql .= " d.fk_user_valid, d.fk_user_approve,"; $sql .= " d.fk_user_valid, d.fk_user_approve,";
@ -565,6 +577,11 @@ class ExpenseReport extends CommonObject
$this->total_ht = $obj->total_ht; $this->total_ht = $obj->total_ht;
$this->total_tva = $obj->total_tva; $this->total_tva = $obj->total_tva;
$this->total_ttc = $obj->total_ttc; $this->total_ttc = $obj->total_ttc;
$this->localtax1 = $obj->total_localtax1; // For backward compatibility
$this->localtax2 = $obj->total_localtax2; // For backward compatibility
$this->total_localtax1 = $obj->total_localtax1;
$this->total_localtax2 = $obj->total_localtax2;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;
$this->detail_refuse = $obj->detail_refuse; $this->detail_refuse = $obj->detail_refuse;
@ -962,54 +979,6 @@ class ExpenseReport extends CommonObject
} }
} }
/**
* recalculer
* TODO Replace this with call to update_price if not already done
*
* @param int $id Id of expense report
* @return int <0 if KO, >0 if OK
*/
public function recalculer($id)
{
$sql = 'SELECT tt.total_ht, tt.total_ttc, tt.total_tva';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as tt';
$sql .= " WHERE tt.".$this->fk_element.' = '.((int) $id);
$total_ht = 0; $total_tva = 0; $total_ttc = 0;
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
$i = 0;
while ($i < $num) {
$objp = $this->db->fetch_object($result);
$total_ht += $objp->total_ht;
$total_tva += $objp->total_tva;
$i++;
}
$total_ttc = $total_ht + $total_tva;
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
$sql .= " total_ht = ".((float) price2num($total_ht, 'MT'));
$sql .= " , total_ttc = ".((float) price2num($total_ttc, 'MT'));
$sql .= " , total_tva = ".((float) price2num($total_tva, 'MT'));
$sql .= " WHERE rowid = ".((int) $id);
$result = $this->db->query($sql);
if ($result) {
$this->db->free($result);
return 1;
} else {
$this->error = $this->db->lasterror();
dol_syslog(get_class($this)."::recalculer: Error ".$this->error, LOG_ERR);
return -3;
}
} else {
$this->error = $this->db->lasterror();
dol_syslog(get_class($this)."::recalculer: Error ".$this->error, LOG_ERR);
return -3;
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* fetch_lines * fetch_lines
@ -1024,8 +993,12 @@ class ExpenseReport extends CommonObject
$this->lines = array(); $this->lines = array();
$sql = ' SELECT de.rowid, de.comments, de.qty, de.value_unit, de.date, de.rang,'; $sql = ' SELECT de.rowid, de.comments, de.qty, de.value_unit, de.date, de.rang,';
$sql .= " de.".$this->fk_element.", de.fk_c_type_fees, de.fk_c_exp_tax_cat, de.fk_projet as fk_project, de.tva_tx, de.fk_ecm_files,"; $sql .= " de.".$this->fk_element.", de.fk_c_type_fees, de.fk_c_exp_tax_cat, de.fk_projet as fk_project,";
$sql .= ' de.tva_tx, de.vat_src_code,';
$sql .= ' de.localtax1_tx, de.localtax2_tx, de.localtax1_type, de.localtax2_type,';
$sql .= ' de.fk_ecm_files,';
$sql .= ' de.total_ht, de.total_tva, de.total_ttc,'; $sql .= ' de.total_ht, de.total_tva, de.total_ttc,';
$sql .= ' de.total_localtax1, de.total_localtax2,';
$sql .= ' ctf.code as code_type_fees, ctf.label as libelle_type_fees,'; $sql .= ' ctf.code as code_type_fees, ctf.label as libelle_type_fees,';
$sql .= ' p.ref as ref_projet, p.title as title_projet'; $sql .= ' p.ref as ref_projet, p.title as title_projet';
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as de'; $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as de';
@ -1065,11 +1038,20 @@ class ExpenseReport extends CommonObject
$deplig->total_ht = $objp->total_ht; $deplig->total_ht = $objp->total_ht;
$deplig->total_tva = $objp->total_tva; $deplig->total_tva = $objp->total_tva;
$deplig->total_ttc = $objp->total_ttc; $deplig->total_ttc = $objp->total_ttc;
$deplig->total_localtax1 = $objp->total_localtax1;
$deplig->total_localtax2 = $objp->total_localtax2;
$deplig->type_fees_code = empty($objp->code_type_fees) ? 'TF_OTHER' : $objp->code_type_fees; $deplig->type_fees_code = empty($objp->code_type_fees) ? 'TF_OTHER' : $objp->code_type_fees;
$deplig->type_fees_libelle = $objp->libelle_type_fees; $deplig->type_fees_libelle = $objp->libelle_type_fees;
$deplig->tva_tx = $objp->tva_tx;
$deplig->tva_tx = $objp->tva_tx;
$deplig->vatrate = $objp->tva_tx; $deplig->vatrate = $objp->tva_tx;
$deplig->vat_src_code = $objp->vat_src_code;
$deplig->localtax1_tx = $objp->localtax1_tx;
$deplig->localtax2_tx = $objp->localtax2_tx;
$deplig->localtax1_type = $objp->localtax1_type;
$deplig->localtax2_type = $objp->localtax2_type;
$deplig->projet_ref = $objp->ref_projet; $deplig->projet_ref = $objp->ref_projet;
$deplig->projet_title = $objp->title_projet; $deplig->projet_title = $objp->title_projet;
@ -1757,41 +1739,11 @@ class ExpenseReport extends CommonObject
} }
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Update total of an expense report when you delete a line. * Add expense report line
*
* @param string $ligne_total_ht Amount without taxes
* @param string $ligne_total_tva Amount of all taxes
* @return void
*/
public function update_totaux_del($ligne_total_ht, $ligne_total_tva)
{
// phpcs:enable
$this->total_ht = $this->total_ht - $ligne_total_ht;
$this->total_tva = $this->total_tva - $ligne_total_tva;
$this->total_ttc = $this->total_ht + $this->total_tva;
$sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET";
$sql .= " total_ht = ".$this->total_ht;
$sql .= " , total_ttc = ".$this->total_ttc;
$sql .= " , total_tva = ".$this->total_tva;
$sql .= " WHERE rowid = ".((int) $this->id);
$result = $this->db->query($sql);
if ($result) {
return 1;
} else {
$this->error = $this->db->error();
return -1;
}
}
/**
* addline
* *
* @param float $qty Qty * @param float $qty Qty
* @param double $up Value init * @param double $up Unit price (price with tax)
* @param int $fk_c_type_fees Type payment * @param int $fk_c_type_fees Type payment
* @param string $vatrate Vat rate (Can be '10' or '10 (ABC)') * @param string $vatrate Vat rate (Can be '10' or '10 (ABC)')
* @param string $date Date * @param string $date Date
@ -1838,7 +1790,14 @@ class ExpenseReport extends CommonObject
$this->line = new ExpenseReportLine($this->db); $this->line = new ExpenseReportLine($this->db);
$localtaxes_type = getLocalTaxesFromRate($vatrate, 0, $mysoc, $this->thirdparty); // We don't know seller and buyer for expense reports
$seller = $mysoc; // We use same than current company (expense report are often done in same country)
$seller->tva_assuj = 1; // Most seller uses vat
$seller->localtax1_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company
$seller->localtax2_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company
$buyer = new Societe($this->db);
$localtaxes_type = getLocalTaxesFromRate($vatrate, 0, $buyer, $seller);
$vat_src_code = ''; $vat_src_code = '';
$reg = array(); $reg = array();
@ -1848,16 +1807,22 @@ class ExpenseReport extends CommonObject
} }
$vatrate = preg_replace('/\*/', '', $vatrate); $vatrate = preg_replace('/\*/', '', $vatrate);
$seller = ''; // seller is unknown $tmp = calcul_price_total($qty, $up, 0, $vatrate, -1, -1, 0, 'TTC', 0, $type, $seller, $localtaxes_type);
$tmp = calcul_price_total($qty, $up, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type, $seller, $localtaxes_type);
$this->line->value_unit = $up; $this->line->value_unit = $up;
$this->line->vat_src_code = $vat_src_code; $this->line->vat_src_code = $vat_src_code;
$this->line->vatrate = price2num($vatrate); $this->line->vatrate = price2num($vatrate);
$this->line->localtax1_tx = $localtaxes_type[1];
$this->line->localtax2_tx = $localtaxes_type[3];
$this->line->localtax1_type = $localtaxes_type[0];
$this->line->localtax2_type = $localtaxes_type[2];
$this->line->total_ttc = $tmp[2]; $this->line->total_ttc = $tmp[2];
$this->line->total_ht = $tmp[0]; $this->line->total_ht = $tmp[0];
$this->line->total_tva = $tmp[1]; $this->line->total_tva = $tmp[1];
$this->line->total_localtax1 = $tmp[9];
$this->line->total_localtax2 = $tmp[10];
$this->line->fk_expensereport = $this->id; $this->line->fk_expensereport = $this->id;
$this->line->qty = $qty; $this->line->qty = $qty;
@ -1899,13 +1864,13 @@ class ExpenseReport extends CommonObject
/** /**
* Check constraint of rules and update price if needed * Check constraint of rules and update price if needed
* *
* @param int $type type of line * @param int $type Type of line
* @param string $seller seller, but actually he is unknown * @param string $seller Seller, but actually he is unknown
* @return true or false * @return true or false
*/ */
public function checkRules($type = 0, $seller = '') public function checkRules($type = 0, $seller = '')
{ {
global $user, $conf, $db, $langs; global $user, $conf, $db, $langs, $mysoc;
$langs->load('trips'); $langs->load('trips');
@ -1913,6 +1878,15 @@ class ExpenseReport extends CommonObject
return true; // if don't use rules return true; // if don't use rules
} }
// We don't know seller and buyer for expense reports
if (!is_object($seller)) {
$seller = $mysoc; // We use same than current company (expense report are often done in same country)
$seller->tva_assuj = 1; // Most seller uses vat
$seller->localtax1_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company
$seller->localtax2_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company
}
//$buyer = new Societe($this->db);
$rulestocheck = ExpenseReportRule::getAllRule($this->line->fk_c_type_fees, $this->line->date, $this->fk_user_author); $rulestocheck = ExpenseReportRule::getAllRule($this->line->fk_c_type_fees, $this->line->date, $this->fk_user_author);
$violation = 0; $violation = 0;
@ -1960,6 +1934,8 @@ class ExpenseReport extends CommonObject
$this->line->total_ttc = $tmp[2]; $this->line->total_ttc = $tmp[2];
$this->line->total_ht = $tmp[0]; $this->line->total_ht = $tmp[0];
$this->line->total_tva = $tmp[1]; $this->line->total_tva = $tmp[1];
$this->line->total_localtax1 = $tmp[9];
$this->line->total_localtax2 = $tmp[10];
return false; return false;
} else { } else {
@ -1970,11 +1946,13 @@ class ExpenseReport extends CommonObject
/** /**
* Method to apply the offset if needed * Method to apply the offset if needed
* *
* @return boolean true=applied, false=not applied * @param int $type Type of line
* @param string $seller Seller, but actually he is unknown
* @return boolean True=applied, False=not applied
*/ */
public function applyOffset() public function applyOffset($type = 0, $seller = '')
{ {
global $conf; global $conf, $mysoc;
if (empty($conf->global->MAIN_USE_EXPENSE_IK)) { if (empty($conf->global->MAIN_USE_EXPENSE_IK)) {
return false; return false;
@ -1987,6 +1965,15 @@ class ExpenseReport extends CommonObject
return false; return false;
} }
// We don't know seller and buyer for expense reports
if (!is_object($seller)) {
$seller = $mysoc; // We use same than current company (expense report are often done in same country)
$seller->tva_assuj = 1; // Most seller uses vat
$seller->localtax1_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company
$seller->localtax2_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company
}
//$buyer = new Societe($this->db);
$range = ExpenseReportIk::getRangeByUser($userauthor, $this->line->fk_c_exp_tax_cat); $range = ExpenseReportIk::getRangeByUser($userauthor, $this->line->fk_c_exp_tax_cat);
if (empty($range)) { if (empty($range)) {
@ -2010,6 +1997,8 @@ class ExpenseReport extends CommonObject
$this->line->total_ttc = $tmp[2]; $this->line->total_ttc = $tmp[2];
$this->line->total_ht = $tmp[0]; $this->line->total_ht = $tmp[0];
$this->line->total_tva = $tmp[1]; $this->line->total_tva = $tmp[1];
$this->line->total_localtax1 = $tmp[9];
$this->line->total_localtax2 = $tmp[10];
return true; return true;
} }
@ -2033,7 +2022,7 @@ class ExpenseReport extends CommonObject
$sql .= ' AND d.rowid <> '.((int) $this->line->id); $sql .= ' AND d.rowid <> '.((int) $this->line->id);
} }
dol_syslog(get_class($this)."::offsetAlreadyGiven sql=".$sql); dol_syslog(get_class($this)."::offsetAlreadyGiven");
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) { if ($resql) {
$num = $this->db->num_rows($resql); $num = $this->db->num_rows($resql);
@ -2056,7 +2045,7 @@ class ExpenseReport extends CommonObject
* @param double $vatrate Vat rate. Can be '8.5' or '8.5* (8.5NPROM...)' * @param double $vatrate Vat rate. Can be '8.5' or '8.5* (8.5NPROM...)'
* @param string $comments Description * @param string $comments Description
* @param float $qty Qty * @param float $qty Qty
* @param double $value_unit Value init * @param double $value_unit Unit price (with taxes)
* @param int $date Date * @param int $date Date
* @param int $expensereport_id Expense report id * @param int $expensereport_id Expense report id
* @param int $fk_c_exp_tax_cat Id of category of car * @param int $fk_c_exp_tax_cat Id of category of car
@ -2073,7 +2062,10 @@ class ExpenseReport extends CommonObject
$type = 0; // TODO What if type is service ? $type = 0; // TODO What if type is service ?
// We don't know seller and buyer for expense reports // We don't know seller and buyer for expense reports
$seller = $mysoc; $seller = $mysoc; // We use same than current company (expense report are often done in same country)
$seller->tva_assuj = 1; // Most seller uses vat
$seller->localtax1_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company
$seller->localtax2_assuj = $mysoc->localtax1_assuj; // We don't know, we reuse the state of company
$buyer = new Societe($this->db); $buyer = new Societe($this->db);
$localtaxes_type = getLocalTaxesFromRate($vatrate, 0, $buyer, $seller); $localtaxes_type = getLocalTaxesFromRate($vatrate, 0, $buyer, $seller);
@ -2087,8 +2079,8 @@ class ExpenseReport extends CommonObject
} }
$vatrate = preg_replace('/\*/', '', $vatrate); $vatrate = preg_replace('/\*/', '', $vatrate);
$tmp = calcul_price_total($qty, $value_unit, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type, $seller, $localtaxes_type); $tmp = calcul_price_total($qty, $value_unit, 0, $vatrate, -1, -1, 0, 'TTC', 0, $type, $seller, $localtaxes_type);
//var_dump($vatrate);var_dump($localtaxes_type);var_dump($tmp);exit;
// calcul total of line // calcul total of line
//$total_ttc = price2num($qty*$value_unit, 'MT'); //$total_ttc = price2num($qty*$value_unit, 'MT');
@ -2109,14 +2101,17 @@ class ExpenseReport extends CommonObject
$this->line->vat_src_code = $vat_src_code; $this->line->vat_src_code = $vat_src_code;
$this->line->vatrate = price2num($vatrate); $this->line->vatrate = price2num($vatrate);
$this->line->total_ttc = $tmp[2];
$this->line->total_ht = $tmp[0];
$this->line->total_tva = $tmp[1];
$this->line->localtax1_tx = $localtaxes_type[1]; $this->line->localtax1_tx = $localtaxes_type[1];
$this->line->localtax2_tx = $localtaxes_type[3]; $this->line->localtax2_tx = $localtaxes_type[3];
$this->line->localtax1_type = $localtaxes_type[0]; $this->line->localtax1_type = $localtaxes_type[0];
$this->line->localtax2_type = $localtaxes_type[2]; $this->line->localtax2_type = $localtaxes_type[2];
$this->line->total_ttc = $tmp[2];
$this->line->total_ht = $tmp[0];
$this->line->total_tva = $tmp[1];
$this->line->total_localtax1 = $tmp[9];
$this->line->total_localtax2 = $tmp[10];
$this->line->fk_ecm_files = $fk_ecm_files; $this->line->fk_ecm_files = $fk_ecm_files;
$this->line->id = ((int) $rowid); $this->line->id = ((int) $rowid);
@ -2184,6 +2179,8 @@ class ExpenseReport extends CommonObject
return -1; return -1;
} }
$this->update_price();
$this->db->commit(); $this->db->commit();
return 1; return 1;
@ -2593,9 +2590,17 @@ class ExpenseReportLine
public $projet_title; public $projet_title;
public $vatrate; public $vatrate;
public $vat_src_code;
public $localtax1_tx;
public $localtax2_tx;
public $localtax1_type;
public $localtax2_type;
public $total_ht; public $total_ht;
public $total_tva; public $total_tva;
public $total_ttc; public $total_ttc;
public $total_localtax1;
public $total_localtax2;
/** /**
* @var int ID into llx_ecm_files table to link line to attached file * @var int ID into llx_ecm_files table to link line to attached file
@ -2623,6 +2628,7 @@ class ExpenseReportLine
{ {
$sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_c_exp_tax_cat, fde.fk_projet as fk_project, fde.date,'; $sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_c_exp_tax_cat, fde.fk_projet as fk_project, fde.date,';
$sql .= ' fde.tva_tx as vatrate, fde.vat_src_code, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc, fde.fk_ecm_files,'; $sql .= ' fde.tva_tx as vatrate, fde.vat_src_code, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc, fde.fk_ecm_files,';
$sql .= ' fde.localtax1_tx, fde.localtax2_tx, fde.localtax1_type, fde.localtax2_type, fde.total_localtax1, fde.total_localtax2,';
$sql .= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,'; $sql .= ' ctf.code as type_fees_code, ctf.label as type_fees_libelle,';
$sql .= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref'; $sql .= ' pjt.rowid as projet_id, pjt.title as projet_title, pjt.ref as projet_ref';
$sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde'; $sql .= ' FROM '.MAIN_DB_PREFIX.'expensereport_det as fde';
@ -2652,11 +2658,20 @@ class ExpenseReportLine
$this->type_fees_libelle = $objp->type_fees_libelle; $this->type_fees_libelle = $objp->type_fees_libelle;
$this->projet_ref = $objp->projet_ref; $this->projet_ref = $objp->projet_ref;
$this->projet_title = $objp->projet_title; $this->projet_title = $objp->projet_title;
$this->vatrate = $objp->vatrate; $this->vatrate = $objp->vatrate;
$this->vat_src_code = $objp->vat_src_code; $this->vat_src_code = $objp->vat_src_code;
$this->localtax1_tx = $objp->localtax1_tx;
$this->localtax2_tx = $objp->localtax2_tx;
$this->localtax1_type = $objp->localtax1_type;
$this->localtax2_type = $objp->localtax2_type;
$this->total_ht = $objp->total_ht; $this->total_ht = $objp->total_ht;
$this->total_tva = $objp->total_tva; $this->total_tva = $objp->total_tva;
$this->total_ttc = $objp->total_ttc; $this->total_ttc = $objp->total_ttc;
$this->total_localtax1 = $objp->total_localtax1;
$this->total_localtax2 = $objp->total_localtax2;
$this->fk_ecm_files = $objp->fk_ecm_files; $this->fk_ecm_files = $objp->fk_ecm_files;
$this->db->free($result); $this->db->free($result);
@ -2695,18 +2710,29 @@ class ExpenseReportLine
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'expensereport_det'; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'expensereport_det';
$sql .= ' (fk_expensereport, fk_c_type_fees, fk_projet,'; $sql .= ' (fk_expensereport, fk_c_type_fees, fk_projet,';
$sql .= ' tva_tx, vat_src_code, comments, qty, value_unit, total_ht, total_tva, total_ttc, date, rule_warning_message, fk_c_exp_tax_cat, fk_ecm_files)'; $sql .= ' tva_tx, vat_src_code,';
$sql .= ' localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
$sql .= ' comments, qty, value_unit,';
$sql .= ' total_ht, total_tva, total_ttc,';
$sql .= ' total_localtax1, total_localtax2,';
$sql .= ' date, rule_warning_message, fk_c_exp_tax_cat, fk_ecm_files)';
$sql .= " VALUES (".$this->db->escape($this->fk_expensereport).","; $sql .= " VALUES (".$this->db->escape($this->fk_expensereport).",";
$sql .= " ".((int) $this->fk_c_type_fees).","; $sql .= " ".((int) $this->fk_c_type_fees).",";
$sql .= " ".((int) (!empty($this->fk_project) && $this->fk_project > 0) ? $this->fk_project : ((!empty($this->fk_projet) && $this->fk_projet > 0) ? $this->fk_projet : 'null')).","; $sql .= " ".((int) (!empty($this->fk_project) && $this->fk_project > 0) ? $this->fk_project : ((!empty($this->fk_projet) && $this->fk_projet > 0) ? $this->fk_projet : 'null')).",";
$sql .= " ".((float) $this->vatrate).","; $sql .= " ".((float) $this->vatrate).",";
$sql .= " '".$this->db->escape(empty($this->vat_src_code) ? '' : $this->vat_src_code)."',"; $sql .= " '".$this->db->escape(empty($this->vat_src_code) ? '' : $this->vat_src_code)."',";
$sql .= " ".((float) price2num($this->localtax1_tx)).",";
$sql .= " ".((float) price2num($this->localtax2_tx)).",";
$sql .= " '".$this->db->escape($this->localtax1_type)."',";
$sql .= " '".$this->db->escape($this->localtax2_type)."',";
$sql .= " '".$this->db->escape($this->comments)."',"; $sql .= " '".$this->db->escape($this->comments)."',";
$sql .= " ".((float) $this->qty).","; $sql .= " ".((float) $this->qty).",";
$sql .= " ".((float) $this->value_unit).","; $sql .= " ".((float) $this->value_unit).",";
$sql .= " ".((float) price2num($this->total_ht)).","; $sql .= " ".((float) price2num($this->total_ht)).",";
$sql .= " ".((float) price2num($this->total_tva)).","; $sql .= " ".((float) price2num($this->total_tva)).",";
$sql .= " ".((float) price2num($this->total_ttc)).","; $sql .= " ".((float) price2num($this->total_ttc)).",";
$sql .= " ".((float) price2num($this->total_localtax1)).",";
$sql .= " ".((float) price2num($this->total_localtax2)).",";
$sql .= " '".$this->db->idate($this->date)."',"; $sql .= " '".$this->db->idate($this->date)."',";
$sql .= " ".(empty($this->rule_warning_message) ? 'null' : "'".$this->db->escape($this->rule_warning_message)."'").","; $sql .= " ".(empty($this->rule_warning_message) ? 'null' : "'".$this->db->escape($this->rule_warning_message)."'").",";
$sql .= " ".((int) $this->fk_c_exp_tax_cat).","; $sql .= " ".((int) $this->fk_c_exp_tax_cat).",";
@ -2814,11 +2840,17 @@ class ExpenseReportLine
$sql .= ", value_unit = ".((float) $this->value_unit); $sql .= ", value_unit = ".((float) $this->value_unit);
$sql .= ", qty=".((float) $this->qty); $sql .= ", qty=".((float) $this->qty);
$sql .= ", date='".$this->db->idate($this->date)."'"; $sql .= ", date='".$this->db->idate($this->date)."'";
$sql .= ", total_ht=".((float) price2num($this->total_ht, 'MT')).""; $sql .= ", total_ht=".((float) price2num($this->total_ht, 'MT'));
$sql .= ", total_tva=".((float) price2num($this->total_tva, 'MT')).""; $sql .= ", total_tva=".((float) price2num($this->total_tva, 'MT'));
$sql .= ", total_ttc=".((float) price2num($this->total_ttc, 'MT')).""; $sql .= ", total_ttc=".((float) price2num($this->total_ttc, 'MT'));
$sql .= ", total_localtax1=".((float) price2num($this->total_localtax1, 'MT'));
$sql .= ", total_localtax2=".((float) price2num($this->total_localtax2, 'MT'));
$sql .= ", tva_tx=".((float) $this->vatrate); $sql .= ", tva_tx=".((float) $this->vatrate);
$sql .= ", vat_src_code='".$this->db->escape($this->vat_src_code)."'"; $sql .= ", vat_src_code='".$this->db->escape($this->vat_src_code)."'";
$sql .= ", localtax1_tx=".((float) $this->localtax1_tx);
$sql .= ", localtax2_tx=".((float) $this->localtax2_tx);
$sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'";
$sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'";
$sql .= ", rule_warning_message='".$this->db->escape($this->rule_warning_message)."'"; $sql .= ", rule_warning_message='".$this->db->escape($this->rule_warning_message)."'";
$sql .= ", fk_c_exp_tax_cat=".$this->db->escape($this->fk_c_exp_tax_cat); $sql .= ", fk_c_exp_tax_cat=".$this->db->escape($this->fk_c_exp_tax_cat);
$sql .= ", fk_ecm_files=".($this->fk_ecm_files > 0 ? ((int) $this->fk_ecm_files) : 'null'); $sql .= ", fk_ecm_files=".($this->fk_ecm_files > 0 ? ((int) $this->fk_ecm_files) : 'null');

View File

@ -1146,7 +1146,7 @@ if ($action == 'create') {
$morehtmlref .= '<input type="hidden" name="action" value="classin">'; $morehtmlref .= '<input type="hidden" name="action" value="classin">';
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">'; $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; $morehtmlref .= '<input type="submit" class="button button-edit valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref .= '</form>'; $morehtmlref .= '</form>';
} else { } else {
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);

View File

@ -423,9 +423,9 @@ if (empty($reshook)) {
dol_print_error($db); dol_print_error($db);
} }
} elseif ($action == 'setdatef' && $usercancreate) { } elseif ($action == 'setdatef' && $usercancreate) {
$newdate = dol_mktime(0, 0, 0, $_POST['datefmonth'], $_POST['datefday'], $_POST['datefyear']); $newdate = dol_mktime(0, 0, 0, GETPOST('datefmonth', 'int'), GETPOST('datefday', 'int'), GETPOST('datefyear', 'int'), 'tzserver');
if ($newdate > (dol_now() + (empty($conf->global->INVOICE_MAX_OFFSET_IN_FUTURE) ? 0 : $conf->global->INVOICE_MAX_OFFSET_IN_FUTURE))) { if ($newdate > (dol_now('tzuserrel') + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) {
if (empty($conf->global->INVOICE_MAX_OFFSET_IN_FUTURE)) { if (empty($conf->global->INVOICE_MAX_FUTURE_DELAY)) {
setEventMessages($langs->trans("WarningInvoiceDateInFuture"), null, 'warnings'); setEventMessages($langs->trans("WarningInvoiceDateInFuture"), null, 'warnings');
} else { } else {
setEventMessages($langs->trans("WarningInvoiceDateTooFarInFuture"), null, 'warnings'); setEventMessages($langs->trans("WarningInvoiceDateTooFarInFuture"), null, 'warnings');
@ -449,7 +449,7 @@ if (empty($reshook)) {
} }
} elseif ($action == 'setdate_lim_reglement' && $usercancreate) { } elseif ($action == 'setdate_lim_reglement' && $usercancreate) {
$object->fetch($id); $object->fetch($id);
$object->date_echeance = dol_mktime(12, 0, 0, $_POST['date_lim_reglementmonth'], $_POST['date_lim_reglementday'], $_POST['date_lim_reglementyear']); $object->date_echeance = dol_mktime(12, 0, 0, GETPOST('date_lim_reglementmonth', 'int'), GETPOST('date_lim_reglementday', 'int'), GETPOST('date_lim_reglementyear', 'int'));
if (!empty($object->date_echeance) && $object->date_echeance < $object->date) { if (!empty($object->date_echeance) && $object->date_echeance < $object->date) {
$object->date_echeance = $object->date; $object->date_echeance = $object->date;
setEventMessages($langs->trans("DatePaymentTermCantBeLowerThanObjectDate"), null, 'warnings'); setEventMessages($langs->trans("DatePaymentTermCantBeLowerThanObjectDate"), null, 'warnings');
@ -695,6 +695,7 @@ if (empty($reshook)) {
if ($socid > 0) { if ($socid > 0) {
$object->socid = GETPOST('socid', 'int'); $object->socid = GETPOST('socid', 'int');
} }
$selectedLines = GETPOST('toselect', 'array');
$db->begin(); $db->begin();
@ -706,8 +707,12 @@ if (empty($reshook)) {
$error++; $error++;
} }
$dateinvoice = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $dateinvoice = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'), 'tzserver'); // If we enter the 02 january, we need to save the 02 january for server
$datedue = dol_mktime(12, 0, 0, GETPOST('echmonth', 'int'), GETPOST('echday', 'int'), GETPOST('echyear', 'int')); $datedue = dol_mktime(0, 0, 0, GETPOST('echmonth', 'int'), GETPOST('echday', 'int'), GETPOST('echyear', 'int'), 'tzserver');
/*var_dump($dateinvoice.' '.dol_print_date($dateinvoice, 'dayhour'));
var_dump(dol_now('tzuserrel').' '.dol_get_last_hour(dol_now('tzuserrel')).' '.dol_print_date(dol_now('tzuserrel'),'dayhour').' '.dol_print_date(dol_get_last_hour(dol_now('tzuserrel')), 'dayhour'));
var_dump($db->idate($dateinvoice));
exit;*/
// Replacement invoice // Replacement invoice
if (GETPOST('type') == FactureFournisseur::TYPE_REPLACEMENT) { if (GETPOST('type') == FactureFournisseur::TYPE_REPLACEMENT) {
@ -716,7 +721,7 @@ if (empty($reshook)) {
$action = 'create'; $action = 'create';
$_GET['socid'] = $_POST['socid']; $_GET['socid'] = $_POST['socid'];
$error++; $error++;
} elseif ($dateinvoice > (dol_get_last_hour(dol_now()) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { } elseif ($dateinvoice > (dol_get_last_hour(dol_now('tzuserrel')) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) {
$error++; $error++;
setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors');
$action = 'create'; $action = 'create';
@ -780,7 +785,7 @@ if (empty($reshook)) {
$action = 'create'; $action = 'create';
$_GET['socid'] = $_POST['socid']; $_GET['socid'] = $_POST['socid'];
$error++; $error++;
} elseif ($dateinvoice > (dol_get_last_hour(dol_now()) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { } elseif ($dateinvoice > (dol_get_last_hour(dol_now('tzuserrel')) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) {
$error++; $error++;
setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors');
$action = 'create'; $action = 'create';
@ -889,7 +894,7 @@ if (empty($reshook)) {
$action = 'create'; $action = 'create';
$_GET['socid'] = $_POST['socid']; $_GET['socid'] = $_POST['socid'];
$error++; $error++;
} elseif ($dateinvoice > (dol_get_last_hour(dol_now()) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) { } elseif ($dateinvoice > (dol_get_last_hour(dol_now('tzuserrel')) + (empty($conf->global->INVOICE_MAX_FUTURE_DELAY) ? 0 : $conf->global->INVOICE_MAX_FUTURE_DELAY))) {
$error++; $error++;
setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors'); setEventMessages($langs->trans("ErrorDateIsInFuture"), null, 'errors');
$action = 'create'; $action = 'create';
@ -1127,6 +1132,10 @@ if (empty($reshook)) {
$num = count($lines); $num = count($lines);
for ($i = 0; $i < $num; $i++) { // TODO handle subprice < 0 for ($i = 0; $i < $num; $i++) { // TODO handle subprice < 0
if (!in_array($lines[$i]->id, $selectedLines)) {
continue; // Skip unselected lines
}
$desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); $desc = ($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle);
$product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0); $product_type = ($lines[$i]->product_type ? $lines[$i]->product_type : 0);
@ -2359,9 +2368,6 @@ if ($action == 'create') {
print $form->buttonsSaveCancel("CreateDraft"); print $form->buttonsSaveCancel("CreateDraft");
print "</form>\n";
// Show origin lines // Show origin lines
if (is_object($objectsrc)) { if (is_object($objectsrc)) {
print '<br>'; print '<br>';
@ -2375,6 +2381,8 @@ if ($action == 'create') {
print '</table>'; print '</table>';
} }
print "</form>\n";
} else { } else {
if ($id > 0 || !empty($ref)) { if ($id > 0 || !empty($ref)) {
// //

View File

@ -57,6 +57,7 @@ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private,
-- v15 -- v15
ALTER TABLE llx_product ADD COLUMN mandatory_period tinyint NULL DEFAULT 0;
ALTER TABLE llx_holiday ADD COLUMN date_approve DATETIME DEFAULT NULL; ALTER TABLE llx_holiday ADD COLUMN date_approve DATETIME DEFAULT NULL;
ALTER TABLE llx_holiday ADD COLUMN fk_user_approve integer DEFAULT NULL; ALTER TABLE llx_holiday ADD COLUMN fk_user_approve integer DEFAULT NULL;

View File

@ -29,10 +29,10 @@ create table llx_commande_fournisseurdet
label varchar(255), -- product label label varchar(255), -- product label
description text, description text,
vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here.
tva_tx double(6,3) DEFAULT 0, -- taux tva tva_tx double(7,4) DEFAULT 0, -- taux tva
localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate localtax1_tx double(7,4) DEFAULT 0, -- localtax1 rate
localtax1_type varchar(10) NULL, -- localtax1 type localtax1_type varchar(10) NULL, -- localtax1 type
localtax2_tx double(6,3) DEFAULT 0, -- localtax2 rate localtax2_tx double(7,4) DEFAULT 0, -- localtax2 rate
localtax2_type varchar(10) NULL, -- localtax2 type localtax2_type varchar(10) NULL, -- localtax2 type
qty real, -- quantity qty real, -- quantity
remise_percent real DEFAULT 0, -- pourcentage de remise remise_percent real DEFAULT 0, -- pourcentage de remise

View File

@ -29,10 +29,10 @@ create table llx_commandedet
label varchar(255) DEFAULT NULL, label varchar(255) DEFAULT NULL,
description text, description text,
vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here.
tva_tx double(6,3), -- Vat rate tva_tx double(7,4), -- Vat rate
localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate localtax1_tx double(7,4) DEFAULT 0, -- localtax1 rate
localtax1_type varchar(10) NULL, -- localtax1 type localtax1_type varchar(10) NULL, -- localtax1 type
localtax2_tx double(6,3) DEFAULT 0, -- localtax2 rate localtax2_tx double(7,4) DEFAULT 0, -- localtax2 rate
localtax2_type varchar(10) NULL, -- localtax2 type localtax2_type varchar(10) NULL, -- localtax2 type
qty real, -- quantity qty real, -- quantity
remise_percent real DEFAULT 0, -- pourcentage de remise remise_percent real DEFAULT 0, -- pourcentage de remise

View File

@ -38,10 +38,10 @@ create table llx_contratdet
date_cloture datetime, date_cloture datetime,
vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here.
tva_tx double(6,3) DEFAULT 0, -- taux tva tva_tx double(7,4) DEFAULT 0, -- taux tva
localtax1_tx double(6,3) DEFAULT 0, -- local tax 1 rate localtax1_tx double(7,4) DEFAULT 0, -- local tax 1 rate
localtax1_type varchar(10) NULL, -- localtax1 type localtax1_type varchar(10) NULL, -- localtax1 type
localtax2_tx double(6,3) DEFAULT 0, -- local tax 2 rate localtax2_tx double(7,4) DEFAULT 0, -- local tax 2 rate
localtax2_type varchar(10) NULL, -- localtax2 type localtax2_type varchar(10) NULL, -- localtax2 type
qty real NOT NULL, -- quantity qty real NOT NULL, -- quantity
remise_percent real DEFAULT 0, -- pourcentage de remise remise_percent real DEFAULT 0, -- pourcentage de remise

View File

@ -21,6 +21,7 @@ CREATE TABLE llx_eventorganization_conferenceorboothattendee(
fk_soc integer, fk_soc integer,
fk_actioncomm integer, fk_actioncomm integer,
fk_project integer NOT NULL, fk_project integer NOT NULL,
fk_invoice integer NULL,
email varchar(100), email varchar(100),
date_subscription datetime, date_subscription datetime,
amount double DEFAULT NULL, amount double DEFAULT NULL,

View File

@ -31,10 +31,10 @@ CREATE TABLE llx_expensereport_det
value_unit double(24,8) NOT NULL, -- P.U. TTC (example 120) value_unit double(24,8) NOT NULL, -- P.U. TTC (example 120)
remise_percent real, remise_percent real,
vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here.
tva_tx double(6,3), -- Vat rate tva_tx double(7,4), -- Vat rate
localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate localtax1_tx double(7,4) DEFAULT 0, -- localtax1 rate
localtax1_type varchar(10) NULL, -- localtax1 type localtax1_type varchar(10) NULL, -- localtax1 type
localtax2_tx double(6,3) DEFAULT 0, -- localtax2 rate localtax2_tx double(7,4) DEFAULT 0, -- localtax2 rate
localtax2_type varchar(10) NULL, -- localtax2 type localtax2_type varchar(10) NULL, -- localtax2 type
total_ht double(24,8) DEFAULT 0 NOT NULL, total_ht double(24,8) DEFAULT 0 NOT NULL,
total_tva double(24,8) DEFAULT 0 NOT NULL, total_tva double(24,8) DEFAULT 0 NOT NULL,

View File

@ -33,10 +33,10 @@ create table llx_facture_fourn_det
remise_percent real DEFAULT 0, -- % de la remise ligne (exemple 20%) remise_percent real DEFAULT 0, -- % de la remise ligne (exemple 20%)
fk_remise_except integer NULL, -- Lien vers table des remises fixes fk_remise_except integer NULL, -- Lien vers table des remises fixes
vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here.
tva_tx double(6,3), -- TVA taux product/service tva_tx double(7,4), -- TVA taux product/service
localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate localtax1_tx double(7,4) DEFAULT 0, -- localtax1 rate
localtax1_type varchar(10) NULL, -- localtax1 type localtax1_type varchar(10) NULL, -- localtax1 type
localtax2_tx double(6,3) DEFAULT 0, -- localtax2 rate localtax2_tx double(7,4) DEFAULT 0, -- localtax2 rate
localtax2_type varchar(10) NULL, -- localtax2 type localtax2_type varchar(10) NULL, -- localtax2 type
total_ht double(24,8), -- Total line price of product excluding tax total_ht double(24,8), -- Total line price of product excluding tax
tva double(24,8), -- Total TVA of line tva double(24,8), -- Total TVA of line

View File

@ -31,10 +31,10 @@ create table llx_facturedet
label varchar(255) DEFAULT NULL, label varchar(255) DEFAULT NULL,
description text, description text,
vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here.
tva_tx double(6,3), -- Vat rate (example 20%) tva_tx double(7,4), -- Vat rate (example 20%)
localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate localtax1_tx double(7,4) DEFAULT 0, -- localtax1 rate
localtax1_type varchar(10) NULL, -- localtax1 type localtax1_type varchar(10) NULL, -- localtax1 type
localtax2_tx double(6,3) DEFAULT 0, -- localtax2 rate localtax2_tx double(7,4) DEFAULT 0, -- localtax2 rate
localtax2_type varchar(10) NULL, -- localtax2 type localtax2_type varchar(10) NULL, -- localtax2 type
qty real, -- Quantity (exemple 2). Note: for credit note, the price is negative, not the quantity. Like for discount, price is negative, not quantity. qty real, -- Quantity (exemple 2). Note: for credit note, the price is negative, not the quantity. Like for discount, price is negative, not quantity.
remise_percent real DEFAULT 0, -- % de la remise ligne (exemple 20%) remise_percent real DEFAULT 0, -- % de la remise ligne (exemple 20%)

View File

@ -30,10 +30,10 @@ create table llx_facturedet_rec
label varchar(255) DEFAULT NULL, label varchar(255) DEFAULT NULL,
description text, description text,
vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here.
tva_tx double(6,3), -- taux tva tva_tx double(7,4), -- taux tva
localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate localtax1_tx double(7,4) DEFAULT 0, -- localtax1 rate
localtax1_type varchar(10) NULL, -- localtax1 type localtax1_type varchar(10) NULL, -- localtax1 type
localtax2_tx double(6,3) DEFAULT 0, -- localtax2 rate localtax2_tx double(7,4) DEFAULT 0, -- localtax2 rate
localtax2_type varchar(10) NULL, -- localtax2 type localtax2_type varchar(10) NULL, -- localtax2 type
qty real, -- quantity qty real, -- quantity
remise_percent real DEFAULT 0, -- pourcentage de remise remise_percent real DEFAULT 0, -- pourcentage de remise

View File

@ -47,11 +47,11 @@ create table llx_product
price_base_type varchar(3) DEFAULT 'HT', price_base_type varchar(3) DEFAULT 'HT',
cost_price double(24,8) DEFAULT NULL, -- Cost price without tax. Can be used for margin calculation. cost_price double(24,8) DEFAULT NULL, -- Cost price without tax. Can be used for margin calculation.
default_vat_code varchar(10), -- Same code than into table llx_c_tva (but no constraints). Should be used in priority to find default vat, npr, localtaxes for product. default_vat_code varchar(10), -- Same code than into table llx_c_tva (but no constraints). Should be used in priority to find default vat, npr, localtaxes for product.
tva_tx double(6,3), -- Default VAT rate of product tva_tx double(7,4), -- Default VAT rate of product
recuperableonly integer NOT NULL DEFAULT '0', -- French NPR VAT recuperableonly integer NOT NULL DEFAULT '0', -- French NPR VAT
localtax1_tx double(6,3) DEFAULT 0, localtax1_tx double(7,4) DEFAULT 0,
localtax1_type varchar(10) NOT NULL DEFAULT '0', localtax1_type varchar(10) NOT NULL DEFAULT '0',
localtax2_tx double(6,3) DEFAULT 0, localtax2_tx double(7,4) DEFAULT 0,
localtax2_type varchar(10) NOT NULL DEFAULT '0', localtax2_type varchar(10) NOT NULL DEFAULT '0',
fk_user_author integer DEFAULT NULL, -- user making creation fk_user_author integer DEFAULT NULL, -- user making creation
fk_user_modif integer, -- user making last change fk_user_modif integer, -- user making last change
@ -103,6 +103,9 @@ create table llx_product
desiredstock float DEFAULT 0, desiredstock float DEFAULT 0,
fk_unit integer DEFAULT NULL, fk_unit integer DEFAULT NULL,
price_autogen tinyint DEFAULT 0, price_autogen tinyint DEFAULT 0,
fk_project integer DEFAULT NULL, -- Used when product was generated by a project or is specifif to a project
mandatory_period tinyint DEFAULT 0 -- is used to signal to the user that the start and end dates are mandatory for this type of product the fk_product_type == 1 (service) (non-blocking action)
fk_default_bom integer DEFAULT NULL, fk_default_bom integer DEFAULT NULL,
fk_project integer DEFAULT NULL -- Used when the product was generated by a project or is specific to a project fk_project integer DEFAULT NULL -- Used when the product was generated by a project or is specific to a project
)ENGINE=innodb; )ENGINE=innodb;

View File

@ -35,11 +35,11 @@ create table llx_product_customer_price
price_min_ttc double(24,8) DEFAULT 0, price_min_ttc double(24,8) DEFAULT 0,
price_base_type varchar(3) DEFAULT 'HT', price_base_type varchar(3) DEFAULT 'HT',
default_vat_code varchar(10), -- Same code than into table llx_c_tva (but no constraints). Should be used in priority to find default vat, npr, localtaxes for product. default_vat_code varchar(10), -- Same code than into table llx_c_tva (but no constraints). Should be used in priority to find default vat, npr, localtaxes for product.
tva_tx double(6,3), tva_tx double(7,4),
recuperableonly integer NOT NULL DEFAULT '0', -- Other NPR VAT recuperableonly integer NOT NULL DEFAULT '0', -- Other NPR VAT
localtax1_tx double(6,3) DEFAULT 0, -- Other local VAT 1 localtax1_tx double(7,4) DEFAULT 0, -- Other local VAT 1
localtax1_type varchar(10) NOT NULL DEFAULT '0', localtax1_type varchar(10) NOT NULL DEFAULT '0',
localtax2_tx double(6,3) DEFAULT 0, -- Other local VAT 2 localtax2_tx double(7,4) DEFAULT 0, -- Other local VAT 2
localtax2_type varchar(10) NOT NULL DEFAULT '0', localtax2_type varchar(10) NOT NULL DEFAULT '0',
fk_user integer, fk_user integer,
import_key varchar(14) -- Import key import_key varchar(14) -- Import key

View File

@ -34,11 +34,11 @@ create table llx_product_customer_price_log
price_min_ttc double(24,8) DEFAULT 0, price_min_ttc double(24,8) DEFAULT 0,
price_base_type varchar(3) DEFAULT 'HT', price_base_type varchar(3) DEFAULT 'HT',
default_vat_code varchar(10), -- Same code than into table llx_c_tva (but no constraints). Should be used in priority to find default vat, npr, localtaxes for product. default_vat_code varchar(10), -- Same code than into table llx_c_tva (but no constraints). Should be used in priority to find default vat, npr, localtaxes for product.
tva_tx double(6,3), tva_tx double(7,4),
recuperableonly integer NOT NULL DEFAULT '0', -- Other NPR VAT recuperableonly integer NOT NULL DEFAULT '0', -- Other NPR VAT
localtax1_tx double(6,3) DEFAULT 0, -- Other local VAT 1 localtax1_tx double(7,4) DEFAULT 0, -- Other local VAT 1
localtax1_type varchar(10) NOT NULL DEFAULT '0', localtax1_type varchar(10) NOT NULL DEFAULT '0',
localtax2_tx double(6,3) DEFAULT 0, -- Other local VAT 2 localtax2_tx double(7,4) DEFAULT 0, -- Other local VAT 2
localtax2_type varchar(10) NOT NULL DEFAULT '0', localtax2_type varchar(10) NOT NULL DEFAULT '0',
fk_user integer, fk_user integer,
import_key varchar(14) -- Import key import_key varchar(14) -- Import key

View File

@ -39,10 +39,10 @@ create table llx_product_fournisseur_price
default_vat_code varchar(10), default_vat_code varchar(10),
barcode varchar(180) DEFAULT NULL, -- barcode barcode varchar(180) DEFAULT NULL, -- barcode
fk_barcode_type integer DEFAULT NULL, -- barcode type fk_barcode_type integer DEFAULT NULL, -- barcode type
tva_tx double(6,3) NOT NULL, tva_tx double(7,4) NOT NULL,
localtax1_tx double(6,3) DEFAULT 0, localtax1_tx double(7,4) DEFAULT 0,
localtax1_type varchar(10) NOT NULL DEFAULT '0', localtax1_type varchar(10) NOT NULL DEFAULT '0',
localtax2_tx double(6,3) DEFAULT 0, localtax2_tx double(7,4) DEFAULT 0,
localtax2_type varchar(10) NOT NULL DEFAULT '0', localtax2_type varchar(10) NOT NULL DEFAULT '0',
info_bits integer NOT NULL DEFAULT 0, info_bits integer NOT NULL DEFAULT 0,
fk_user integer, fk_user integer,

View File

@ -35,11 +35,11 @@ create table llx_product_price
price_min_ttc double(24,8) default NULL, price_min_ttc double(24,8) default NULL,
price_base_type varchar(3) DEFAULT 'HT', price_base_type varchar(3) DEFAULT 'HT',
default_vat_code varchar(10), -- Same code than into table llx_c_tva (but no constraints). Should be used in priority to find default vat, npr, localtaxes for product. default_vat_code varchar(10), -- Same code than into table llx_c_tva (but no constraints). Should be used in priority to find default vat, npr, localtaxes for product.
tva_tx double(6,3) DEFAULT 0 NOT NULL, -- Used only when option PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL is on (not supported) tva_tx double(7,4) DEFAULT 0 NOT NULL, -- Used only when option PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL is on (not supported)
recuperableonly integer NOT NULL DEFAULT '0', recuperableonly integer NOT NULL DEFAULT '0',
localtax1_tx double(6,3) DEFAULT 0, localtax1_tx double(7,4) DEFAULT 0,
localtax1_type varchar(10) NOT NULL DEFAULT '0', localtax1_type varchar(10) NOT NULL DEFAULT '0',
localtax2_tx double(6,3) DEFAULT 0, localtax2_tx double(7,4) DEFAULT 0,
localtax2_type varchar(10) NOT NULL DEFAULT '0', localtax2_type varchar(10) NOT NULL DEFAULT '0',
fk_user_author integer, fk_user_author integer,
tosell tinyint DEFAULT 1, tosell tinyint DEFAULT 1,

View File

@ -29,10 +29,10 @@ create table llx_propaldet
description text, description text,
fk_remise_except integer NULL, -- Lien vers table des remises fixes fk_remise_except integer NULL, -- Lien vers table des remises fixes
vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here.
tva_tx double(6,3) DEFAULT 0, -- Vat rate tva_tx double(7,4) DEFAULT 0, -- Vat rate
localtax1_tx double(6,3) DEFAULT 0, -- localtax1 rate localtax1_tx double(7,4) DEFAULT 0, -- localtax1 rate
localtax1_type varchar(10) NULL, -- localtax1 type localtax1_type varchar(10) NULL, -- localtax1 type
localtax2_tx double(6,3) DEFAULT 0, -- localtax2 rate localtax2_tx double(7,4) DEFAULT 0, -- localtax2 rate
localtax2_type varchar(10) NULL, -- localtax2 type localtax2_type varchar(10) NULL, -- localtax2 type
qty real, -- quantity qty real, -- quantity
remise_percent real DEFAULT 0, -- pourcentage de remise remise_percent real DEFAULT 0, -- pourcentage de remise

View File

@ -99,9 +99,9 @@ create table llx_societe
fk_shipping_method integer, -- preferred shipping method id fk_shipping_method integer, -- preferred shipping method id
tva_assuj tinyint DEFAULT 1, -- assujeti ou non a la TVA tva_assuj tinyint DEFAULT 1, -- assujeti ou non a la TVA
localtax1_assuj tinyint DEFAULT 0, -- assujeti ou non a local tax 1 localtax1_assuj tinyint DEFAULT 0, -- assujeti ou non a local tax 1
localtax1_value double(6,3), localtax1_value double(7,4),
localtax2_assuj tinyint DEFAULT 0, -- assujeti ou non a local tax 2 localtax2_assuj tinyint DEFAULT 0, -- assujeti ou non a local tax 2
localtax2_value double(6,3), localtax2_value double(7,4),
barcode varchar(180), -- barcode barcode varchar(180), -- barcode
fk_barcode_type integer NULL DEFAULT 0, -- barcode type fk_barcode_type integer NULL DEFAULT 0, -- barcode type
price_level integer NULL, -- level of price for multiprices price_level integer NULL, -- level of price for multiprices

View File

@ -27,7 +27,7 @@ create table llx_societe_remise
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
datec datetime, -- creation date datec datetime, -- creation date
fk_user_author integer, -- creation user fk_user_author integer, -- creation user
remise_client double(6,3) DEFAULT 0 NOT NULL, -- discount remise_client double(7,4) DEFAULT 0 NOT NULL, -- discount
note text note text
)ENGINE=innodb; )ENGINE=innodb;

View File

@ -29,7 +29,7 @@ create table llx_societe_remise_except
amount_ht double(24,8) NOT NULL, amount_ht double(24,8) NOT NULL,
amount_tva double(24,8) DEFAULT 0 NOT NULL, amount_tva double(24,8) DEFAULT 0 NOT NULL,
amount_ttc double(24,8) DEFAULT 0 NOT NULL, amount_ttc double(24,8) DEFAULT 0 NOT NULL,
tva_tx double(6,3) DEFAULT 0 NOT NULL, tva_tx double(7,4) DEFAULT 0 NOT NULL,
vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here.
fk_user integer NOT NULL, fk_user integer NOT NULL,
fk_facture_line integer, fk_facture_line integer,

View File

@ -27,7 +27,7 @@ create table llx_societe_remise_supplier
tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
datec datetime, -- creation date datec datetime, -- creation date
fk_user_author integer, -- creation user fk_user_author integer, -- creation user
remise_supplier double(6,3) DEFAULT 0 NOT NULL, -- discount remise_supplier double(7,4) DEFAULT 0 NOT NULL, -- discount
note text note text
)ENGINE=innodb; )ENGINE=innodb;

View File

@ -24,10 +24,10 @@ CREATE TABLE llx_supplier_proposaldet (
description text, description text,
fk_remise_except integer DEFAULT NULL, fk_remise_except integer DEFAULT NULL,
vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here. vat_src_code varchar(10) DEFAULT '', -- Vat code used as source of vat fields. Not strict foreign key here.
tva_tx double(6,3) DEFAULT 0, -- Vat rate tva_tx double(7,4) DEFAULT 0, -- Vat rate
localtax1_tx double(6,3) DEFAULT 0, localtax1_tx double(7,4) DEFAULT 0,
localtax1_type varchar(10) DEFAULT NULL, localtax1_type varchar(10) DEFAULT NULL,
localtax2_tx double(6,3) DEFAULT 0, localtax2_tx double(7,4) DEFAULT 0,
localtax2_type varchar(10) DEFAULT NULL, localtax2_type varchar(10) DEFAULT NULL,
qty double DEFAULT NULL, qty double DEFAULT NULL,
remise_percent double DEFAULT '0', remise_percent double DEFAULT '0',

View File

@ -144,11 +144,6 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port); $db = getDoliDBInstance($conf->db->type, $conf->db->host, $conf->db->user, $conf->db->pass, $conf->db->name, $conf->db->port);
// Create the global $hookmanager object
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
$hookmanager->initHooks(array('upgrade'));
if (!$db->connected) { if (!$db->connected) {
print '<tr><td colspan="4">'.$langs->trans("ErrorFailedToConnectToDatabase", $conf->db->name).'</td><td class="right">'.$langs->trans('Error').'</td></tr>'; print '<tr><td colspan="4">'.$langs->trans("ErrorFailedToConnectToDatabase", $conf->db->name).'</td><td class="right">'.$langs->trans('Error').'</td></tr>';
dolibarr_install_syslog('upgrade2: failed to connect to database :'.$conf->db->name.' on '.$conf->db->host.' for user '.$conf->db->user, LOG_ERR); dolibarr_install_syslog('upgrade2: failed to connect to database :'.$conf->db->name.' on '.$conf->db->host.' for user '.$conf->db->user, LOG_ERR);
@ -182,6 +177,11 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
$conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
} }
// Create the global $hookmanager object
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager = new HookManager($db);
$hookmanager->initHooks(array('upgrade'));
/*************************************************************************************** /***************************************************************************************
* *

View File

@ -37,8 +37,8 @@ OtherInfo=Other information
DeleteCptCategory=Remove accounting account from group DeleteCptCategory=Remove accounting account from group
ConfirmDeleteCptCategory=Are you sure you want to remove this accounting account from the accounting account group? ConfirmDeleteCptCategory=Are you sure you want to remove this accounting account from the accounting account group?
JournalizationInLedgerStatus=Status of journalization JournalizationInLedgerStatus=Status of journalization
AlreadyInGeneralLedger=Already transferred in accounting journals and ledger AlreadyInGeneralLedger=Already transferred to accounting journals and ledger
NotYetInGeneralLedger=Not yet transferred in accouting journals and ledger NotYetInGeneralLedger=Not yet transferred to accouting journals and ledger
GroupIsEmptyCheckSetup=Group is empty, check setup of the personalized accounting group GroupIsEmptyCheckSetup=Group is empty, check setup of the personalized accounting group
DetailByAccount=Show detail by account DetailByAccount=Show detail by account
AccountWithNonZeroValues=Accounts with non-zero values AccountWithNonZeroValues=Accounts with non-zero values
@ -298,7 +298,7 @@ NoNewRecordSaved=No more record to journalize
ListOfProductsWithoutAccountingAccount=List of products not bound to any accounting account ListOfProductsWithoutAccountingAccount=List of products not bound to any accounting account
ChangeBinding=Change the binding ChangeBinding=Change the binding
Accounted=Accounted in ledger Accounted=Accounted in ledger
NotYetAccounted=Not yet accounted in the ledger NotYetAccounted=Not yet transferred to accounting
ShowTutorial=Show Tutorial ShowTutorial=Show Tutorial
NotReconciled=Not reconciled NotReconciled=Not reconciled
WarningRecordWithoutSubledgerAreExcluded=Warning, all operations without subledger account defined are filtered and excluded from this view WarningRecordWithoutSubledgerAreExcluded=Warning, all operations without subledger account defined are filtered and excluded from this view
@ -329,8 +329,8 @@ ACCOUNTING_DISABLE_BINDING_ON_PURCHASES=Disable binding & transfer in accountanc
ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS=Disable binding & transfer in accountancy on expense reports (expense reports will not be taken into account in accounting) ACCOUNTING_DISABLE_BINDING_ON_EXPENSEREPORTS=Disable binding & transfer in accountancy on expense reports (expense reports will not be taken into account in accounting)
## Export ## Export
NotifiedExportDate=Notified export date (modification of the entries will not be possible) NotifiedExportDate=Flag exported lines as exported (modification of the lines will not be possible)
NotifiedValidationDate=Validation of the entries (modification or deletion of the entries will not be possible) NotifiedValidationDate=Validate the exported entries (modification or deletion of the lines will not be possible)
ConfirmExportFile=Confirmation of the generation of the accounting export file ? ConfirmExportFile=Confirmation of the generation of the accounting export file ?
ExportDraftJournal=Export draft journal ExportDraftJournal=Export draft journal
Modelcsv=Model of export Modelcsv=Model of export

View File

@ -898,6 +898,11 @@ Permission1002=Create/modify warehouses
Permission1003=Delete warehouses Permission1003=Delete warehouses
Permission1004=Read stock movements Permission1004=Read stock movements
Permission1005=Create/modify stock movements Permission1005=Create/modify stock movements
Permission1011=View inventories
Permission1012=Create new inventory
Permission1014=Validate inventory
Permission1015=Allow to change PMP value for a product
Permission1016=Delete inventory
Permission1101=Read delivery receipts Permission1101=Read delivery receipts
Permission1102=Create/modify delivery receipts Permission1102=Create/modify delivery receipts
Permission1104=Validate delivery receipts Permission1104=Validate delivery receipts

View File

@ -45,3 +45,5 @@ GenerateImgWebp=Duplicate all images with another version with .webp format
ConfirmGenerateImgWebp=If you confirm, you will generate an image in .webp format for all images currently into this folder (subfolders are not included)... ConfirmGenerateImgWebp=If you confirm, you will generate an image in .webp format for all images currently into this folder (subfolders are not included)...
ConfirmImgWebpCreation=Confirm all images duplication ConfirmImgWebpCreation=Confirm all images duplication
SucessConvertImgWebp=Images successfully duplicated SucessConvertImgWebp=Images successfully duplicated
ECMDirName=Dir name
ECMParentDirectory=Parent directory

View File

@ -19,7 +19,7 @@
# #
ModuleEventOrganizationName = Event Organization ModuleEventOrganizationName = Event Organization
EventOrganizationDescription = Event Organization through Module Project EventOrganizationDescription = Event Organization through Module Project
EventOrganizationDescriptionLong= Manage the organization of an event (conferences, attendees, speakers, with public suggestion, vote or registration pages) EventOrganizationDescriptionLong= Manage the organization of an event (show, conferences, attendees or speakers, with public pages for suggestion, vote or registration)
# #
# Menu # Menu
# #

View File

@ -401,5 +401,11 @@ DeleteLinkedProduct=Delete the child product linked to the combination
AmountUsedToUpdateWAP=Amount to use to update the Weighted Average Price AmountUsedToUpdateWAP=Amount to use to update the Weighted Average Price
PMPValue=Weighted average price PMPValue=Weighted average price
PMPValueShort=WAP PMPValueShort=WAP
mandatoryperiod=Mandatory periods
mandatoryPeriodNeedTobeSet=Attention periods not entered and mandatory
mandatoryPeriodNeedTobeSetMsgValidate=A service requires a start and end period
mandatoryHelper=Message to the user on the need to enter a start date and an end date on a service when creating / validating an invoice, commercial proposal, sales order. <br> This action is not blocking in the process of confirmation
DefaultBOM=Default BOM DefaultBOM=Default BOM
DefaultBOMDesc=The default BOM recommended to use to manufacture this product. This field can be set only if nature of product is '%s'. DefaultBOMDesc=The default BOM recommended to use to manufacture this product. This field can be set only if nature of product is '%s'.

View File

@ -45,3 +45,5 @@ GenerateImgWebp=Dupliquer toutes les images avec une autre version au format .we
ConfirmGenerateImgWebp=Si vous confirmez, vous générerez une image au format .webp pour toutes les images actuellement dans ce dossier (les sous-dossiers ne sont pas inclus)... ConfirmGenerateImgWebp=Si vous confirmez, vous générerez une image au format .webp pour toutes les images actuellement dans ce dossier (les sous-dossiers ne sont pas inclus)...
ConfirmImgWebpCreation=Confirmer la duplication de toutes les images ConfirmImgWebpCreation=Confirmer la duplication de toutes les images
SucessConvertImgWebp=Images dupliquées avec succès SucessConvertImgWebp=Images dupliquées avec succès
ECMDirName=Nom du dossier
ECMParentDirectory=Dossier parent

View File

@ -399,3 +399,7 @@ ProductSupplierExtraFields=Attributs supplémentaires (Prix fournisseur)
DeleteLinkedProduct=Supprimer le produit enfant lié à la combinaison DeleteLinkedProduct=Supprimer le produit enfant lié à la combinaison
PMPValue=Prix moyen pondéré (PMP) PMPValue=Prix moyen pondéré (PMP)
PMPValueShort=PMP PMPValueShort=PMP
mandatoryperiod=Périodes obligatoires
mandatoryPeriodNeedTobeSet=Attention périodes non saisies et obligatoires
mandatoryPeriodNeedTobeSetMsgValidate=Un service nécessite une période de début et de fin
mandatoryHelper=Message à l'utilisateur sur la necessité de saisir une date de début et une date de fin sur un service lors de la création/validation de facture, proposition commerciale , commande client.<br>Cette action n'est pas bloquante dans le processus de validation

View File

@ -91,7 +91,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) {
$outtype = $object->type; $outtype = $object->type;
$outqty = 1; $outqty = 1;
$outdiscount = 0; $outdiscount = 0;
$mandatory_period = $object->mandatory_period;
$found = false; $found = false;
$price_level = 1; $price_level = 1;
@ -203,6 +203,7 @@ if (!empty($action) && $action == 'fetch' && !empty($id)) {
'tva_tx' => $outtva_tx, 'tva_tx' => $outtva_tx,
'qty' => $outqty, 'qty' => $outqty,
'discount' => $outdiscount, 'discount' => $outdiscount,
'mandatory_period' => $mandatory_period,
'array_options'=>$object->array_options); 'array_options'=>$object->array_options);
} }

View File

@ -105,6 +105,7 @@ $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
$accountancy_code_buy_intra = GETPOST('accountancy_code_buy_intra', 'alpha'); $accountancy_code_buy_intra = GETPOST('accountancy_code_buy_intra', 'alpha');
$accountancy_code_buy_export = GETPOST('accountancy_code_buy_export', 'alpha'); $accountancy_code_buy_export = GETPOST('accountancy_code_buy_export', 'alpha');
$checkmandatory = GETPOST('accountancy_code_buy_export', 'alpha');
// by default 'alphanohtml' (better security); hidden conf MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML allows basic html // by default 'alphanohtml' (better security); hidden conf MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML allows basic html
$label_security_check = empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML) ? 'alphanohtml' : 'restricthtml'; $label_security_check = empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML) ? 'alphanohtml' : 'restricthtml';
@ -131,7 +132,9 @@ $extrafields->fetch_name_optionals_label($object->table_element);
if ($id > 0 || !empty($ref)) { if ($id > 0 || !empty($ref)) {
$result = $object->fetch($id, $ref); $result = $object->fetch($id, $ref);
if ($result < 0) {
dol_print_error($db, $object->error, $object->errors);
}
if (!empty($conf->product->enabled)) { if (!empty($conf->product->enabled)) {
$upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref);
} elseif (!empty($conf->service->enabled)) { } elseif (!empty($conf->service->enabled)) {
@ -298,7 +301,7 @@ if (empty($reshook)) {
$object->ref = $ref; $object->ref = $ref;
$object->label = GETPOST('label', $label_security_check); $object->label = GETPOST('label', $label_security_check);
$object->price_base_type = GETPOST('price_base_type', 'aZ09'); $object->price_base_type = GETPOST('price_base_type', 'aZ09');
$object->mandatory_period = !empty(GETPOST("mandatoryperiod", 'alpha')) ? 1 : 0;
if ($object->price_base_type == 'TTC') { if ($object->price_base_type == 'TTC') {
$object->price_ttc = GETPOST('price'); $object->price_ttc = GETPOST('price');
} else { } else {
@ -599,7 +602,7 @@ if (empty($reshook)) {
$accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha'); $accountancy_code_buy = GETPOST('accountancy_code_buy', 'alpha');
$accountancy_code_buy_intra = GETPOST('accountancy_code_buy_intra', 'alpha'); $accountancy_code_buy_intra = GETPOST('accountancy_code_buy_intra', 'alpha');
$accountancy_code_buy_export = GETPOST('accountancy_code_buy_export', 'alpha'); $accountancy_code_buy_export = GETPOST('accountancy_code_buy_export', 'alpha');
$checkmandatory = GETPOST('mandatoryperiod', 'alpha');
if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') { if (empty($accountancy_code_sell) || $accountancy_code_sell == '-1') {
$object->accountancy_code_sell = ''; $object->accountancy_code_sell = '';
} else { } else {
@ -630,6 +633,11 @@ if (empty($reshook)) {
} else { } else {
$object->accountancy_code_buy_export = $accountancy_code_buy_export; $object->accountancy_code_buy_export = $accountancy_code_buy_export;
} }
if ($object->isService()) {
$object->mandatory_period = (!empty($checkmandatory)) ? 1 : 0 ;
}
// Fill array 'array_options' with data from add form // Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object); $ret = $extrafields->setOptionalsFromPost(null, $object);
@ -1284,6 +1292,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '<tr><td>'.$langs->trans("Duration").'</td><td>'; print '<tr><td>'.$langs->trans("Duration").'</td><td>';
print '<input name="duration_value" size="4" value="'.GETPOST('duration_value', 'int').'">'; print '<input name="duration_value" size="4" value="'.GETPOST('duration_value', 'int').'">';
print $formproduct->selectMeasuringUnits("duration_unit", "time", (GETPOSTISSET('duration_value') ? GETPOSTISSET('duration_value', 'alpha') : 'h'), 0, 1); print $formproduct->selectMeasuringUnits("duration_unit", "time", (GETPOSTISSET('duration_value') ? GETPOSTISSET('duration_value', 'alpha') : 'h'), 0, 1);
// Mandatory period
print ' &nbsp; &nbsp; &nbsp; ';
print '<input type="checkbox" id="mandatoryperiod" name="mandatoryperiod"'.($object->mandatory_period == 1 ? ' checked="checked"' : '').'>';
print '<label for="mandatoryperiod">';
$htmltooltip = $langs->trans("mandatoryHelper");
print $form->textwithpicto($langs->trans("mandatoryperiod"), $htmltooltip, 1, 0);
print '</label>';
print '</td></tr>'; print '</td></tr>';
} }
@ -1423,6 +1440,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
$defaultva = get_default_tva($mysoc, $mysoc); $defaultva = get_default_tva($mysoc, $mysoc);
print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1); print $form->load_tva("tva_tx", $defaultva, $mysoc, $mysoc, 0, 0, '', false, 1);
print '</td></tr>'; print '</td></tr>';
print '</table>'; print '</table>';
print '<br>'; print '<br>';
@ -1820,6 +1838,15 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '<tr><td>'.$langs->trans("Duration").'</td><td>'; print '<tr><td>'.$langs->trans("Duration").'</td><td>';
print '<input name="duration_value" size="5" value="'.$object->duration_value.'"> '; print '<input name="duration_value" size="5" value="'.$object->duration_value.'"> ';
print $formproduct->selectMeasuringUnits("duration_unit", "time", $object->duration_unit, 0, 1); print $formproduct->selectMeasuringUnits("duration_unit", "time", $object->duration_unit, 0, 1);
// Mandatory period
print ' &nbsp; &nbsp; &nbsp; ';
print '<input type="checkbox" id="mandatoryperiod" name="mandatoryperiod"'.($object->mandatory_period == 1 ? ' checked="checked"' : '').'>';
print '<label for="mandatoryperiod">';
$htmltooltip = $langs->trans("mandatoryHelper");
print $form->textwithpicto($langs->trans("mandatoryperiod"), $htmltooltip, 1, 0);
print '</label>';
print '</td></tr>'; print '</td></tr>';
} else { } else {
if (empty($conf->global->PRODUCT_DISABLE_NATURE)) { if (empty($conf->global->PRODUCT_DISABLE_NATURE)) {
@ -2301,13 +2328,22 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
if ($object->isService()) { if ($object->isService()) {
// Duration // Duration
print '<tr><td class="titlefield">'.$langs->trans("Duration").'</td><td>'.$object->duration_value.'&nbsp;'; print '<tr><td class="titlefield">'.$langs->trans("Duration").'</td><td>';
print $object->duration_value;
if ($object->duration_value > 1) { if ($object->duration_value > 1) {
$dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years")); $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hours"), "d"=>$langs->trans("Days"), "w"=>$langs->trans("Weeks"), "m"=>$langs->trans("Months"), "y"=>$langs->trans("Years"));
} elseif ($object->duration_value > 0) { } elseif ($object->duration_value > 0) {
$dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year")); $dur = array("i"=>$langs->trans("Minute"), "h"=>$langs->trans("Hour"), "d"=>$langs->trans("Day"), "w"=>$langs->trans("Week"), "m"=>$langs->trans("Month"), "y"=>$langs->trans("Year"));
} }
print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')."&nbsp;"; print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? "&nbsp;".$langs->trans($dur[$object->duration_unit])."&nbsp;" : '');
// Mandatory period
if ($object->duration_value > 0) {
print ' &nbsp; &nbsp; &nbsp; ';
}
$htmltooltip = $langs->trans("mandatoryHelper");
print '<input type="checkbox" class="" name="mandatoryperiod"'.($object->mandatory_period == 1 ? ' checked="checked"' : '').' disabled>';
print $form->textwithpicto($langs->trans("mandatoryperiod"), $htmltooltip, 1, 0);
print '</td></tr>'; print '</td></tr>';
} else { } else {
@ -2538,8 +2574,9 @@ if ($action != 'create' && $action != 'edit') {
print "\n</div>\n"; print "\n</div>\n";
} }
/* /*
* All the "Add to" areas * All the "Add to" areas if PRODUCT_ADD_FORM_ADD_TO is set
*/ */
if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == '' || $action == 'view') && $object->status) { if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action == '' || $action == 'view') && $object->status) {

View File

@ -434,6 +434,13 @@ class Product extends CommonObject
public $is_object_used; public $is_object_used;
/**
*
*
*
*/
public $mandatory_period;
/** /**
* 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password') * 'type' if the field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]', 'varchar(x)', 'double(24,8)', 'real', 'price', 'text', 'html', 'date', 'datetime', 'timestamp', 'duration', 'mail', 'phone', 'url', 'password')
* Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)" * Note: Filter can be a string like "(t.ref:like:'SO-%') or (t.date_creation:<:'20160101') or (t.nature:is:NULL)"
@ -484,6 +491,8 @@ class Product extends CommonObject
'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000),
//'tosell' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), //'tosell' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')),
//'tobuy' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')), //'tobuy' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Draft', 1=>'Active', -1=>'Cancel')),
'mandatory_period' =>array('type'=>'integer', 'label'=>'mandatory_period', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'default'=>0, 'index'=>1, 'position'=>1000),
); );
/** /**
@ -635,7 +644,7 @@ class Product extends CommonObject
// Barcode value // Barcode value
$this->barcode = trim($this->barcode); $this->barcode = trim($this->barcode);
$this->mandatory_period = empty($this->mandatory_period) ? 0 : $this->mandatory_period;
// Check parameters // Check parameters
if (empty($this->label)) { if (empty($this->label)) {
$this->error = 'ErrorMandatoryParametersNotProvided'; $this->error = 'ErrorMandatoryParametersNotProvided';
@ -717,6 +726,7 @@ class Product extends CommonObject
$sql .= ", tobatch"; $sql .= ", tobatch";
$sql .= ", batch_mask"; $sql .= ", batch_mask";
$sql .= ", fk_unit"; $sql .= ", fk_unit";
$sql .= ", mandatory_period";
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= "'".$this->db->idate($now)."'"; $sql .= "'".$this->db->idate($now)."'";
$sql .= ", ".((int) $conf->entity); $sql .= ", ".((int) $conf->entity);
@ -745,6 +755,7 @@ class Product extends CommonObject
$sql .= ", ".((empty($this->status_batch) || $this->status_batch < 0) ? '0' : ((int) $this->status_batch)); $sql .= ", ".((empty($this->status_batch) || $this->status_batch < 0) ? '0' : ((int) $this->status_batch));
$sql .= ", '".$this->db->escape($this->batch_mask)."'"; $sql .= ", '".$this->db->escape($this->batch_mask)."'";
$sql .= ", ".($this->fk_unit > 0 ? ((int) $this->fk_unit) : 'NULL'); $sql .= ", ".($this->fk_unit > 0 ? ((int) $this->fk_unit) : 'NULL');
$sql .= ", '".$this->db->escape($this->mandatory_period)."'";
$sql .= ")"; $sql .= ")";
dol_syslog(get_class($this)."::Create", LOG_DEBUG); dol_syslog(get_class($this)."::Create", LOG_DEBUG);
@ -1016,7 +1027,6 @@ class Product extends CommonObject
$this->accountancy_code_sell_export = trim($this->accountancy_code_sell_export); $this->accountancy_code_sell_export = trim($this->accountancy_code_sell_export);
$this->db->begin(); $this->db->begin();
$result = 0; $result = 0;
@ -1150,7 +1160,7 @@ class Product extends CommonObject
$sql .= ", price_autogen = ".(!$this->price_autogen ? 0 : 1); $sql .= ", price_autogen = ".(!$this->price_autogen ? 0 : 1);
$sql .= ", fk_price_expression = ".($this->fk_price_expression != 0 ? (int) $this->fk_price_expression : 'NULL'); $sql .= ", fk_price_expression = ".($this->fk_price_expression != 0 ? (int) $this->fk_price_expression : 'NULL');
$sql .= ", fk_user_modif = ".($user->id > 0 ? $user->id : 'NULL'); $sql .= ", fk_user_modif = ".($user->id > 0 ? $user->id : 'NULL');
$sql .= ", mandatory_period = ".($this->mandatory_period );
// stock field is not here because it is a denormalized value from product_stock. // stock field is not here because it is a denormalized value from product_stock.
$sql .= " WHERE rowid = ".((int) $id); $sql .= " WHERE rowid = ".((int) $id);
@ -2253,7 +2263,7 @@ class Product extends CommonObject
$sql .= " p.price_min, p.price_min_ttc, p.price_base_type, p.cost_price, p.default_vat_code, p.tva_tx, p.recuperableonly as tva_npr, p.localtax1_tx, p.localtax2_tx, p.localtax1_type, p.localtax2_type, p.tosell,"; $sql .= " p.price_min, p.price_min_ttc, p.price_base_type, p.cost_price, p.default_vat_code, p.tva_tx, p.recuperableonly as tva_npr, p.localtax1_tx, p.localtax2_tx, p.localtax1_type, p.localtax2_type, p.tosell,";
$sql .= " p.tobuy, p.fk_product_type, p.duration, p.fk_default_warehouse, p.seuil_stock_alerte, p.canvas, p.net_measure, p.net_measure_units, p.weight, p.weight_units,"; $sql .= " p.tobuy, p.fk_product_type, p.duration, p.fk_default_warehouse, p.seuil_stock_alerte, p.canvas, p.net_measure, p.net_measure_units, p.weight, p.weight_units,";
$sql .= " p.length, p.length_units, p.width, p.width_units, p.height, p.height_units,"; $sql .= " p.length, p.length_units, p.width, p.width_units, p.height, p.height_units,";
$sql .= " p.surface, p.surface_units, p.volume, p.volume_units, p.barcode, p.fk_barcode_type, p.finished, p.fk_default_bom,"; $sql .= " p.surface, p.surface_units, p.volume, p.volume_units, p.barcode, p.fk_barcode_type, p.finished, p.fk_default_bom, p.mandatory_period,";
if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) {
$sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,"; $sql .= " p.accountancy_code_buy, p.accountancy_code_buy_intra, p.accountancy_code_buy_export, p.accountancy_code_sell, p.accountancy_code_sell_intra, p.accountancy_code_sell_export,";
} else { } else {
@ -2428,6 +2438,8 @@ class Product extends CommonObject
$this->price_autogen = $obj->price_autogen; $this->price_autogen = $obj->price_autogen;
$this->model_pdf = $obj->model_pdf; $this->model_pdf = $obj->model_pdf;
$this->mandatory_period = $obj->mandatory_period;
$this->db->free($resql); $this->db->free($resql);
// fetch optionals attributes and labels // fetch optionals attributes and labels
@ -5643,6 +5655,16 @@ class Product extends CommonObject
return ($this->type == Product::TYPE_SERVICE ? true : false); return ($this->type == Product::TYPE_SERVICE ? true : false);
} }
/**
* Return if object have a constraint on mandatory_period
*
* @return boolean True if mandatory_period setted to 1
*/
public function isMandatoryPeriod()
{
return ($this->mandatory_period == 1 ? true : false);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Get a barcode from the module to generate barcode values. * Get a barcode from the module to generate barcode values.

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2021 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
@ -54,7 +54,9 @@ $cancel = GETPOST('cancel', 'alpha');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'pricesuppliercard'; $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'pricesuppliercard';
$socid = GETPOST('socid', 'int'); $socid = GETPOST('socid', 'int');
$cost_price = GETPOST('cost_price', 'alpha'); $cost_price = price2num(GETPOST('cost_price', 'alpha'), '', 2);
$pmp = price2num(GETPOST('pmp', 'alpha'), '', 2);
$backtopage = GETPOST('backtopage', 'alpha'); $backtopage = GETPOST('backtopage', 'alpha');
$error = 0; $error = 0;
@ -147,13 +149,29 @@ if (empty($reshook)) {
} }
} }
} }
if ($action == 'setpmp') {
if ($id) {
$result = $object->fetch($id);
$object->pmp = price2num($pmp);
$sql = "UPDATE ".MAIN_DB_PREFIX."product SET pmp = ".((float) $object->pmp)." WHERE rowid = ".((int) $id);
$resql = $db->query($sql);
//$result = $object->update($object->id, $user);
if ($resql) {
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
$action = '';
} else {
$error++;
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
if ($action == 'confirm_remove_pf') { if ($action == 'confirm_remove_pf') {
if ($rowid) { // id of product supplier price to remove if ($rowid) { // id of product supplier price to remove
$action = ''; $action = '';
$result = $object->remove_product_fournisseur_price($rowid); $result = $object->remove_product_fournisseur_price($rowid);
if ($result > 0) { if ($result > 0) {
$db->query("DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields WHERE fk_object = $rowid"); $db->query("DELETE FROM ".MAIN_DB_PREFIX."product_fournisseur_price_extrafields WHERE fk_object = ".((int) $rowid));
setEventMessages($langs->trans("PriceRemoved"), null, 'mesgs'); setEventMessages($langs->trans("PriceRemoved"), null, 'mesgs');
} else { } else {
$error++; $error++;
@ -425,11 +443,25 @@ if ($id > 0 || $ref) {
print '</td></tr>'; print '</td></tr>';
// PMP // PMP
print '<tr><td class="titlefieldcreate">'.$form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")).'</td>'; $usercaneditpmp = 0;
if (!empty($conf->global->PRODUCT_CAN_EDIT_WAP)) {
$usercaneditpmp = $usercancreate;
}
print '<tr><td class="titlefieldcreate">';
$textdesc = $langs->trans("AverageUnitPricePMPDesc");
$text = $form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $textdesc, 1, 'help', '');
print $form->editfieldkey($text, 'pmp', $object->pmp, $object, $usercaneditpmp, 'amount:6');
print '</td><td>';
print $form->editfieldval($text, 'pmp', ($object->pmp > 0 ? $object->pmp : ''), $object, $usercaneditpmp, 'amount:6');
if ($object->pmp > 0) {
print ' '.$langs->trans("HT");
}
/*
.$form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")).'</td>';
print '<td>'; print '<td>';
if ($object->pmp > 0) { if ($object->pmp > 0) {
print price($object->pmp).' '.$langs->trans("HT"); print price($object->pmp).' '.$langs->trans("HT");
} }*/
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';

View File

@ -814,7 +814,7 @@ class Project extends CommonObject
'propal'=>'fk_projet', 'commande'=>'fk_projet', 'facture'=>'fk_projet', 'propal'=>'fk_projet', 'commande'=>'fk_projet', 'facture'=>'fk_projet',
'supplier_proposal'=>'fk_projet', 'commande_fournisseur'=>'fk_projet', 'facture_fourn'=>'fk_projet', 'supplier_proposal'=>'fk_projet', 'commande_fournisseur'=>'fk_projet', 'facture_fourn'=>'fk_projet',
'expensereport_det'=>'fk_projet', 'contrat'=>'fk_projet', 'fichinter'=>'fk_projet', 'don'=>'fk_projet', 'expensereport_det'=>'fk_projet', 'contrat'=>'fk_projet', 'fichinter'=>'fk_projet', 'don'=>'fk_projet',
'actioncomm'=>'fk_project', 'mrp_mo'=>'fk_project' 'actioncomm'=>'fk_project', 'mrp_mo'=>'fk_project', 'entrepot'=>'fk_project'
); );
foreach ($listoftables as $key => $value) { foreach ($listoftables as $key => $value) {
$sql = "UPDATE ".MAIN_DB_PREFIX.$key." SET ".$value." = NULL where ".$value." = ".((int) $this->id); $sql = "UPDATE ".MAIN_DB_PREFIX.$key." SET ".$value." = NULL where ".$value." = ".((int) $this->id);

View File

@ -181,8 +181,8 @@ class Task extends CommonObject
$sql .= ", '".$this->db->escape($this->description)."'"; $sql .= ", '".$this->db->escape($this->description)."'";
$sql .= ", '".$this->db->idate($now)."'"; $sql .= ", '".$this->db->idate($now)."'";
$sql .= ", ".((int) $user->id); $sql .= ", ".((int) $user->id);
$sql .= ", ".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : 'null'); $sql .= ", ".($this->date_start ? "'".$this->db->idate($this->date_start)."'" : 'null');
$sql .= ", ".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : 'null'); $sql .= ", ".($this->date_end ? "'".$this->db->idate($this->date_end)."'" : 'null');
$sql .= ", ".(($this->planned_workload != '' && $this->planned_workload >= 0) ? ((int) $this->planned_workload) : 'null'); $sql .= ", ".(($this->planned_workload != '' && $this->planned_workload >= 0) ? ((int) $this->planned_workload) : 'null');
$sql .= ", ".(($this->progress != '' && $this->progress >= 0) ? ((int) $this->progress) : 'null'); $sql .= ", ".(($this->progress != '' && $this->progress >= 0) ? ((int) $this->progress) : 'null');
$sql .= ")"; $sql .= ")";

View File

@ -36,6 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
if (!empty($conf->stock->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
}
if (!empty($conf->propal->enabled)) { if (!empty($conf->propal->enabled)) {
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
} }

View File

@ -89,6 +89,7 @@ if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/', $c
$title = ($object->ref ? $object->ref.' '.$object->name.' - ' : '').$langs->trans("Gantt"); $title = ($object->ref ? $object->ref.' '.$object->name.' - ' : '').$langs->trans("Gantt");
} }
$help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos"; $help_url = "EN:Module_Projects|FR:Module_Projets|ES:M&oacute;dulo_Proyectos";
llxHeader("", $title, $help_url, '', 0, 0, $arrayofjs, $arrayofcss); llxHeader("", $title, $help_url, '', 0, 0, $arrayofjs, $arrayofcss);
if (($id > 0 && is_numeric($id)) || !empty($ref)) { if (($id > 0 && is_numeric($id)) || !empty($ref)) {
@ -136,29 +137,36 @@ if (($id > 0 && is_numeric($id)) || !empty($ref)) {
print '<table class="border tableforfield centpercent">'; print '<table class="border tableforfield centpercent">';
// Usage // Usage
print '<tr><td class="tdtop">'; if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) {
print $langs->trans("Usage"); print '<tr><td class="tdtop">';
print '</td>'; print $langs->trans("Usage");
print '<td>'; print '</td>';
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) { print '<td>';
print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> '; if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
$htmltext = $langs->trans("ProjectFollowOpportunity"); print '<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET('usage_opportunity') ? (GETPOST('usage_opportunity', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_opportunity ? ' checked="checked"' : '')).'"> ';
print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext); $htmltext = $langs->trans("ProjectFollowOpportunity");
print '<br>'; print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
print '<br>';
}
if (empty($conf->global->PROJECT_HIDE_TASKS)) {
print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectFollowTasks");
print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
print '<br>';
}
if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectBillTimeDescription");
print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
print '<br>';
}
if (!empty($conf->eventorganization->enabled)) {
print '<input type="checkbox" disabled name="usage_organize_event"'.(GETPOSTISSET('usage_organize_event') ? (GETPOST('usage_organize_event', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_organize_event ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("EventOrganizationDescriptionLong");
print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext);
}
print '</td></tr>';
} }
if (empty($conf->global->PROJECT_HIDE_TASKS)) {
print '<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET('usage_task') ? (GETPOST('usage_task', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_task ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectFollowTasks");
print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext);
print '<br>';
}
if (!empty($conf->global->PROJECT_BILL_TIME_SPENT)) {
print '<input type="checkbox" disabled name="usage_bill_time"'.(GETPOSTISSET('usage_bill_time') ? (GETPOST('usage_bill_time', 'alpha') != '' ? ' checked="checked"' : '') : ($object->usage_bill_time ? ' checked="checked"' : '')).'"> ';
$htmltext = $langs->trans("ProjectBillTimeDescription");
print $form->textwithpicto($langs->trans("BillTime"), $htmltext);
print '<br>';
}
print '</td></tr>';
// Visibility // Visibility
print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>'; print '<tr><td class="titlefield">'.$langs->trans("Visibility").'</td><td>';

View File

@ -555,7 +555,7 @@ if ($id > 0 || !empty($ref)) {
print '<div class="fichehalfleft">'; print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">'; print '<table class="border tableforfield centpercent">';
// Usage // Usage
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) { if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) {
@ -628,7 +628,7 @@ if ($id > 0 || !empty($ref)) {
print '<div class="ficheaddleft">'; print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>'; print '<div class="underbanner clearboth"></div>';
print '<table class="border tableforfield" width="100%">'; print '<table class="border tableforfield centpercent">';
// Description // Description
print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>'; print '<td class="titlefield tdtop">'.$langs->trans("Description").'</td><td>';
@ -637,7 +637,7 @@ if ($id > 0 || !empty($ref)) {
// Categories // Categories
if ($conf->categorie->enabled) { if ($conf->categorie->enabled) {
print '<tr><td valign="middle">'.$langs->trans("Categories").'</td><td>'; print '<tr><td class="valignmiddle">'.$langs->trans("Categories").'</td><td>';
print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1); print $form->showCategories($object->id, Categorie::TYPE_PROJECT, 1);
print "</td></tr>"; print "</td></tr>";
} }

View File

@ -1349,7 +1349,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0) {
$nboftasks = 0; $nboftasks = 0;
if (empty($id)) { if (empty($id)) {
print '<td class="maxwidthonsmartphone">'; print '<td class="maxwidthonsmartphone">';
$nboftasks = $formproject->selectTasks(-1, GETPOST('taskid', 'int'), 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, ''); $nboftasks = $formproject->selectTasks(-1, GETPOST('taskid', 'int'), 'taskid', 0, 0, 1, 1, 0, 0, 'maxwidth300', $projectstatic->id, 'progress');
print '</td>'; print '</td>';
} }

View File

@ -330,63 +330,63 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
$thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithNameContactUs", $mysoc->email); $thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
} }
} }
if ($resultfetchthirdparty <= 0 && !empty($emailcompany)) { }
// Try to find thirdparty from the email only if ($resultfetchthirdparty <= 0 && !empty($emailcompany)) {
$resultfetchthirdparty = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $emailcompany); // Try to find thirdparty from the email only
if ($resultfetchthirdparty > 0) { $resultfetchthirdparty = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $emailcompany);
// We found a unique result with that email only, so we set the fk_soc of attendee if ($resultfetchthirdparty > 0) {
$confattendee->fk_soc = $thirdparty->id; // We found a unique result with that email only, so we set the fk_soc of attendee
$confattendee->update($user); $confattendee->fk_soc = $thirdparty->id;
} elseif ($resultfetchthirdparty == -2) { $confattendee->update($user);
$thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email); } elseif ($resultfetchthirdparty == -2) {
} $thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
} }
if ($resultfetchthirdparty <= 0 && !empty($email) && $email != $emailcompany) { }
// Try to find thirdparty from the email only if ($resultfetchthirdparty <= 0 && !empty($email) && $email != $emailcompany) {
$resultfetchthirdparty = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email); // Try to find thirdparty from the email only
if ($resultfetchthirdparty > 0) { $resultfetchthirdparty = $thirdparty->fetch('', '', '', '', '', '', '', '', '', '', $email);
// We found a unique result with that email only, so we set the fk_soc of attendee if ($resultfetchthirdparty > 0) {
$confattendee->fk_soc = $thirdparty->id; // We found a unique result with that email only, so we set the fk_soc of attendee
$confattendee->update($user); $confattendee->fk_soc = $thirdparty->id;
} elseif ($resultfetchthirdparty == -2) { $confattendee->update($user);
$thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email); } elseif ($resultfetchthirdparty == -2) {
} $thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithEmailContactUs", $mysoc->email);
} }
if ($resultfetchthirdparty <= 0 && !empty($genericcompanyname)) { }
// Try to find thirdparty from the generic mail only if ($resultfetchthirdparty <= 0 && !empty($genericcompanyname)) {
$resultfetchthirdparty = $thirdparty->fetch('', $genericcompanyname, '', '', '', '', '', '', '', '', ''); // Try to find thirdparty from the generic mail only
if ($resultfetchthirdparty > 0) { $resultfetchthirdparty = $thirdparty->fetch('', $genericcompanyname, '', '', '', '', '', '', '', '', '');
// We found a unique result with that name + email, so we set the fk_soc of attendee if ($resultfetchthirdparty > 0) {
$confattendee->fk_soc = $thirdparty->id; // We found a unique result with that name + email, so we set the fk_soc of attendee
$confattendee->update($user); $confattendee->fk_soc = $thirdparty->id;
} elseif ($resultfetchthirdparty == -2) { $confattendee->update($user);
$thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithNameContactUs", $mysoc->email); } elseif ($resultfetchthirdparty == -2) {
} $thirdparty->error = $langs->trans("ErrorSeveralCompaniesWithNameContactUs", $mysoc->email);
} }
}
// TODO Add more tests on a VAT number, profid or a name ? // TODO Add more tests on a VAT number, profid or a name ?
if ($resultfetchthirdparty <= 0 && !empty($email)) { if ($resultfetchthirdparty <= 0 && !empty($email)) {
// Try to find the thirdparty from the contact // Try to find the thirdparty from the contact
$resultfetchcontact = $contact->fetch('', null, '', $email); $resultfetchcontact = $contact->fetch('', null, '', $email);
if ($resultfetchcontact > 0 && $contact->fk_soc > 0) { if ($resultfetchcontact > 0 && $contact->fk_soc > 0) {
$thirdparty->fetch($contact->fk_soc); $thirdparty->fetch($contact->fk_soc);
$confattendee->fk_soc = $thirdparty->id; $confattendee->fk_soc = $thirdparty->id;
$confattendee->update($user); $confattendee->update($user);
$resultfetchthirdparty = 1; $resultfetchthirdparty = 1;
}
} }
}
if ($resultfetchthirdparty <= 0 && !empty($societe)) { if ($resultfetchthirdparty <= 0 && !empty($societe)) {
// Try to find thirdparty from the company name only // Try to find thirdparty from the company name only
$resultfetchthirdparty = $thirdparty->fetch('', $societe, '', '', '', '', '', '', '', '', ''); $resultfetchthirdparty = $thirdparty->fetch('', $societe, '', '', '', '', '', '', '', '', '');
if ($resultfetchthirdparty > 0) { if ($resultfetchthirdparty > 0) {
// We found a unique result with that name only, so we set the fk_soc of attendee // We found a unique result with that name only, so we set the fk_soc of attendee
$confattendee->fk_soc = $thirdparty->id; $confattendee->fk_soc = $thirdparty->id;
$confattendee->update($user); $confattendee->update($user);
} elseif ($resultfetchthirdparty == -2) { } elseif ($resultfetchthirdparty == -2) {
$thirdparty->error = "ErrorSeveralCompaniesWithNameContactUs"; $thirdparty->error = "ErrorSeveralCompaniesWithNameContactUs";
}
} }
} }
} }
@ -450,6 +450,7 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
} }
if (!$error) { if (!$error) {
// If the registration needs a payment
if (!empty(floatval($project->price_registration))) { if (!empty(floatval($project->price_registration))) {
$outputlangs = $langs; $outputlangs = $langs;
@ -515,11 +516,14 @@ if (empty($reshook) && $action == 'add' && (!empty($conference->id) && $conferen
$date_start = $project->date_start; $date_start = $project->date_start;
$date_end = $project->date_end; $date_end = $project->date_end;
$result = $facture->addline($labelforproduct, floatval($project->price_registration), 1, $vattouse, 0, 0, $productforinvoicerow->id, 0, $date_start, $date_end, 0, 0, '', 'HT', 0, 1); // If there is no lines yet, we add one
if ($result <= 0) { if (empty($facture->lines)) {
$confattendee->error = $facture->error; $result = $facture->addline($labelforproduct, floatval($project->price_registration), 1, $vattouse, 0, 0, $productforinvoicerow->id, 0, $date_start, $date_end, 0, 0, '', 'HT', 0, 1);
$confattendee->errors = $facture->errors; if ($result <= 0) {
$error++; $confattendee->error = $facture->error;
$confattendee->errors = $facture->errors;
$error++;
}
} }
} }

View File

@ -371,7 +371,7 @@ if ($search_supervisor > 0) {
if ($search_thirdparty != '') { if ($search_thirdparty != '') {
$sql .= natural_search(array('s.nom'), $search_thirdparty); $sql .= natural_search(array('s.nom'), $search_thirdparty);
} }
if ($search_warehouse != '') { if ($search_warehouse > 0) {
$sql .= natural_search(array('u.fk_warehouse'), $search_warehouse); $sql .= natural_search(array('u.fk_warehouse'), $search_warehouse);
} }
if ($search_login != '') { if ($search_login != '') {