Merge remote-tracking branch 'upstream/develop' into fix/warnings

This commit is contained in:
Frédéric FRANCE 2022-10-13 10:32:48 +02:00
commit 509d92f63d
19 changed files with 291 additions and 156 deletions

View File

@ -5526,12 +5526,20 @@ class Facture extends CommonInvoice
$sendContent = make_substitutions($content, $substitutionarray, $outputlangs, 1);
// Recipient
$to = '';
$to = array();
$res = $tmpinvoice->fetch_thirdparty();
$recipient = $tmpinvoice->thirdparty;
if ($res > 0) {
if (!empty($recipient->email)) {
$to = $recipient->email;
$tmparraycontact = $tmpinvoice->liste_contact(-1, 'external', 0, 'BILLING');
if (is_array($tmparraycontact) && count($tmparraycontact) > 0) {
foreach ($tmparraycontact as $data_email) {
if (!empty($data_email['email'])) {
$to[] = $tmpinvoice->thirdparty->contact_get_property($data_email['id'], 'email');
}
}
}
if (empty($to) && !empty($recipient->email)) {
$to[] = $recipient->email;
} else {
$errormesg = "Failed to send remind to thirdparty id=".$tmpinvoice->socid.". No email defined for user.";
$error++;
@ -5548,9 +5556,11 @@ class Facture extends CommonInvoice
$error++;
}
if (!$error && $to) {
if (!$error && !empty($to)) {
$this->db->begin();
$to = implode(',', $to);
// Errors Recipient
$errors_to = $conf->global->MAIN_MAIL_ERRORS_TO;

View File

@ -98,7 +98,8 @@ $extralabelslines = $extrafields->fetch_name_optionals_label($object->table_elem
$permissionnote = $user->rights->contrat->creer; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->contrat->creer; // Used by the include of actions_dellink.inc.php
$permissiontodelete = ($user->rights->contrat->creer && $object->statut == $object::STATUS_DRAFT) || $user->rights->contrat->supprimer;
$permissiontoadd = $user->rights->contrat->creer; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$permissiontoedit = $permissiontoadd;
$error = 0;
@ -139,6 +140,8 @@ if (empty($reshook)) {
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
if ($action == 'confirm_active' && $confirm == 'yes' && $user->rights->contrat->activer) {
$result = $object->active_line($user, GETPOST('ligne', 'int'), GETPOST('date'), GETPOST('dateend'), GETPOST('comment'));
@ -351,7 +354,8 @@ if (empty($reshook)) {
$lines[$i]->fk_fournprice,
$lines[$i]->pa_ht,
$array_options,
$lines[$i]->fk_unit
$lines[$i]->fk_unit,
$num+1
);
if ($result < 0) {
@ -403,6 +407,8 @@ if (empty($reshook)) {
$price_ttc = '';
$price_ttc_devise = '';
$rang = count($object->lines) + 1;
if (GETPOST('price_ht') !== '') {
$price_ht = price2num(GETPOST('price_ht'), 'MU', 2);
}
@ -610,7 +616,8 @@ if (empty($reshook)) {
$fk_fournprice,
$pa_ht,
$array_options,
$fk_unit
$fk_unit,
$rang
);
}
@ -693,10 +700,10 @@ if (empty($reshook)) {
if (!$error) {
if ($date_start_real_update == '') {
$date_start_real_update = $objectline->date_ouverture;
$date_start_real_update = $objectline->date_start_real;
}
if ($date_end_real_update == '') {
$date_end_real_update = $objectline->date_cloture;
$date_end_real_update = $objectline->date_end_real;
}
$vat_rate = GETPOST('eltva_tx');
@ -740,13 +747,14 @@ if (empty($reshook)) {
$objectline->vat_src_code = $vat_src_code;
$objectline->localtax1_tx = is_numeric($localtax1_tx) ? $localtax1_tx : 0;
$objectline->localtax2_tx = is_numeric($localtax2_tx) ? $localtax2_tx : 0;
$objectline->date_ouverture_prevue = $date_start_update;
$objectline->date_ouverture = $date_start_real_update;
$objectline->date_fin_validite = $date_end_update;
$objectline->date_cloture = $date_end_real_update;
$objectline->date_start = $date_start_update;
$objectline->date_start_real = $date_start_real_update;
$objectline->date_end = $date_end_update;
$objectline->date_end_real = $date_end_real_update;
$objectline->fk_user_cloture = $user->id;
$objectline->fk_fournprice = $fk_fournprice;
$objectline->pa_ht = $pa_ht;
$objectline->rang = $objectline->rang;
if ($fk_unit > 0) {
$objectline->fk_unit = GETPOST('unit');
@ -1483,7 +1491,9 @@ if ($action == 'create') {
// Title line for service
$cursorline = 1;
print '<div id="contrat-lines-container" data-contractid="'.$object->id.'" data-element="'.$object->element.'" >';
print '<div id="contrat-lines-container" id="contractlines" data-contractid="'.$object->id.'" data-element="'.$object->element.'" >';
while ($cursorline <= $nbofservices) {
print '<div id="contrat-line-container'.$object->lines[$cursorline - 1]->id.'" data-contratlineid = "'.$object->lines[$cursorline - 1]->id.'" data-element="'.$object->lines[$cursorline - 1]->element.'" >';
print '<form name="update" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'" method="post">';
@ -1498,11 +1508,12 @@ if ($action == 'create') {
$sql = "SELECT cd.rowid, cd.statut, cd.label as label_det, cd.fk_product, cd.product_type, cd.description, cd.price_ht, cd.qty,";
$sql .= " cd.tva_tx, cd.vat_src_code, cd.remise_percent, cd.info_bits, cd.subprice, cd.multicurrency_subprice,";
$sql .= " cd.date_ouverture_prevue as date_debut, cd.date_ouverture as date_debut_reelle,";
$sql .= " cd.date_fin_validite as date_fin, cd.date_cloture as date_fin_reelle,";
$sql .= " cd.date_ouverture_prevue as date_start, cd.date_ouverture as date_start_real,";
$sql .= " cd.date_fin_validite as date_end, cd.date_cloture as date_end_real,";
$sql .= " cd.commentaire as comment, cd.fk_product_fournisseur_price as fk_fournprice, cd.buy_price_ht as pa_ht,";
$sql .= " cd.fk_unit,";
$sql .= " p.rowid as pid, p.ref as pref, p.label as plabel, p.fk_product_type as ptype, p.entity as pentity, p.tosell, p.tobuy, p.tobatch";
$sql .= " ,cd.rang";
$sql .= " FROM ".MAIN_DB_PREFIX."contratdet as cd";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
$sql .= " WHERE cd.rowid = ".((int) $object->lines[$cursorline - 1]->id);
@ -1511,6 +1522,8 @@ if ($action == 'create') {
if ($result) {
$total = 0;
$objp = $db->fetch_object($result);
print '<tr class="liste_titre'.($cursorline ? ' liste_titre_add' : '').'">';
print '<td>'.$langs->trans("ServiceNb", $cursorline).'</td>';
print '<td width="80" class="center">'.$langs->trans("VAT").'</td>';
@ -1526,10 +1539,28 @@ if ($action == 'create') {
if (isModEnabled('margin') && !empty($conf->global->MARGIN_SHOW_ON_CONTRACT)) {
print '<td width="50" class="right">'.$langs->trans("BuyingPrice").'</td>';
}
print '<td width="30">&nbsp;</td>';
//
if ($nbofservices > 1 && $conf->browser->layout != 'phone' && !empty($user->rights->contrat->creer)) {
print '<td width="30" class="linecolmove tdlineupdown center">';
if ($cursorline > 1) {
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=up&token='.newToken().'&rowid='.$objp->rowid.'">';
echo img_up('default', 0, 'imgupforline');
print '</a>';
}
if ($cursorline < $nbofservices) {
print '<a class="lineupdown" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=down&token='.newToken().'&rowid='.$objp->rowid.'">';
echo img_down('default', 0, 'imgdownforline');
print '</a>';
}
print '</td>';
} else {
print '<td width="30">&nbsp;</td>';
}
print "</tr>\n";
$objp = $db->fetch_object($result);
// Line in view mode
if ($action != 'editline' || GETPOST('rowid') != $objp->rowid) {
@ -1634,10 +1665,10 @@ if ($action == 'create') {
// Date planned
print $langs->trans("DateStartPlanned").': ';
if ($objp->date_debut) {
print dol_print_date($db->jdate($objp->date_debut), 'day');
if ($objp->date_start) {
print dol_print_date($db->jdate($objp->date_start), 'day');
// Warning si date prevu passee et pas en service
if ($objp->statut == 0 && $db->jdate($objp->date_debut) < ($now - $conf->contrat->services->inactifs->warning_delay)) {
if ($objp->statut == 0 && $db->jdate($objp->date_start) < ($now - $conf->contrat->services->inactifs->warning_delay)) {
$warning_delay = $conf->contrat->services->inactifs->warning_delay / 3600 / 24;
$textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days");
print " ".img_warning($textlate);
@ -1647,9 +1678,9 @@ if ($action == 'create') {
}
print ' &nbsp;-&nbsp; ';
print $langs->trans("DateEndPlanned").': ';
if ($objp->date_fin) {
print dol_print_date($db->jdate($objp->date_fin), 'day');
if ($objp->statut == 4 && $db->jdate($objp->date_fin) < ($now - $conf->contrat->services->expires->warning_delay)) {
if ($objp->date_end) {
print dol_print_date($db->jdate($objp->date_end), 'day');
if ($objp->statut == 4 && $db->jdate($objp->date_end) < ($now - $conf->contrat->services->expires->warning_delay)) {
$warning_delay = $conf->contrat->services->expires->warning_delay / 3600 / 24;
$textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days");
print " ".img_warning($textlate);
@ -1761,9 +1792,9 @@ if ($action == 'create') {
print '<tr class="oddeven">';
print '<td colspan="'.$colspan.'">';
print $langs->trans("DateStartPlanned").' ';
print $form->selectDate($db->jdate($objp->date_debut), "date_start_update", $usehm, $usehm, ($db->jdate($objp->date_debut) > 0 ? 0 : 1), "update");
print $form->selectDate($db->jdate($objp->date_start), "date_start_update", $usehm, $usehm, ($db->jdate($objp->date_start) > 0 ? 0 : 1), "update");
print ' &nbsp;&nbsp;'.$langs->trans("DateEndPlanned").' ';
print $form->selectDate($db->jdate($objp->date_fin), "date_end_update", $usehm, $usehm, ($db->jdate($objp->date_fin) > 0 ? 0 : 1), "update");
print $form->selectDate($db->jdate($objp->date_end), "date_end_update", $usehm, $usehm, ($db->jdate($objp->date_end) > 0 ? 0 : 1), "update");
print '</td>';
print '</tr>';
@ -1883,26 +1914,26 @@ if ($action == 'create') {
print '<td>';
// Si pas encore active
if (!$objp->date_debut_reelle) {
if (!$objp->date_start_real) {
print $langs->trans("DateStartReal").': ';
if ($objp->date_debut_reelle) {
print dol_print_date($db->jdate($objp->date_debut_reelle), 'day');
if ($objp->date_start_real) {
print dol_print_date($db->jdate($objp->date_start_real), 'day');
} else {
print $langs->trans("ContractStatusNotRunning");
}
}
// Si active et en cours
if ($objp->date_debut_reelle && !$objp->date_fin_reelle) {
if ($objp->date_start_real && !$objp->date_end_real) {
print $langs->trans("DateStartReal").': ';
print dol_print_date($db->jdate($objp->date_debut_reelle), 'day');
print dol_print_date($db->jdate($objp->date_start_real), 'day');
}
// Si desactive
if ($objp->date_debut_reelle && $objp->date_fin_reelle) {
if ($objp->date_start_real && $objp->date_end_real) {
print $langs->trans("DateStartReal").': ';
print dol_print_date($db->jdate($objp->date_debut_reelle), 'day');
print dol_print_date($db->jdate($objp->date_start_real), 'day');
print ' &nbsp;-&nbsp; ';
print $langs->trans("DateEndReal").': ';
print dol_print_date($db->jdate($objp->date_fin_reelle), 'day');
print dol_print_date($db->jdate($objp->date_end_real), 'day');
}
if (!empty($objp->comment)) {
print " &nbsp;-&nbsp; ".$objp->comment;
@ -1923,14 +1954,14 @@ if ($action == 'create') {
print '<table class="noborder tableforservicepart2'.($cursorline < $nbofservices ? ' boxtablenobottom' : '').'" width="100%">';
// Definie date debut et fin par defaut
$dateactstart = $objp->date_debut;
$dateactstart = $objp->date_start;
if (GETPOST('remonth')) {
$dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
} elseif (!$dateactstart) {
$dateactstart = time();
}
$dateactend = $objp->date_fin;
$dateactend = $objp->date_end;
if (GETPOST('endmonth')) {
$dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear'));
} elseif (!$dateactend) {
@ -1979,14 +2010,14 @@ if ($action == 'create') {
print '<table class="noborder tableforservicepart2'.($cursorline < $nbofservices ? ' boxtablenobottom' : '').'" width="100%">';
// Definie date debut et fin par defaut
$dateactstart = $objp->date_debut_reelle;
$dateactstart = $objp->date_start_real;
if (GETPOST('remonth')) {
$dateactstart = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
} elseif (!$dateactstart) {
$dateactstart = time();
}
$dateactend = $objp->date_fin_reelle;
$dateactend = $objp->date_end_real;
if (GETPOST('endmonth')) {
$dateactend = dol_mktime(12, 0, 0, GETPOST('endmonth'), GETPOST('endday'), GETPOST('endyear'));
} elseif (!$dateactend) {
@ -2005,7 +2036,7 @@ if ($action == 'create') {
if ($objp->statut >= 4) {
if ($objp->statut == 4) {
print $langs->trans("DateEndReal").' ';
print $form->selectDate($dateactend, "end", $usehm, $usehm, ($objp->date_fin_reelle > 0 ? 0 : 1), "closeline", 1, 1);
print $form->selectDate($dateactend, "end", $usehm, $usehm, ($objp->date_end_real > 0 ? 0 : 1), "closeline", 1, 1);
}
}
print '</td>';

View File

@ -290,8 +290,8 @@ class Contracts extends DolibarrApi
$request_data->localtax2_tx,
$request_data->fk_product,
$request_data->remise_percent,
$request_data->date_start, // date_start = date planned start, date ouverture = date_start_real
$request_data->date_end, // date_end = date planned end, date_cloture = date_end_real
$request_data->date_start,
$request_data->date_end,
$request_data->price_base_type ? $request_data->price_base_type : 'HT',
$request_data->subprice_excl_tax,
$request_data->info_bits,
@ -345,13 +345,13 @@ class Contracts extends DolibarrApi
$request_data->subprice,
$request_data->qty,
$request_data->remise_percent,
$request_data->date_ouveture_prevue,
$request_data->date_fin_validite,
$request_data->date_start,
$request_data->date_end,
$request_data->tva_tx,
$request_data->localtax1_tx,
$request_data->localtax2_tx,
$request_data->date_ouverture,
$request_data->date_cloture,
$request_data->date_start_real,
$request_data->date_end_real,
$request_data->price_base_type ? $request_data->price_base_type : 'HT',
$request_data->info_bits,
$request_data->fk_fourn_price,
@ -662,14 +662,10 @@ class Contracts extends DolibarrApi
unset($object->address);
unset($object->date_ouverture_prevue);
unset($object->date_ouverture);
unset($object->date_fin_validite);
unset($object->date_cloture);
unset($object->date_debut_prevue);
unset($object->date_debut_reel);
unset($object->date_fin_prevue);
unset($object->date_fin_reel);
unset($object->date_start);
unset($object->date_start_real);
unset($object->date_end);
unset($object->date_end_real);
unset($object->civility_id);
return $object;

View File

@ -788,19 +788,22 @@ class Contrat extends CommonObject
$sql .= " d.total_localtax2,";
$sql .= " d.total_ttc,";
$sql .= " d.info_bits, d.fk_product,";
$sql .= " d.date_ouverture_prevue, d.date_ouverture,";
$sql .= " d.date_fin_validite, d.date_cloture,";
$sql .= " d.date_ouverture_prevue as date_start,";
$sql .= " d.date_ouverture as date_start_real,";
$sql .= " d.date_fin_validite as date_end,";
$sql .= " d.date_cloture as date_end_real,";
$sql .= " d.fk_user_author,";
$sql .= " d.fk_user_ouverture,";
$sql .= " d.fk_user_cloture,";
$sql .= " d.fk_unit,";
$sql .= " d.product_type as type";
$sql .= " d.product_type as type,";
$sql .= " d.rang";
$sql .= " FROM ".MAIN_DB_PREFIX."contratdet as d LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid";
$sql .= " WHERE d.fk_contrat = ".((int) $this->id);
if ($only_services == 1) {
$sql .= " AND d.product_type = 1";
}
$sql .= " ORDER by d.rowid ASC";
$sql .= " ORDER by d.rang ASC";
dol_syslog(get_class($this)."::fetch_lines", LOG_DEBUG);
$result = $this->db->query($sql);
@ -855,19 +858,21 @@ class Contrat extends CommonObject
$line->description = $objp->description;
$line->date_start = $this->db->jdate($objp->date_ouverture_prevue);
$line->date_start_real = $this->db->jdate($objp->date_ouverture);
$line->date_end = $this->db->jdate($objp->date_fin_validite);
$line->date_end_real = $this->db->jdate($objp->date_cloture);
$line->date_start = $this->db->jdate($objp->date_start);
$line->date_start_real = $this->db->jdate($objp->date_start_real);
$line->date_end = $this->db->jdate($objp->date_end);
$line->date_end_real = $this->db->jdate($objp->date_end_real);
// For backward compatibility
$line->date_ouverture_prevue = $this->db->jdate($objp->date_ouverture_prevue);
$line->date_ouverture = $this->db->jdate($objp->date_ouverture);
$line->date_fin_validite = $this->db->jdate($objp->date_fin_validite);
$line->date_cloture = $this->db->jdate($objp->date_cloture);
$line->date_debut_prevue = $this->db->jdate($objp->date_ouverture_prevue);
$line->date_debut_reel = $this->db->jdate($objp->date_ouverture);
$line->date_fin_prevue = $this->db->jdate($objp->date_fin_validite);
$line->date_fin_reel = $this->db->jdate($objp->date_cloture);
//$line->date_ouverture_prevue = $this->db->jdate($objp->date_ouverture_prevue);
//$line->date_ouverture = $this->db->jdate($objp->date_ouverture);
//$line->date_fin_validite = $this->db->jdate($objp->date_fin_validite);
//$line->date_cloture = $this->db->jdate($objp->date_cloture);
//$line->date_debut_prevue = $this->db->jdate($objp->date_ouverture_prevue);
//$line->date_debut_reel = $this->db->jdate($objp->date_ouverture);
//$line->date_fin_prevue = $this->db->jdate($objp->date_fin_validite);
//$line->date_fin_reel = $this->db->jdate($objp->date_cloture);
$line->rang = $objp->rang;
// Retrieve all extrafields for contract line
// fetch optionals attributes and labels
@ -892,10 +897,10 @@ class Contrat extends CommonObject
if ($line->statut == ContratLigne::STATUS_INITIAL) {
$this->nbofserviceswait++;
}
if ($line->statut == ContratLigne::STATUS_OPEN && (empty($line->date_fin_prevue) || $line->date_fin_prevue >= $now)) {
if ($line->statut == ContratLigne::STATUS_OPEN && (empty($line->date_end) || $line->date_end >= $now)) {
$this->nbofservicesopened++;
}
if ($line->statut == ContratLigne::STATUS_OPEN && (!empty($line->date_fin_prevue) && $line->date_fin_prevue < $now)) {
if ($line->statut == ContratLigne::STATUS_OPEN && (!empty($line->date_end) && $line->date_end < $now)) {
$this->nbofservicesexpired++;
}
if ($line->statut == ContratLigne::STATUS_CLOSED) {
@ -1492,6 +1497,9 @@ class Contrat extends CommonObject
if (empty($remise_percent)) {
$remise_percent = 0;
}
if (empty($rang)) {
$rang = 0;
}
if ($date_start && $date_end && $date_start > $date_end) {
$langs->load("errors");
@ -1555,6 +1563,7 @@ class Contrat extends CommonObject
$sql .= ",date_fin_validite";
}
$sql .= ", fk_unit";
$sql .= ", rang";
$sql .= ") VALUES (";
$sql .= $this->id.", '', '".$this->db->escape($desc)."',";
$sql .= ($fk_product > 0 ? $fk_product : "null").",";
@ -1587,6 +1596,7 @@ class Contrat extends CommonObject
$sql .= ",'".$this->db->idate($date_end)."'";
}
$sql .= ", ".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null");
$sql .= ", ".(!empty($rang) ? (int) $rang : "0");
$sql .= ")";
$resql = $this->db->query($sql);
@ -1644,17 +1654,18 @@ class Contrat extends CommonObject
* @param float $tvatx Taux TVA
* @param float $localtax1tx Local tax 1 rate
* @param float $localtax2tx Local tax 2 rate
* @param int|string $date_debut_reel Date de debut reelle
* @param int|string $date_fin_reel Date de fin reelle
* @param int|string $date_start_real Date de debut reelle
* @param int|string $date_end_real Date de fin reelle
* @param string $price_base_type HT or TTC
* @param int $info_bits Bits of type of lines
* @param int $fk_fournprice Fourn price id
* @param int $pa_ht Buying price HT
* @param array $array_options extrafields array
* @param string $fk_unit Code of the unit to use. Null to use the default one
* @param string $rang Position
* @return int < 0 si erreur, > 0 si ok
*/
public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx = 0.0, $localtax2tx = 0.0, $date_debut_reel = '', $date_fin_reel = '', $price_base_type = 'HT', $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null)
public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx = 0.0, $localtax2tx = 0.0, $date_start_real = '', $date_end_real = '', $price_base_type = 'HT', $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null, $rang = 0)
{
global $user, $conf, $langs, $mysoc;
@ -1672,6 +1683,9 @@ class Contrat extends CommonObject
if (empty($fk_fournprice)) {
$fk_fournprice = 0;
}
if (empty($rang)) {
$rang = 0;
}
$subprice = $price;
$remise = 0;
@ -1688,7 +1702,7 @@ class Contrat extends CommonObject
return -1;
}
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $date_debut_reel, $date_fin_reel, $tvatx, $localtax1tx, $localtax2tx, $price_base_type, $info_bits");
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $date_start_real, $date_end_real, $tvatx, $localtax1tx, $localtax2tx, $price_base_type, $info_bits, $rang");
$this->db->begin();
@ -1760,17 +1774,18 @@ class Contrat extends CommonObject
} else {
$sql .= ",date_fin_validite = null";
}
if ($date_debut_reel > 0) {
$sql .= ",date_ouverture = '".$this->db->idate($date_debut_reel)."'";
if ($date_start_real > 0) {
$sql .= ",date_ouverture = '".$this->db->idate($date_start_real)."'";
} else {
$sql .= ",date_ouverture = null";
}
if ($date_fin_reel > 0) {
$sql .= ",date_cloture = '".$this->db->idate($date_fin_reel)."'";
if ($date_end_real > 0) {
$sql .= ",date_cloture = '".$this->db->idate($date_end_real)."'";
} else {
$sql .= ",date_cloture = null";
}
$sql .= ", fk_unit = ".($fk_unit > 0 ? ((int) $fk_unit) : "null");
$sql .= ", rang = ".(!empty($rang) ? ((int) $rang) : "0");
$sql .= " WHERE rowid = ".((int) $rowid);
dol_syslog(get_class($this)."::updateline", LOG_DEBUG);
@ -2565,7 +2580,7 @@ class Contrat extends CommonObject
if (!$error) {
foreach ($this->lines as $line) {
$result = $clonedObj->addline($line->description, $line->subprice, $line->qty, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, $line->remise_percent, $line->date_ouverture, $line->date_cloture, 'HT', 0, $line->info_bits, $line->fk_fournprice, $line->pa_ht, $line->array_options, $line->fk_unit);
$result = $clonedObj->addline($line->description, $line->subprice, $line->qty, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, $line->remise_percent, $line->date_ouverture, $line->date_cloture, 'HT', 0, $line->info_bits, $line->fk_fournprice, $line->pa_ht, $line->array_options, $line->fk_unit, $line->rang);
if ($result < 0) {
$error++;
$this->error = $clonedObj->error;
@ -2850,19 +2865,19 @@ class ContratLigne extends CommonObjectLine
/**
* @deprecated Use date_start
*/
public $date_ouverture_prevue; // date start planned
//public $date_ouverture_prevue; // date start planned
/**
* @deprecated Use date_start_real
*/
public $date_ouverture; // date start real
//public $date_ouverture; // date start real
/**
* @deprecated Use date_end
*/
public $date_fin_validite; // date end planned
//public $date_fin_validite; // date end planned
/**
* @deprecated Use date_end_real
*/
public $date_cloture; // date end real
//public $date_cloture; // date end real
public $tva_tx;
public $vat_src_code;
@ -2923,6 +2938,12 @@ class ContratLigne extends CommonObjectLine
public $commentaire;
/**
* @var int line rank
*/
public $rang = 0;
const STATUS_INITIAL = 0;
const STATUS_OPEN = 4;
const STATUS_CLOSED = 5;
@ -2952,7 +2973,8 @@ class ContratLigne extends CommonObjectLine
//'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>125),
'fk_user_ouverture' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserStartingService', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>135),
'fk_user_cloture' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserClosingService', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>135),
'statut' =>array('type'=>'smallint(6)', 'label'=>'Statut', 'enabled'=>1, 'visible'=>-1, 'position'=>500, 'arrayofkeyval'=>array(0=>'Draft', 4=>'Open', 5=>'Closed'))
'statut' =>array('type'=>'smallint(6)', 'label'=>'Statut', 'enabled'=>1, 'visible'=>-1, 'position'=>500, 'arrayofkeyval'=>array(0=>'Draft', 4=>'Open', 5=>'Closed')),
'rang' =>array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'position'=>500, 'default' =>0)
);
// END MODULEBUILDER PROPERTIES
@ -2976,7 +2998,7 @@ class ContratLigne extends CommonObjectLine
*/
public function getLibStatut($mode)
{
return $this->LibStatut($this->statut, $mode, ((!empty($this->date_fin_validite)) ? ($this->date_fin_validite < dol_now() ? 1 : 0) : -1));
return $this->LibStatut($this->statut, $mode, ((!empty($this->date_end)) ? ($this->date_end < dol_now() ? 1 : 0) : -1));
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@ -3091,10 +3113,10 @@ class ContratLigne extends CommonObjectLine
$sql .= " p.fk_product_type as product_type,";
$sql .= " t.description,";
$sql .= " t.date_commande,";
$sql .= " t.date_ouverture_prevue as date_ouverture_prevue,";
$sql .= " t.date_ouverture as date_ouverture,";
$sql .= " t.date_fin_validite as date_fin_validite,";
$sql .= " t.date_cloture as date_cloture,";
$sql .= " t.date_ouverture_prevue as date_start,";
$sql .= " t.date_ouverture as date_start_real,";
$sql .= " t.date_fin_validite as date_end,";
$sql .= " t.date_cloture as date_end_real,";
$sql .= " t.tva_tx,";
$sql .= " t.vat_src_code,";
$sql .= " t.localtax1_tx,";
@ -3119,7 +3141,8 @@ class ContratLigne extends CommonObjectLine
$sql .= " t.fk_user_ouverture,";
$sql .= " t.fk_user_cloture,";
$sql .= " t.commentaire,";
$sql .= " t.fk_unit";
$sql .= " t.fk_unit,";
$sql .= " t.rang";
$sql .= " FROM ".MAIN_DB_PREFIX."contratdet as t LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = t.fk_product";
if ($id) {
$sql .= " WHERE t.rowid = ".((int) $id);
@ -3149,15 +3172,15 @@ class ContratLigne extends CommonObjectLine
$this->description = $obj->description;
$this->date_commande = $this->db->jdate($obj->date_commande);
$this->date_start = $this->db->jdate($obj->date_ouverture_prevue);
$this->date_start_real = $this->db->jdate($obj->date_ouverture);
$this->date_end = $this->db->jdate($obj->date_fin_validite);
$this->date_end_real = $this->db->jdate($obj->date_cloture);
$this->date_start = $this->db->jdate($obj->date_start);
$this->date_start_real = $this->db->jdate($obj->date_start_real);
$this->date_end = $this->db->jdate($obj->date_end);
$this->date_end_real = $this->db->jdate($obj->date_end_real);
// For backward compatibility
$this->date_ouverture_prevue = $this->db->jdate($obj->date_ouverture_prevue);
$this->date_ouverture = $this->db->jdate($obj->date_ouverture);
$this->date_fin_validite = $this->db->jdate($obj->date_fin_validite);
$this->date_cloture = $this->db->jdate($obj->date_cloture);
//$this->date_ouverture_prevue = $this->db->jdate($obj->date_ouverture_prevue);
//$this->date_ouverture = $this->db->jdate($obj->date_ouverture);
//$this->date_fin_validite = $this->db->jdate($obj->date_fin_validite);
//$this->date_cloture = $this->db->jdate($obj->date_cloture);
$this->tva_tx = $obj->tva_tx;
$this->vat_src_code = $obj->vat_src_code;
@ -3186,6 +3209,8 @@ class ContratLigne extends CommonObjectLine
$this->pa_ht = $marginInfos[0];
$this->fk_unit = $obj->fk_unit;
$this->rang = $obj->rang;
$this->fetch_optionals();
}
@ -3237,6 +3262,7 @@ class ContratLigne extends CommonObjectLine
$this->fk_user_ouverture = (int) $this->fk_user_ouverture;
$this->fk_user_cloture = (int) $this->fk_user_cloture;
$this->commentaire = trim($this->commentaire);
$this->rang = (int) $this->rang;
//if (empty($this->subprice)) $this->subprice = 0;
if (empty($this->price_ht)) {
$this->price_ht = 0;
@ -3261,16 +3287,16 @@ class ContratLigne extends CommonObjectLine
}
// For backward compatibility
if (empty($this->date_start)) {
$this->date_start = $this->date_ouverture_prevue;
$this->date_start = $this->date_start;
}
if (empty($this->date_start_real)) {
$this->date_start = $this->date_ouverture;
$this->date_start_real = $this->date_start_real;
}
if (empty($this->date_end)) {
$this->date_start = $this->date_fin_validite;
$this->date_end = $this->date_end;
}
if (empty($this->date_end_real)) {
$this->date_start = $this->date_cloture;
$this->date_end_real = $this->date_end_real;
}
@ -3318,10 +3344,10 @@ class ContratLigne extends CommonObjectLine
$sql .= " label='".$this->db->escape($this->label)."',";
$sql .= " description='".$this->db->escape($this->description)."',";
$sql .= " date_commande=".($this->date_commande != '' ? "'".$this->db->idate($this->date_commande)."'" : "null").",";
$sql .= " date_ouverture_prevue=".($this->date_ouverture_prevue != '' ? "'".$this->db->idate($this->date_ouverture_prevue)."'" : "null").",";
$sql .= " date_ouverture=".($this->date_ouverture != '' ? "'".$this->db->idate($this->date_ouverture)."'" : "null").",";
$sql .= " date_fin_validite=".($this->date_fin_validite != '' ? "'".$this->db->idate($this->date_fin_validite)."'" : "null").",";
$sql .= " date_cloture=".($this->date_cloture != '' ? "'".$this->db->idate($this->date_cloture)."'" : "null").",";
$sql .= " date_ouverture_prevue=".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : "null").",";
$sql .= " date_ouverture=".($this->date_start_real != '' ? "'".$this->db->idate($this->date_start_real)."'" : "null").",";
$sql .= " date_fin_validite=".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : "null").",";
$sql .= " date_cloture=".($this->date_end_real != '' ? "'".$this->db->idate($this->date_end_real)."'" : "null").",";
$sql .= " vat_src_code='".$this->db->escape($this->vat_src_code)."',";
$sql .= " tva_tx=".price2num($this->tva_tx).",";
$sql .= " localtax1_tx=".price2num($this->localtax1_tx).",";
@ -3344,7 +3370,8 @@ class ContratLigne extends CommonObjectLine
$sql .= " fk_user_ouverture=".($this->fk_user_ouverture > 0 ? $this->fk_user_ouverture : "NULL").",";
$sql .= " fk_user_cloture=".($this->fk_user_cloture > 0 ? $this->fk_user_cloture : "NULL").",";
$sql .= " commentaire='".$this->db->escape($this->commentaire)."',";
$sql .= " fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit);
$sql .= " fk_unit=".(!$this->fk_unit ? 'NULL' : $this->fk_unit).",";
$sql .= " rang=".(empty($this->rang) ? '0' : (int) $this->rang);
$sql .= " WHERE rowid=".((int) $this->id);
dol_syslog(get_class($this)."::update", LOG_DEBUG);
@ -3365,9 +3392,9 @@ class ContratLigne extends CommonObjectLine
if (!$error && !empty($conf->global->CONTRACT_SYNC_PLANNED_DATE_OF_SERVICES)) {
dol_syslog(get_class($this)."::update CONTRACT_SYNC_PLANNED_DATE_OF_SERVICES is on so we update date for all lines", LOG_DEBUG);
if ($this->date_ouverture_prevue != $this->oldcopy->date_ouverture_prevue) {
if ($this->date_start != $this->oldcopy->date_start) {
$sql = 'UPDATE '.MAIN_DB_PREFIX.'contratdet SET';
$sql .= " date_ouverture_prevue = ".($this->date_ouverture_prevue != '' ? "'".$this->db->idate($this->date_ouverture_prevue)."'" : "null");
$sql .= " date_ouverture_prevue = ".($this->date_start != '' ? "'".$this->db->idate($this->date_start)."'" : "null");
$sql .= " WHERE fk_contrat = ".((int) $this->fk_contrat);
$resql = $this->db->query($sql);
@ -3376,9 +3403,9 @@ class ContratLigne extends CommonObjectLine
$this->error = "Error ".$this->db->lasterror();
}
}
if ($this->date_fin_validite != $this->oldcopy->date_fin_validite) {
if ($this->date_end != $this->oldcopy->date_end) {
$sql = 'UPDATE '.MAIN_DB_PREFIX.'contratdet SET';
$sql .= " date_fin_validite = ".($this->date_fin_validite != '' ? "'".$this->db->idate($this->date_fin_validite)."'" : "null");
$sql .= " date_fin_validite = ".($this->date_end != '' ? "'".$this->db->idate($this->date_end)."'" : "null");
$sql .= " WHERE fk_contrat = ".((int) $this->fk_contrat);
$resql = $this->db->query($sql);
@ -3463,11 +3490,12 @@ class ContratLigne extends CommonObjectLine
$sql .= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice,";
$sql .= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc,";
$sql .= " info_bits,";
$sql .= " rang,";
$sql .= " price_ht, remise, fk_product_fournisseur_price, buy_price_ht";
if ($this->date_ouverture_prevue > 0) {
if ($this->date_start > 0) {
$sql .= ",date_ouverture_prevue";
}
if ($this->date_fin_validite > 0) {
if ($this->date_end > 0) {
$sql .= ",date_fin_validite";
}
$sql .= ") VALUES ($this->fk_contrat, '', '".$this->db->escape($this->description)."',";
@ -3482,6 +3510,7 @@ class ContratLigne extends CommonObjectLine
$sql .= " ".price2num($this->remise_percent).",".price2num($this->subprice).",";
$sql .= " ".price2num($this->total_ht).",".price2num($this->total_tva).",".price2num($this->total_localtax1).",".price2num($this->total_localtax2).",".price2num($this->total_ttc).",";
$sql .= " '".$this->db->escape($this->info_bits)."',";
$sql .= " ".(empty($this->rang) ? '0' : (int) $this->rang).",";
$sql .= " ".price2num($this->price_ht).",".price2num($this->remise).",";
if ($this->fk_fournprice > 0) {
$sql .= ' '.((int) $this->fk_fournprice).',';
@ -3493,11 +3522,11 @@ class ContratLigne extends CommonObjectLine
} else {
$sql .= ' null';
}
if ($this->date_ouverture > 0) {
$sql .= ",'".$this->db->idate($this->date_ouverture)."'";
if ($this->date_start > 0) {
$sql .= ",'".$this->db->idate($this->date_start)."'";
}
if ($this->date_cloture > 0) {
$sql .= ",'".$this->db->idate($this->date_cloture)."'";
if ($this->date_end > 0) {
$sql .= ",'".$this->db->idate($this->date_end)."'";
}
$sql .= ")";
@ -3554,12 +3583,19 @@ class ContratLigne extends CommonObjectLine
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = ".ContratLigne::STATUS_OPEN.",";
$sql .= " date_ouverture = ".(dol_strlen($date) != 0 ? "'".$this->db->idate($date)."'" : "null").",";
$this->statut = ContratLigne::STATUS_OPEN;
$this->date_start = $date;
$this->date_end = $date_end;
$this->fk_user_ouverture = $user->id;
$this->date_end_real = null;
$this->commentaire = $comment;
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = ".$this->statut.",";
$sql .= " date_ouverture = ".(dol_strlen($this->date_start_real) != 0 ? "'".$this->db->idate($this->date_start_real)."'" : "null").",";
if ($date_end >= 0) {
$sql .= " date_fin_validite = ".(dol_strlen($date_end) != 0 ? "'".$this->db->idate($date_end)."'" : "null").",";
$sql .= " date_fin_validite = ".(dol_strlen($this->date_end) != 0 ? "'".$this->db->idate($this->date_end)."'" : "null").",";
}
$sql .= " fk_user_ouverture = ".((int) $user->id).",";
$sql .= " fk_user_ouverture = ".((int) $this->fk_user_ouverture).",";
$sql .= " date_cloture = null,";
$sql .= " commentaire = '".$this->db->escape($comment)."'";
$sql .= " WHERE rowid = ".((int) $this->id)." AND (statut = ".ContratLigne::STATUS_INITIAL." OR statut = ".ContratLigne::STATUS_CLOSED.")";
@ -3575,13 +3611,6 @@ class ContratLigne extends CommonObjectLine
// End call triggers
if (!$error) {
$this->statut = ContratLigne::STATUS_OPEN;
$this->date_ouverture = $date;
$this->date_fin_validite = $date_end;
$this->fk_user_ouverture = $user->id;
$this->date_cloture = null;
$this->commentaire = $comment;
$this->db->commit();
return 1;
} else {
@ -3600,18 +3629,18 @@ class ContratLigne extends CommonObjectLine
* Close a contract line
*
* @param User $user Objet User who close contract
* @param int $date_end Date end
* @param int $date_end_real Date end
* @param string $comment A comment typed by user
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
* @return int <0 if KO, >0 if OK
*/
public function close_line($user, $date_end, $comment = '', $notrigger = 0)
public function close_line($user, $date_end_real, $comment = '', $notrigger = 0)
{
// phpcs:enable
global $langs, $conf;
// Update object
$this->date_cloture = $date_end;
$this->date_cloture = $date_end_real;
$this->fk_user_cloture = $user->id;
$this->commentaire = $comment;
@ -3622,7 +3651,7 @@ class ContratLigne extends CommonObjectLine
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = ".((int) ContratLigne::STATUS_CLOSED).",";
$sql .= " date_cloture = '".$this->db->idate($date_end)."',";
$sql .= " date_cloture = '".$this->db->idate($date_end_real)."',";
$sql .= " fk_user_cloture = ".((int) $user->id).",";
$sql .= " commentaire = '".$this->db->escape($comment)."'";
$sql .= " WHERE rowid = ".((int) $this->id)." AND statut = ".((int) ContratLigne::STATUS_OPEN);

View File

@ -114,6 +114,8 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3)
$perm = 1;
} elseif ($table_element_line == 'projet_task' && $fk_element == 'fk_projet' && $user->rights->projet->creer) {
$perm = 1;
} elseif ($table_element_line == 'contratdet' && $fk_element == 'fk_contrat' && $user->hasRight('contrat', 'creer')) {
$perm = 1;
} else {
$tmparray = explode('_', $table_element_line);
$tmpmodule = $tmparray[0]; $tmpobject = preg_replace('/line$/', '', $tmparray[1]);
@ -152,7 +154,7 @@ if (GETPOST('roworder', 'alpha', 3) && GETPOST('table_element_line', 'aZ09', 3)
// Reorder line to have position of children lines sharing same counter than parent lines
// This should be useless because there is no need to have children sharing same counter than parent, but well, it's cleaner into database.
if (in_array($fk_element, array('fk_facture', 'fk_propal', 'fk_commande'))) {
if (in_array($fk_element, array('fk_facture', 'fk_propal', 'fk_commande','fk_contrat'))) {
$result = $row->line_order(true);
}
} else {

View File

@ -871,7 +871,7 @@ class pdf_einstein extends ModelePDFCommandes
// If payment mode not forced or forced to VIR, show payment with BAN
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
if ($object->fk_account > 0 || $object->fk_bank > 0 || !empty($conf->global->FACTURE_RIB_NUMBER)) {
if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
$bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
if ($object->fk_bank > 0) {
$bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank

View File

@ -1088,7 +1088,7 @@ class pdf_eratosthene extends ModelePDFCommandes
// If payment mode not forced or forced to VIR, show payment with BAN
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
if ($object->fk_account > 0 || $object->fk_bank > 0 || !empty($conf->global->FACTURE_RIB_NUMBER)) {
if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
$bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
if ($object->fk_bank > 0) {
$bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank

View File

@ -1134,10 +1134,10 @@ class pdf_crabe extends ModelePDFFactures
// Check a payment mode is defined
if (empty($object->mode_reglement_code)
&& empty($conf->global->FACTURE_CHQ_NUMBER)
&& empty($conf->global->FACTURE_RIB_NUMBER)) {
&& !getDolGlobalInt('FACTURE_RIB_NUMBER')) {
$this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured");
} elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))
|| ($object->mode_reglement_code == 'VIR' && empty($conf->global->FACTURE_RIB_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))) {
|| ($object->mode_reglement_code == 'VIR' && !getDolGlobalInt('FACTURE_RIB_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))) {
// Avoid having any valid PDF with setup that is not complete
$outputlangs->load("errors");
@ -1247,7 +1247,7 @@ class pdf_crabe extends ModelePDFFactures
// If payment mode not forced or forced to VIR, show payment with BAN
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
if ($object->fk_account > 0 || $object->fk_bank > 0 || !empty($conf->global->FACTURE_RIB_NUMBER)) {
if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
$bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
if ($object->fk_bank > 0) {
$bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank

View File

@ -1242,10 +1242,10 @@ class pdf_sponge extends ModelePDFFactures
// Check a payment mode is defined
if (empty($object->mode_reglement_code)
&& empty($conf->global->FACTURE_CHQ_NUMBER)
&& empty($conf->global->FACTURE_RIB_NUMBER)) {
&& !getDolGlobalInt('FACTURE_RIB_NUMBER')) {
$this->error = $outputlangs->transnoentities("ErrorNoPaiementModeConfigured");
} elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))
|| ($object->mode_reglement_code == 'VIR' && empty($conf->global->FACTURE_RIB_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))) {
|| ($object->mode_reglement_code == 'VIR' && !getDolGlobalInt('FACTURE_RIB_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))) {
// Avoid having any valid PDF with setup that is not complete
$outputlangs->load("errors");
@ -1358,7 +1358,7 @@ class pdf_sponge extends ModelePDFFactures
// If payment mode not forced or forced to VIR, show payment with BAN
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
if ($object->fk_account > 0 || $object->fk_bank > 0 || !empty($conf->global->FACTURE_RIB_NUMBER)) {
if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
$bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
if ($object->fk_bank > 0) {
$bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank

View File

@ -1053,7 +1053,7 @@ class pdf_azur extends ModelePDFPropales
// If payment mode not forced or forced to VIR, show payment with BAN
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER)) {
if (!empty($object->fk_account) || !empty($object->fk_bank) || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
$bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
if (!empty($object->fk_bank)) {
$bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank

View File

@ -1172,7 +1172,7 @@ class pdf_cyan extends ModelePDFPropales
// If payment mode not forced or forced to VIR, show payment with BAN
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
if ($object->fk_account > 0 || $object->fk_bank > 0 || !empty($conf->global->FACTURE_RIB_NUMBER)) {
if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
$bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
if ($object->fk_bank > 0) {
$bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank

View File

@ -978,7 +978,7 @@ class pdf_eagle_proforma extends ModelePDFCommandes
// If payment mode not forced or forced to VIR, show payment with BAN
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER)) {
if (!empty($object->fk_account) || !empty($object->fk_bank) || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
$bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
$account = new Account($this->db);

View File

@ -872,7 +872,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
// If payment mode not forced or forced to VIR, show payment with BAN
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
if (!empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER)) {
if (!empty($object->fk_bank) || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
$bankid = (empty($object->fk_bank) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_bank);
$account = new Account($this->db);
$account->fetch($bankid);

View File

@ -39,7 +39,7 @@ ob_start();
<header id="header">
<section id="sectionheader" contenteditable="true">
<h1>David Doe</h1>
<p>Welcome on my website<br />
<p>Welcome on my website<br>
</p>
</section>
</header>
@ -101,7 +101,7 @@ ob_start();
<section id="sectionsecond" class="main special" contenteditable="true">
<header class="major">
<h2>Ipsum consequat</h2>
<p>Donec imperdiet consequat consequat. Suspendisse feugiat congue<br />
<p>Donec imperdiet consequat consequat. Suspendisse feugiat congue<br>
posuere. Nulla massa urna, fermentum eget quam aliquet.</p>
</header>
<ul class="statistics">
@ -138,7 +138,7 @@ ob_start();
<section id="sectioncta" class="main special" contenteditable="true">
<header class="major">
<h2>Congue imperdiet</h2>
<p>Donec imperdiet consequat consequat. Suspendisse feugiat congue<br />
<p>Donec imperdiet consequat consequat. Suspendisse feugiat congue<br>
posuere. Nulla massa urna, fermentum eget quam aliquet.</p>
</header>
<footer class="major">

View File

@ -483,6 +483,13 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
migrate_user_photospath();
migrate_user_photospath2();
}
// Scripts for 17.0
$afterversionarray = explode('.', '16.0.9');
$beforeversionarray = explode('.', '17.0.9');
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
migrate_contractdet_rank();
}
}
@ -5137,3 +5144,62 @@ function migrate_export_import_profiles($mode = 'export')
print '<tr class="trforrunsql" style=""><td class="wordbreak" colspan="4">'.$langs->trans("NothingToDo")."</td></tr>\n";
}
}
/**
* Migrate Rank into contract line
*
* @return void
*/
function migrate_contractdet_rank()
{
global $db, $langs;
$error = 0;
$resultstring = '';
$db->begin();
print '<tr class="trforrunsql"><td colspan="4">';
$sql = "SELECT c.rowid as cid ,cd.rowid as cdid,cd.rang FROM ".$db->prefix()."contratdet as cd INNER JOIN ".$db->prefix()."contrat as c ON c.rowid=cd.fk_contrat AND cd.rang=0";
$sql .=" ORDER BY c.rowid,cd.rowid";
$resql = $db->query($sql);
if ($resql) {
$currentRank=0;
$current_contract=0;
while ($obj = $db->fetch_object($resql)) {
if (empty($current_contract) || $current_contract==$obj->cid) {
$currentRank++;
} else {
$currentRank=1;
}
$sqlUpd = "UPDATE ".$db->prefix()."contratdet SET rang=".(int) $currentRank." WHERE rowid=".(int) $obj->cdid;
$resultstring .= '<tr class="trforrunsql" style=""><td class="wordbreak" colspan="4">'.$sqlUpd."</td></tr>\n";
$resqlUpd = $db->query($sqlUpd);
if (!$resqlUpd) {
dol_print_error($db);
$error++;
}
$current_contract = $obj->cid;
}
} else {
$error++;
}
if (!$error) {
$db->commit();
} else {
$db->rollback();
}
print '<b>'.$langs->trans('MigrationContractLineRank')."</b><br>\n";
print '</td></tr>';
if ($resultstring) {
print $resultstring;
} else {
print '<tr class="trforrunsql" style=""><td class="wordbreak" colspan="4">'.$langs->trans("NothingToDo")."</td></tr>\n";
}
}

View File

@ -214,3 +214,4 @@ Loaded=Loaded
FunctionTest=Function test
NodoUpgradeAfterDB=No action requested by external modules after upgrade of database
NodoUpgradeAfterFiles=No action requested by external modules after upgrade of files or directories
MigrationContractLineRank=Migrate Contract Line to use Rank (and enable Reorder)

View File

@ -450,7 +450,7 @@ class MyObject extends CommonObject
$sql = "SELECT ";
$sql .= $this->getFieldList('t');
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
$sql .= " FROM ".$this->db->prefix().$this->table_element." as t";
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
$sql .= " WHERE t.entity IN (".getEntity($this->element).")";
} else {

View File

@ -126,11 +126,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ
// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
$enablepermissioncheck = 0;
if ($enablepermissioncheck) {
$permissiontoread = $user->rights->mymodule->myobject->read;
$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$permissiontodelete = $user->rights->mymodule->myobject->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
$permissionnote = $user->rights->mymodule->myobject->write; // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->rights->mymodule->myobject->write; // Used by the include of actions_dellink.inc.php
$permissiontoread = $user->hasRight('mymodule', 'myobject', 'read');
$permissiontoadd = $user->hasRight('mymodule', 'myobject', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
$permissiontodelete = $user->hasRight('mymodule', 'myobject', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
$permissionnote = $user->hasRight('mymodule', 'myobject', 'write'); // Used by the include of actions_setnotes.inc.php
$permissiondellink = $user->hasRight('mymodule', 'myobject', 'write'); // Used by the include of actions_dellink.inc.php
} else {
$permissiontoread = 1;
$permissiontoadd = 1; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) ---Put here your own copyright and developer email---
* Copyright (C) 2022 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by