Merge branch '13.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/admin/tools/listevents.php
	htdocs/compta/bank/line.php
	htdocs/compta/facture/class/facture-rec.class.php
	htdocs/compta/facture/class/facture.class.php
	htdocs/compta/paiement/cheque/card.php
	htdocs/core/class/commonobject.class.php
	htdocs/core/class/extrafields.class.php
	htdocs/core/lib/date.lib.php
	htdocs/core/lib/ticket.lib.php
	htdocs/core/modules/mailings/modules_mailings.php
	htdocs/core/tpl/extrafields_view.tpl.php
	htdocs/core/tpl/objectline_view.tpl.php
	htdocs/cron/list.php
	htdocs/expedition/card.php
	htdocs/mrp/mo_list.php
	htdocs/product/stock/productlot_card.php
	htdocs/public/emailing/mailing-read.php
	htdocs/public/emailing/mailing-unsubscribe.php
	htdocs/ticket/list.php
	test/phpunit/FactureRecTest.php
This commit is contained in:
Laurent Destailleur 2021-03-05 19:29:09 +01:00
commit 3cbced439a
25 changed files with 460 additions and 256 deletions

View File

@ -69,13 +69,20 @@ $search_desc = GETPOST("search_desc", "alpha");
$search_ua = GETPOST("search_ua", "restricthtml"); $search_ua = GETPOST("search_ua", "restricthtml");
$search_prefix_session = GETPOST("search_prefix_session", "restricthtml"); $search_prefix_session = GETPOST("search_prefix_session", "restricthtml");
if (GETPOST("date_startmonth") == '' || GETPOST("date_startmonth") > 0) { $now = dol_now();
$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); $nowarray = dol_getdate($now);
if (!GETPOSTISSET("date_startmonth")) {
$date_start = dol_get_first_day($nowarray['year'], $nowarray['mon'], 'tzuserrel');
} else if (GETPOST("date_startmonth") > 0) {
$date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth", 'int'), GETPOST("date_startday", 'int'), GETPOST("date_startyear", 'int'), 'tzuserrel');
} else { } else {
$date_start = -1; $date_start = -1;
} }
if (GETPOST("date_endmonth") == '' || GETPOST("date_endmonth") > 0) { if (!GETPOSTISSET("date_endmonth")) {
$date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); $date_end = dol_get_last_hour(dol_now('gmt'), 'tzuserrel');
} elseif (GETPOST("date_endmonth") > 0) {
$date_end = dol_get_last_hour(dol_mktime(23, 59, 59, GETPOST("date_endmonth", 'int'), GETPOST("date_endday", 'int'), GETPOST("date_endyear", 'int'), 'tzuserrel'), 'tzuserrel');
} else { } else {
$date_end = -1; $date_end = -1;
} }
@ -85,8 +92,6 @@ if ($date_start > 0 && $date_end > 0 && $date_start > $date_end) {
$date_end = $date_start + 86400; $date_end = $date_start + 86400;
} }
$now = dol_now();
$nowarray = dol_getdate($now);
if (empty($date_start)) { // We define date_start and date_end if (empty($date_start)) { // We define date_start and date_end
$date_start = dol_get_first_day($nowarray['year'], $nowarray['mon'], false); $date_start = dol_get_first_day($nowarray['year'], $nowarray['mon'], false);
@ -114,7 +119,6 @@ $arrayfields = array(
) )
); );
/* /*
* Actions * Actions
*/ */
@ -316,19 +320,22 @@ if ($result) {
// Fields title search // Fields title search
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre" width="15%">'.$form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0).'</td>'; print '<td class="liste_titre" width="15%">';
print $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
print $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
print '</td>';
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
print '<input class="flat maxwidth100" type="text" name="search_code" value="'.$search_code.'">'; print '<input class="flat maxwidth100" type="text" name="search_code" value="'.dol_escape_htmltag($search_code).'">';
print '</td>'; print '</td>';
// IP // IP
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
print '<input class="flat maxwidth100" type="text" name="search_ip" value="'.$search_ip.'">'; print '<input class="flat maxwidth100" type="text" name="search_ip" value="'.dol_escape_htmltag($search_ip).'">';
print '</td>'; print '</td>';
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
print '<input class="flat maxwidth100" type="text" name="search_user" value="'.$search_user.'">'; print '<input class="flat maxwidth100" type="text" name="search_user" value="'.dol_escape_htmltag($search_user).'">';
print '</td>'; print '</td>';
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
@ -337,13 +344,13 @@ if ($result) {
if (!empty($arrayfields['e.user_agent']['checked'])) { if (!empty($arrayfields['e.user_agent']['checked'])) {
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
print '<input class="flat maxwidth100" type="text" name="search_ua" value="'.$search_ua.'">'; print '<input class="flat maxwidth100" type="text" name="search_ua" value="'.dol_escape_htmltag($search_ua).'">';
print '</td>'; print '</td>';
} }
if (!empty($arrayfields['e.prefix_session']['checked'])) { if (!empty($arrayfields['e.prefix_session']['checked'])) {
print '<td class="liste_titre left">'; print '<td class="liste_titre left">';
print '<input class="flat maxwidth100" type="text" name="search_prefix_session" value="'.$search_prefix_session.'">'; print '<input class="flat maxwidth100" type="text" name="search_prefix_session" value="'.dol_escape_htmltag($search_prefix_session).'">';
print '</td>'; print '</td>';
} }
@ -376,7 +383,7 @@ if ($result) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
// Date // Date
print '<td class="nowrap left">'.dol_print_date($db->jdate($obj->dateevent), '%Y-%m-%d %H:%M:%S').'</td>'; print '<td class="nowrap left">'.dol_print_date($db->jdate($obj->dateevent), '%Y-%m-%d %H:%M:%S', 'tzuserrel').'</td>';
// Code // Code
print '<td>'.$obj->type.'</td>'; print '<td>'.$obj->type.'</td>';

View File

@ -207,8 +207,8 @@ if (empty($reshook)) {
$substitutionarray['__OTHER4__'] = $other4; $substitutionarray['__OTHER4__'] = $other4;
$substitutionarray['__OTHER5__'] = $other5; $substitutionarray['__OTHER5__'] = $other5;
$substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter) $substitutionarray['__USER_SIGNATURE__'] = $signature; // Signature is empty when ran from command line or taken from user in parameter)
$substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.$obj->tag.'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" width="1" height="1" style="width:1px;height:1px" border="0"/>'; $substitutionarray['__CHECK_READ__'] = '<img src="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-read.php?tag='.urlencode($obj->tag).'&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'&email='.urlencode($obj->email).'&mtid='.$obj->rowid.'" width="1" height="1" style="width:1px;height:1px" border="0"/>';
$substitutionarray['__UNSUBSCRIBE__'] = '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.$obj->tag.'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>'; $substitutionarray['__UNSUBSCRIBE__'] = '<a href="'.DOL_MAIN_URL_ROOT.'/public/emailing/mailing-unsubscribe.php?tag='.urlencode($obj->tag).'&unsuscrib=1&securitykey='.urlencode($conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY).'&email='.urlencode($obj->email).'&mtid='.$obj->rowid.'" target="_blank">'.$langs->trans("MailUnsubcribe").'</a>';
$onlinepaymentenabled = 0; $onlinepaymentenabled = 0;
if (!empty($conf->paypal->enabled)) { if (!empty($conf->paypal->enabled)) {

View File

@ -315,10 +315,11 @@ if ($result) {
$i++; $i++;
// Bank account // Bank account
print '<tr><td class="titlefield">'.$langs->trans("Account").'</td>'; print '<tr><td class="titlefieldcreate">'.$langs->trans("Account").'</td>';
print '<td>'; print '<td>';
if (!$objp->rappro && !$bankline->getVentilExportCompta()) { if (!$objp->rappro && !$bankline->getVentilExportCompta()) {
$form->select_comptes($acct->id, 'accountid', 0, '', 0); print img_picto('', 'bank_account', 'class="paddingright"');
print $form->select_comptes($acct->id, 'accountid', 0, '', 0, '', 0, '', 1);
} else { } else {
print $acct->getNomUrl(1, 'transactions', 'reflabel'); print $acct->getNomUrl(1, 'transactions', 'reflabel');
} }
@ -566,7 +567,7 @@ if ($result) {
// Bank line // Bank line
print '<tr><td class="toptd">'.$form->editfieldkey('RubriquesTransactions', 'custcats', '', $object, 0).'</td><td>'; print '<tr><td class="toptd">'.$form->editfieldkey('RubriquesTransactions', 'custcats', '', $object, 0).'</td><td>';
$cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, null, 'parent', null, null, 1); $cate_arbo = $form->select_all_categories(Categorie::TYPE_BANK_LINE, null, 'parent', null, null, 1);
print $form->multiselectarray('custcats', $cate_arbo, $arrayselected, null, null, null, null, "90%"); print img_picto('', 'category', 'class="paddingright"').$form->multiselectarray('custcats', $cate_arbo, $arrayselected, null, null, null, null, "90%");
print "</td></tr>"; print "</td></tr>";
} }

View File

@ -335,14 +335,20 @@ class FactureRec extends CommonInvoice
$facsrc->lines[$i]->special_code, $facsrc->lines[$i]->special_code,
$facsrc->lines[$i]->label, $facsrc->lines[$i]->label,
$facsrc->lines[$i]->fk_unit, $facsrc->lines[$i]->fk_unit,
$facsrc->lines[$i]->multicurrency_subprice $facsrc->lines[$i]->multicurrency_subprice,
0,
0,
null,
$facsrc->lines[$i]->pa_ht
); );
if ($result_insert < 0) { if ($result_insert < 0) {
$error++; $error++;
} else { } else {
$objectline = new FactureLigneRec($this->db); $objectline = new FactureLigneRec($this->db);
if ($objectline->fetch($result_insert)) {
$result2 = $objectline->fetch($result_insert);
if ($result2 > 0) {
// Extrafields // Extrafields
if (method_exists($facsrc->lines[$i], 'fetch_optionals')) { if (method_exists($facsrc->lines[$i], 'fetch_optionals')) {
$facsrc->lines[$i]->fetch_optionals($facsrc->lines[$i]->id); $facsrc->lines[$i]->fetch_optionals($facsrc->lines[$i]->id);
@ -353,6 +359,9 @@ class FactureRec extends CommonInvoice
if ($result < 0) { if ($result < 0) {
$error++; $error++;
} }
} elseif ($result2 < 0) {
$this->errors[] = $objectline->error;
$error++;
} }
} }
} }
@ -403,6 +412,7 @@ class FactureRec extends CommonInvoice
if ($error) { if ($error) {
$this->db->rollback(); $this->db->rollback();
return -3;
} else { } else {
$this->db->commit(); $this->db->commit();
return $this->id; return $this->id;
@ -494,14 +504,15 @@ class FactureRec extends CommonInvoice
//$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = f.rowid AND el.targettype = 'facture'"; //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON el.fk_target = f.rowid AND el.targettype = 'facture'";
$sql .= ' WHERE f.entity IN ('.getEntity('invoice').')'; $sql .= ' WHERE f.entity IN ('.getEntity('invoice').')';
if ($rowid) { if ($rowid) {
$sql .= ' AND f.rowid='.$rowid; $sql .= ' AND f.rowid='.((int) $rowid);
} elseif ($ref) { } elseif ($ref) {
$sql .= " AND f.titre='".$this->db->escape($ref)."'"; $sql .= " AND f.titre='".$this->db->escape($ref)."'";
} else {
$sql .= ' AND f.rowid = 0';
} }
/* This field are not used for template invoice /* This field are not used for template invoice
if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'"; if ($ref_ext) $sql.= " AND f.ref_ext='".$this->db->escape($ref_ext)."'";
if ($ref_int) $sql.= " AND f.ref_int='".$this->db->escape($ref_int)."'"; */
*/
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) { if ($result) {
@ -629,11 +640,11 @@ class FactureRec extends CommonInvoice
$sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx, '; $sql = 'SELECT l.rowid, l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx, ';
$sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,';
$sql .= ' l.info_bits, l.date_start_fill, l.date_end_fill, l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; $sql .= ' l.info_bits, l.date_start_fill, l.date_end_fill, l.total_ht, l.total_tva, l.total_ttc, l.fk_product_fournisseur_price, l.buy_price_ht as pa_ht,';
//$sql.= ' l.situation_percent, l.fk_prev_id,'; //$sql.= ' l.situation_percent, l.fk_prev_id,';
//$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,'; //$sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise_percent, l.fk_remise_except, l.subprice,';
$sql .= ' l.rang, l.special_code,'; $sql .= ' l.rang, l.special_code,';
//$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; //$sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price, l.buy_price_ht as pa_ht,';
$sql .= ' l.fk_unit, l.fk_contract_line,'; $sql .= ' l.fk_unit, l.fk_contract_line,';
$sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,'; $sql .= ' l.fk_multicurrency, l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,';
$sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; $sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc';
@ -682,10 +693,16 @@ class FactureRec extends CommonInvoice
$line->total_ht = $objp->total_ht; $line->total_ht = $objp->total_ht;
$line->total_tva = $objp->total_tva; $line->total_tva = $objp->total_tva;
$line->total_ttc = $objp->total_ttc; $line->total_ttc = $objp->total_ttc;
//$line->code_ventilation = $objp->fk_code_ventilation; //$line->code_ventilation = $objp->fk_code_ventilation;
$line->fk_fournprice = $objp->fk_fournprice;
$marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); $line->fk_product_fournisseur_price = $objp->fk_product_fournisseur_price;
$line->pa_ht = $marginInfos[0]; $line->fk_fournprice = $objp->fk_product_fournisseur_price; // For backward compatibility
$marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $objp->fk_product_fournisseur_price, $objp->pa_ht);
$line->buyprice = $marginInfos[0];
$line->pa_ht = $marginInfos[0]; // For backward compatibility
$line->marge_tx = $marginInfos[1]; $line->marge_tx = $marginInfos[1];
$line->marque_tx = $marginInfos[2]; $line->marque_tx = $marginInfos[2];
$line->rang = $objp->rang; $line->rang = $objp->rang;
@ -1962,6 +1979,10 @@ class FactureLigneRec extends CommonInvoiceLine
$sql .= ' l.date_start_fill, l.date_end_fill, l.info_bits, l.total_ht, l.total_tva, l.total_ttc,'; $sql .= ' l.date_start_fill, l.date_end_fill, l.info_bits, l.total_ht, l.total_tva, l.total_ttc,';
$sql .= ' l.rang, l.special_code,'; $sql .= ' l.rang, l.special_code,';
$sql .= ' l.fk_unit, l.fk_contract_line,'; $sql .= ' l.fk_unit, l.fk_contract_line,';
$sql .= ' l.import_key, l.fk_multicurrency,';
$sql .= ' l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,';
$sql .= ' l.buy_price_ht, l.fk_product_fournisseur_price,';
$sql .= ' l.fk_user_author, l.fk_user_modif,';
$sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; $sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc';
$sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l'; $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l';
$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
@ -2008,7 +2029,17 @@ class FactureLigneRec extends CommonInvoiceLine
$this->special_code = $objp->special_code; $this->special_code = $objp->special_code;
$this->fk_unit = $objp->fk_unit; $this->fk_unit = $objp->fk_unit;
$this->fk_contract_line = $objp->fk_contract_line; $this->fk_contract_line = $objp->fk_contract_line;
$this->import_key = $objp->import_key;
$this->fk_multicurrency = $objp->fk_multicurrency;
$this->multicurrency_code = $objp->multicurrency_code;
$this->multicurrency_subprice = $objp->multicurrency_subprice;
$this->multicurrency_total_ht = $objp->multicurrency_total_ht;
$this->multicurrency_total_tva = $objp->multicurrency_total_tva;
$this->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
$this->buy_price_ht = $objp->buy_price_ht;
$this->fk_product_fournisseur_price = $objp->fk_product_fournisseur_price;
$this->fk_user_author = $objp->fk_user_author;
$this->fk_user_modif = $objp->fk_user_modif;
$this->db->free($result); $this->db->free($result);
return 1; return 1;

View File

@ -917,8 +917,9 @@ class Facture extends CommonInvoice
$localtax1_tx = $_facrec->lines[$i]->localtax1_tx; $localtax1_tx = $_facrec->lines[$i]->localtax1_tx;
$localtax2_tx = $_facrec->lines[$i]->localtax2_tx; $localtax2_tx = $_facrec->lines[$i]->localtax2_tx;
$fk_product_fournisseur_price = empty($_facrec->lines[$i]->fk_product_fournisseur_price) ?null:$_facrec->lines[$i]->fk_product_fournisseur_price; $fk_product_fournisseur_price = empty($_facrec->lines[$i]->fk_product_fournisseur_price) ? null : $_facrec->lines[$i]->fk_product_fournisseur_price;
$buyprice = empty($_facrec->lines[$i]->buyprice) ? 0 : $_facrec->lines[$i]->buyprice; $buyprice = empty($_facrec->lines[$i]->buyprice) ? 0 : $_facrec->lines[$i]->buyprice;
// If buyprice not defined from template invoice, we try to guess the best value // If buyprice not defined from template invoice, we try to guess the best value
if (!$buyprice && $_facrec->lines[$i]->fk_product > 0) { if (!$buyprice && $_facrec->lines[$i]->fk_product > 0) {
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';

View File

@ -364,8 +364,9 @@ if ($action == 'new') {
print '</form>'; print '</form>';
print '<br>'; print '<br>';
$sql = "SELECT ba.rowid as bid, b.datec as datec, b.dateo as date, b.rowid as transactionid, "; $sql = "SELECT ba.rowid as bid, ba.label,";
$sql .= " b.amount, ba.label, b.emetteur, b.num_chq, b.banque,"; $sql .= " b.rowid as transactionid, b.label as transactionlabel, b.datec as datec, b.dateo as date, ";
$sql .= " b.amount, b.emetteur, b.num_chq, b.banque,";
$sql .= " p.rowid as paymentid, p.ref as paymentref"; $sql .= " p.rowid as paymentid, p.ref as paymentref";
$sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid";
@ -393,6 +394,8 @@ if ($action == 'new') {
$lines[$obj->bid][$i]["numero"] = $obj->num_chq; $lines[$obj->bid][$i]["numero"] = $obj->num_chq;
$lines[$obj->bid][$i]["banque"] = $obj->banque; $lines[$obj->bid][$i]["banque"] = $obj->banque;
$lines[$obj->bid][$i]["id"] = $obj->transactionid; $lines[$obj->bid][$i]["id"] = $obj->transactionid;
$lines[$obj->bid][$i]["ref"] = $obj->transactionid;
$lines[$obj->bid][$i]["label"] = $obj->transactionlabel;
$lines[$obj->bid][$i]["paymentid"] = $obj->paymentid; $lines[$obj->bid][$i]["paymentid"] = $obj->paymentid;
$lines[$obj->bid][$i]["paymentref"] = $obj->paymentref; $lines[$obj->bid][$i]["paymentref"] = $obj->paymentref;
$i++; $i++;
@ -473,8 +476,9 @@ if ($action == 'new') {
print '</td>'; print '</td>';
// Link to bank transaction // Link to bank transaction
print '<td class="center">'; print '<td class="center">';
$accountlinestatic->rowid = $value["id"]; $accountlinestatic->id = $value["id"];
if ($accountlinestatic->rowid) { $accountlinestatic->ref = $value["ref"];
if ($accountlinestatic->id > 0) {
print $accountlinestatic->getNomUrl(1); print $accountlinestatic->getNomUrl(1);
} else { } else {
print '&nbsp;'; print '&nbsp;';
@ -594,7 +598,7 @@ if ($action == 'new') {
// List of bank checks // List of bank checks
$sql = "SELECT b.rowid, b.amount, b.num_chq, b.emetteur,"; $sql = "SELECT b.rowid, b.rowid as ref, b.label, b.amount, b.num_chq, b.emetteur,";
$sql .= " b.dateo as date, b.datec as datec, b.banque,"; $sql .= " b.dateo as date, b.datec as datec, b.banque,";
$sql .= " p.rowid as pid, p.ref as pref, ba.rowid as bid, p.statut"; $sql .= " p.rowid as pid, p.ref as pref, ba.rowid as bid, p.statut";
$sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; $sql .= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
@ -648,8 +652,9 @@ if ($action == 'new') {
print '</td>'; print '</td>';
// Link to bank transaction // Link to bank transaction
print '<td class="center">'; print '<td class="center">';
$accountlinestatic->rowid = $objp->rowid; $accountlinestatic->id = $objp->rowid;
if ($accountlinestatic->rowid) { $accountlinestatic->ref = $objp->ref;
if ($accountlinestatic->id > 0) {
print $accountlinestatic->getNomUrl(1); print $accountlinestatic->getNomUrl(1);
} else { } else {
print '&nbsp;'; print '&nbsp;';

View File

@ -74,9 +74,9 @@ if ($action == 'add' && !empty($permissiontoadd)) {
if (in_array($object->fields[$key]['type'], array('text', 'html'))) { if (in_array($object->fields[$key]['type'], array('text', 'html'))) {
$value = GETPOST($key, 'restricthtml'); $value = GETPOST($key, 'restricthtml');
} elseif ($object->fields[$key]['type'] == 'date') { } elseif ($object->fields[$key]['type'] == 'date') {
$value = dol_mktime(12, 0, 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); $value = dol_mktime(12, 0, 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); // for date without hour, we use gmt
} elseif ($object->fields[$key]['type'] == 'datetime') { } elseif ($object->fields[$key]['type'] == 'datetime') {
$value = dol_mktime(GETPOST($key.'hour', 'int'), GETPOST($key.'min', 'int'), 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); $value = dol_mktime(GETPOST($key.'hour', 'int'), GETPOST($key.'min', 'int'), GETPOST($key.'sec', 'int'), GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int'), 'tzuserrel');
} elseif ($object->fields[$key]['type'] == 'duration') { } elseif ($object->fields[$key]['type'] == 'duration') {
$value = 60 * 60 * GETPOST($key.'hour', 'int') + 60 * GETPOST($key.'min', 'int'); $value = 60 * 60 * GETPOST($key.'hour', 'int') + 60 * GETPOST($key.'min', 'int');
} elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) { } elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
@ -174,9 +174,9 @@ if ($action == 'update' && !empty($permissiontoadd)) {
$value = GETPOST($key, 'restricthtml'); $value = GETPOST($key, 'restricthtml');
} }
} elseif ($object->fields[$key]['type'] == 'date') { } elseif ($object->fields[$key]['type'] == 'date') {
$value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); $value = dol_mktime(12, 0, 0, GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int')); // for date without hour, we use gmt
} elseif ($object->fields[$key]['type'] == 'datetime') { } elseif ($object->fields[$key]['type'] == 'datetime') {
$value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year')); $value = dol_mktime(GETPOST($key.'hour', 'int'), GETPOST($key.'min', 'int'), GETPOST($key.'sec', 'int'), GETPOST($key.'month', 'int'), GETPOST($key.'day', 'int'), GETPOST($key.'year', 'int'), 'tzuserrel');
} elseif ($object->fields[$key]['type'] == 'duration') { } elseif ($object->fields[$key]['type'] == 'duration') {
if (GETPOST($key.'hour', 'int') != '' || GETPOST($key.'min', 'int') != '') { if (GETPOST($key.'hour', 'int') != '' || GETPOST($key.'min', 'int') != '') {
$value = 60 * 60 * GETPOST($key.'hour', 'int') + 60 * GETPOST($key.'min', 'int'); $value = 60 * 60 * GETPOST($key.'hour', 'int') + 60 * GETPOST($key.'min', 'int');

View File

@ -6455,11 +6455,10 @@ abstract class CommonObject
} }
} }
if (in_array($type, array('date', 'datetime'))) { if (in_array($type, array('date'))) {
$tmp = explode(',', $size); $tmp = explode(',', $size);
$newsize = $tmp[0]; $newsize = $tmp[0];
$showtime = 0;
$showtime = in_array($type, array('datetime')) ? 1 : 0;
// Do not show current date when field not required (see selectDate() method) // Do not show current date when field not required (see selectDate() method)
if (!$required && $value == '') { if (!$required && $value == '') {
@ -6468,6 +6467,16 @@ abstract class CommonObject
// TODO Must also support $moreparam // TODO Must also support $moreparam
$out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1);
} elseif (in_array($type, array('datetime'))) {
$tmp = explode(',', $size);
$newsize = $tmp[0];
$showtime = 1;
// Do not show current date when field not required (see selectDate() method)
if (!$required && $value == '') $value = '-1';
// TODO Must also support $moreparam
$out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1, '', '', '', 1, '', '', 'tzuserrel');
} elseif (in_array($type, array('duration'))) { } elseif (in_array($type, array('duration'))) {
$out = $form->select_duration($keyprefix.$key.$keysuffix, $value, 0, 'text', 0, 1); $out = $form->select_duration($keyprefix.$key.$keysuffix, $value, 0, 'text', 0, 1);
} elseif (in_array($type, array('int', 'integer'))) { } elseif (in_array($type, array('int', 'integer'))) {
@ -7025,13 +7034,13 @@ abstract class CommonObject
$value = $this->getLibStatut(3); $value = $this->getLibStatut(3);
} elseif ($type == 'date') { } elseif ($type == 'date') {
if (!empty($value)) { if (!empty($value)) {
$value = dol_print_date($value, 'day'); $value = dol_print_date($value, 'day'); // We suppose dates without time are always gmt (storage of course + output)
} else { } else {
$value = ''; $value = '';
} }
} elseif ($type == 'datetime' || $type == 'timestamp') { } elseif ($type == 'datetime' || $type == 'timestamp') {
if (!empty($value)) { if (!empty($value)) {
$value = dol_print_date($value, 'dayhour'); $value = dol_print_date($value, 'dayhour', 'tzuserrel');
} else { } else {
$value = ''; $value = '';
} }
@ -7410,12 +7419,21 @@ abstract class CommonObject
} }
// Convert date into timestamp format (value in memory must be a timestamp) // Convert date into timestamp format (value in memory must be a timestamp)
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date', 'datetime'))) { if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('date'))) {
$datenotinstring = $this->array_options['options_'.$key]; $datenotinstring = $this->array_options['options_'.$key];
if (!is_numeric($this->array_options['options_'.$key])) { // For backward compatibility if (!is_numeric($this->array_options['options_'.$key])) { // For backward compatibility
$datenotinstring = $this->db->jdate($datenotinstring); $datenotinstring = $this->db->jdate($datenotinstring);
} }
$value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)) ? dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min", 'int', 3), 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3)) : $datenotinstring; $value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)) ? dol_mktime(12, 0, 0, GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3)) : $datenotinstring;
}
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('datetime')))
{
$datenotinstring = $this->array_options['options_'.$key];
if (!is_numeric($this->array_options['options_'.$key])) // For backward compatibility
{
$datenotinstring = $this->db->jdate($datenotinstring);
}
$value = (GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix)) ? dol_mktime(GETPOST($keyprefix.'options_'.$key.$keysuffix."hour", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."min", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."sec", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."month", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."day", 'int', 3), GETPOST($keyprefix.'options_'.$key.$keysuffix."year", 'int', 3), 'tzuserrel') : $datenotinstring;
} }
// Convert float submited string into real php numeric (value in memory must be a php numeric) // Convert float submited string into real php numeric (value in memory must be a php numeric)
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('price', 'double'))) { if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('price', 'double'))) {
@ -8174,12 +8192,14 @@ abstract class CommonObject
*/ */
public function setVarsFromFetchObj(&$obj) public function setVarsFromFetchObj(&$obj)
{ {
global $db;
foreach ($this->fields as $field => $info) { foreach ($this->fields as $field => $info) {
if ($this->isDate($info)) { if ($this->isDate($info)) {
if (empty($obj->{$field}) || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') { if (is_null($obj->{$field}) || $obj->{$field} === '' || $obj->{$field} === '0000-00-00 00:00:00' || $obj->{$field} === '1000-01-01 00:00:00') {
$this->{$field} = 0; $this->{$field} = '';
} else { } else {
$this->{$field} = strtotime($obj->{$field}); $this->{$field} = $db->jdate($obj->{$field});
} }
} elseif ($this->isArray($info)) { } elseif ($this->isArray($info)) {
if (!empty($obj->{$field})) { if (!empty($obj->{$field})) {

View File

@ -1062,11 +1062,10 @@ class ExtraFields
} }
} }
if (in_array($type, array('date', 'datetime'))) { if (in_array($type, array('date'))) {
$tmp = explode(',', $size); $tmp = explode(',', $size);
$newsize = $tmp[0]; $newsize = $tmp[0];
$showtime = 0;
$showtime = in_array($type, array('datetime')) ? 1 : 0;
// Do not show current date when field not required (see selectDate() method) // Do not show current date when field not required (see selectDate() method)
if (!$required && $value == '') { if (!$required && $value == '') {
@ -1079,16 +1078,41 @@ class ExtraFields
'start' => isset($value['start']) ? $value['start'] : '', 'start' => isset($value['start']) ? $value['start'] : '',
'end' => isset($value['end']) ? $value['end'] : '' 'end' => isset($value['end']) ? $value['end'] : ''
); );
$out = '<div ' . ($moreparam ? $moreparam : '') . '><div class="nowrap">' $out = '<div ' . ($moreparam ? $moreparam : '') . '><div class="nowrap">';
. $form->selectDate($prefill['start'], $keyprefix.$key.$keysuffix.'_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")) $out .= $form->selectDate($prefill['start'], $keyprefix.$key.$keysuffix.'_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
. '</div><div class="nowrap">' $out .= '</div><div class="nowrap">';
. $form->selectDate($prefill['end'], $keyprefix.$key.$keysuffix.'_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")) $out .= $form->selectDate($prefill['end'], $keyprefix.$key.$keysuffix.'_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
. '</div></div>'; $out .= '</div></div>';
} else { } else {
// TODO Must also support $moreparam // TODO Must also support $moreparam
$out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1); $out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1);
} }
} elseif (in_array($type, array('int', 'integer'))) { } elseif (in_array($type, array('datetime'))) {
$tmp = explode(',', $size);
$newsize = $tmp[0];
$showtime = 1;
// Do not show current date when field not required (see selectDate() method)
if (!$required && $value == '') {
$value = '-1';
}
if ($mode == 1) {
// search filter on a date extrafield shows two inputs to select a date range
$prefill = array(
'start' => isset($value['start']) ? $value['start'] : '',
'end' => isset($value['end']) ? $value['end'] : ''
);
$out = '<div ' . ($moreparam ? $moreparam : '') . '><div class="nowrap">';
$out .= $form->selectDate($prefill['start'], $keyprefix.$key.$keysuffix.'_start', 1, 1, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"), 'tzuserrel');
$out .= '</div><div class="nowrap">';
$out .= $form->selectDate($prefill['end'], $keyprefix.$key.$keysuffix.'_end', 1, 1, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"), 'tzuserrel');
$out .= '</div></div>';
} else {
// TODO Must also support $moreparam
$out = $form->selectDate($value, $keyprefix.$key.$keysuffix, $showtime, $showtime, $required, '', 1, (($keyprefix != 'search_' && $keyprefix != 'search_options_') ? 1 : 0), 0, 1, '', '', '', 1, '', '', 'tzuserrel');
}
} elseif (in_array($type, array('int', 'integer'))) {
$tmp = explode(',', $size); $tmp = explode(',', $size);
$newsize = $tmp[0]; $newsize = $tmp[0];
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').'>'; $out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" maxlength="'.$newsize.'" value="'.dol_escape_htmltag($value).'"'.($moreparam ? $moreparam : '').'>';
@ -1611,10 +1635,10 @@ class ExtraFields
$showsize = 0; $showsize = 0;
if ($type == 'date') { if ($type == 'date') {
$showsize = 10; $showsize = 10;
$value = dol_print_date($value, 'day'); $value = dol_print_date($value, 'day'); // For date without hour, date is always GMT for storage and output
} elseif ($type == 'datetime') { } elseif ($type == 'datetime') {
$showsize = 19; $showsize = 19;
$value = dol_print_date($value, 'dayhour'); $value = dol_print_date($value, 'dayhour', 'tzuserrel');
} elseif ($type == 'int') { } elseif ($type == 'int') {
$showsize = 10; $showsize = 10;
} elseif ($type == 'double') { } elseif ($type == 'double') {
@ -2064,12 +2088,10 @@ class ExtraFields
if (in_array($key_type, array('date'))) { if (in_array($key_type, array('date'))) {
// Clean parameters // Clean parameters
// TODO GMT date in memory must be GMT so we should add gm=true in parameters $value_key = dol_mktime(12, 0, 0, GETPOST("options_".$key."month", 'int'), GETPOST("options_".$key."day", 'int'), GETPOST("options_".$key."year", 'int'));
$value_key = dol_mktime(0, 0, 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]);
} elseif (in_array($key_type, array('datetime'))) { } elseif (in_array($key_type, array('datetime'))) {
// Clean parameters // Clean parameters
// TODO GMT date in memory must be GMT so we should add gm=true in parameters $value_key = dol_mktime(GETPOST("options_".$key."hour", 'int'), GETPOST("options_".$key."min", 'int'), GETPOST("options_".$key."sec", 'int'), GETPOST("options_".$key."month", 'int'), GETPOST("options_".$key."day", 'int'), GETPOST("options_".$key."year", 'int'), 'tzuserrel');
$value_key = dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]);
} elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) { } elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) {
$value_arr = GETPOST("options_".$key, 'array'); // check if an array $value_arr = GETPOST("options_".$key, 'array'); // check if an array
if (!empty($value_arr)) { if (!empty($value_arr)) {
@ -2134,32 +2156,33 @@ class ExtraFields
$key_type = $this->attributes[$extrafieldsobjectkey]['type'][$key]; $key_type = $this->attributes[$extrafieldsobjectkey]['type'][$key];
} }
if (in_array($key_type, array('date', 'datetime'))) { if (in_array($key_type, array('date'))) {
$dateparamname_start = $keysuffix . 'options_' . $key . $keyprefix . '_start'; $dateparamname_start = $keysuffix . 'options_' . $key . $keyprefix . '_start';
$dateparamname_end = $keysuffix . 'options_' . $key . $keyprefix . '_end'; $dateparamname_end = $keysuffix . 'options_' . $key . $keyprefix . '_end';
if (GETPOSTISSET($dateparamname_start . 'year') && GETPOSTISSET($dateparamname_end . 'year')) { if (GETPOSTISSET($dateparamname_start . 'year') && GETPOSTISSET($dateparamname_end . 'year')) {
// values provided as a date pair (start date + end date), each date being broken down as year, month, day, etc. // values provided as a date pair (start date + end date), each date being broken down as year, month, day, etc.
$value_key = array( $value_key = array(
'start' => dol_mktime( 'start' => dol_mktime(0, 0, 0, GETPOST($dateparamname_start . 'month', 'int'), GETPOST($dateparamname_start . 'day', 'int'), GETPOST($dateparamname_start . 'year', 'int')),
0, 'end' => dol_mktime(23, 59, 59, GETPOST($dateparamname_end . 'month', 'int'), GETPOST($dateparamname_end . 'day', 'int'), GETPOST($dateparamname_end . 'year', 'int'))
0,
0,
GETPOST($dateparamname_start . 'month', 'int'),
GETPOST($dateparamname_start . 'day', 'int'),
GETPOST($dateparamname_start . 'year', 'int')
),
'end' => dol_mktime(
23,
59,
59,
GETPOST($dateparamname_end . 'month', 'int'),
GETPOST($dateparamname_end . 'day', 'int'),
GETPOST($dateparamname_end . 'year', 'int')
)
); );
} elseif (GETPOSTISSET($keysuffix."options_".$key.$keyprefix."year")) { } elseif (GETPOSTISSET($keysuffix."options_".$key.$keyprefix."year")) {
// Clean parameters // Clean parameters
$value_key = dol_mktime(GETPOST($keysuffix."options_".$key.$keyprefix."hour", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."min", 'int'), 0, GETPOST($keysuffix."options_".$key.$keyprefix."month", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."day", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."year", 'int')); $value_key = dol_mktime(12, 0, 0, GETPOST($keysuffix."options_".$key.$keyprefix."month", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."day", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."year", 'int'));
} else {
continue; // Value was not provided, we should not set it.
}
} elseif (in_array($key_type, array('datetime'))) {
$dateparamname_start = $keysuffix . 'options_' . $key . $keyprefix . '_start';
$dateparamname_end = $keysuffix . 'options_' . $key . $keyprefix . '_end';
if (GETPOSTISSET($dateparamname_start . 'year') && GETPOSTISSET($dateparamname_end . 'year')) {
// values provided as a date pair (start date + end date), each date being broken down as year, month, day, etc.
$value_key = array(
'start' => dol_mktime(GETPOST($dateparamname_start . 'hour', 'int'), GETPOST($dateparamname_start . 'min', 'int'), GETPOST($dateparamname_start . 'sec', 'int'), GETPOST($dateparamname_start . 'month', 'int'), GETPOST($dateparamname_start . 'day', 'int'), GETPOST($dateparamname_start . 'year', 'int'), 'tzuserrel'),
'end' => dol_mktime(GETPOST($dateparamname_end . 'hour', 'int'), GETPOST($dateparamname_start . 'min', 'int'), GETPOST($dateparamname_start . 'sec', 'int'), GETPOST($dateparamname_end . 'month', 'int'), GETPOST($dateparamname_end . 'day', 'int'), GETPOST($dateparamname_end . 'year', 'int'), 'tzuserrel')
);
} elseif (GETPOSTISSET($keysuffix."options_".$key.$keyprefix."year")) {
// Clean parameters
$value_key = dol_mktime(GETPOST($keysuffix."options_".$key.$keyprefix."hour", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."min", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."sec", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."month", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."day", 'int'), GETPOST($keysuffix."options_".$key.$keyprefix."year", 'int'), 'tzuserrel');
} else { } else {
continue; // Value was not provided, we should not set it. continue; // Value was not provided, we should not set it.
} }

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2013-2015 Jean-François FERRY <hello@librethic.io> /* Copyright (C) 2013-2015 Jean-François FERRY <hello@librethic.io>
* Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr> * Copyright (C) 2016 Christophe Battarel <christophe@altairis.fr>
* Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr> * Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2021 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -517,7 +518,7 @@ class FormTicket
print ' selected="selected"'; print ' selected="selected"';
} elseif ($selected == $id) { } elseif ($selected == $id) {
print ' selected="selected"'; print ' selected="selected"';
} elseif ($arraytypes['use_default'] == "1" && !$empty) { } elseif ($arraytypes['use_default'] == "1" && !$selected && !$empty) {
print ' selected="selected"'; print ' selected="selected"';
} }
@ -612,7 +613,7 @@ class FormTicket
print ' selected="selected"'; print ' selected="selected"';
} elseif ($selected == $id) { } elseif ($selected == $id) {
print ' selected="selected"'; print ' selected="selected"';
} elseif ($arraycategories['use_default'] == "1" && !$empty) { } elseif ($arraycategories['use_default'] == "1" && !$selected && !$empty) {
print ' selected="selected"'; print ' selected="selected"';
} }
@ -713,7 +714,7 @@ class FormTicket
print ' selected="selected"'; print ' selected="selected"';
} elseif ($selected == $id) { } elseif ($selected == $id) {
print ' selected="selected"'; print ' selected="selected"';
} elseif ($arrayseverities['use_default'] == "1" && !$empty) { } elseif ($arrayseverities['use_default'] == "1" && !$selected && !$empty) {
print ' selected="selected"'; print ' selected="selected"';
} }

View File

@ -546,24 +546,28 @@ function dol_get_last_day($year, $month = 12, $gm = false)
* Return GMT time for last hour of a given GMT date (it replaces hours, min and second part to 23:59:59) * Return GMT time for last hour of a given GMT date (it replaces hours, min and second part to 23:59:59)
* *
* @param int $date Date GMT * @param int $date Date GMT
* @param mixed $gm False or 0 or 'tzserver' = Return date to compare with server TZ,
* True or 1 or 'gmt' to compare with GMT date.
* @return int Date for last hour of a given date * @return int Date for last hour of a given date
*/ */
function dol_get_last_hour($date) function dol_get_last_hour($date, $gm = 'tzserver')
{ {
$tmparray = dol_getdate($date); $tmparray = dol_getdate($date);
return dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year'], false); return dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year'], $gm);
} }
/** /**
* Return GMT time for first hour of a given GMT date (it removes hours, min and second part) * Return GMT time for first hour of a given GMT date (it removes hours, min and second part)
* *
* @param int $date Date * @param int $date Date GMT
* @param mixed $gm False or 0 or 'tzserver' = Return date to compare with server TZ,
* True or 1 or 'gmt' to compare with GMT date.
* @return int Date for last hour of a given date * @return int Date for last hour of a given date
*/ */
function dol_get_first_hour($date) function dol_get_first_hour($date, $gm = 'tzserver')
{ {
$tmparray = dol_getdate($date); $tmparray = dol_getdate($date);
return dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year'], false); return dol_mktime(0, 0, 0, $tmparray['mon'], $tmparray['mday'], $tmparray['year'], $gm);
} }
/** Return first day of week for a date. First day of week may be monday if option MAIN_START_WEEK is 1. /** Return first day of week for a date. First day of week may be monday if option MAIN_START_WEEK is 1.

View File

@ -4277,7 +4277,7 @@ function img_searchclear($titlealt = 'default', $other = '')
* @param string $text Text info * @param string $text Text info
* @param integer $infoonimgalt Info is shown only on alt of star picto, otherwise it is show on output after the star picto * @param integer $infoonimgalt Info is shown only on alt of star picto, otherwise it is show on output after the star picto
* @param int $nodiv No div * @param int $nodiv No div
* @param string $admin '1'=Info for admin users. '0'=Info for standard users (change only the look), 'error','xxx'=Other * @param string $admin '1'=Info for admin users. '0'=Info for standard users (change only the look), 'error', 'warning', 'xxx'=Other
* @param string $morecss More CSS ('', 'warning', 'error') * @param string $morecss More CSS ('', 'warning', 'error')
* @param string $textfordropdown Show a text to click to dropdown the info box. * @param string $textfordropdown Show a text to click to dropdown the info box.
* @return string String with info text * @return string String with info text

View File

@ -282,12 +282,10 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no
dol_print_error('', 'BadParameter'); dol_print_error('', 'BadParameter');
} }
$out = '';
$histo = array(); $histo = array();
$numaction = 0; $numaction = 0;
$now = dol_now(); $now = dol_now();
// Open DSI -- Fix order by -- Begin
$sortfield_list = explode(',', $sortfield); $sortfield_list = explode(',', $sortfield);
$sortfield_label_list = array('a.id' => 'id', 'a.datep' => 'dp', 'a.percent' => 'percent'); $sortfield_label_list = array('a.id' => 'id', 'a.datep' => 'dp', 'a.percent' => 'percent');
$sortfield_new_list = array(); $sortfield_new_list = array();
@ -297,7 +295,7 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no
$sortfield_new = implode(',', $sortfield_new_list); $sortfield_new = implode(',', $sortfield_new_list);
if (!empty($conf->agenda->enabled)) { if (!empty($conf->agenda->enabled)) {
// Recherche histo sur actioncomm // Search histo on actioncomm
if (is_object($objcon) && $objcon->id > 0) { if (is_object($objcon) && $objcon->id > 0) {
$sql = "SELECT DISTINCT a.id, a.label as label,"; $sql = "SELECT DISTINCT a.id, a.label as label,";
} else { } else {
@ -464,87 +462,97 @@ function show_ticket_messaging($conf, $langs, $db, $filterobj, $objcon = '', $no
$sql = $sql2; $sql = $sql2;
} }
//TODO Add limit in nb of results // TODO Add limit in nb of results
$sql .= $db->order($sortfield_new, $sortorder); if ($sql) { // May not be defined if module Agenda is not enabled and mailing module disabled too
$sql .= $db->order($sortfield_new, $sortorder);
dol_syslog("company.lib::show_actions_done", LOG_DEBUG); dol_syslog("company.lib::show_actions_done", LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) { if ($resql) {
$i = 0; $i = 0;
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
while ($i < $num) { while ($i < $num) {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if ($obj->type == 'action') { if ($obj->type == 'action') {
$contactaction = new ActionComm($db); $contactaction = new ActionComm($db);
$contactaction->id = $obj->id; $contactaction->id = $obj->id;
$result = $contactaction->fetchResources(); $result = $contactaction->fetchResources();
if ($result < 0) { if ($result < 0) {
dol_print_error($db); dol_print_error($db);
setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors'); setEventMessage("company.lib::show_actions_done Error fetch ressource", 'errors');
}
//if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))";
//elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))";
$tododone = '';
if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) {
$tododone = 'todo';
}
$histo[$numaction] = array(
'type'=>$obj->type,
'tododone'=>$tododone,
'id'=>$obj->id,
'datestart'=>$db->jdate($obj->dp),
'dateend'=>$db->jdate($obj->dp2),
'note'=>$obj->label,
'message'=>$obj->message,
'percent'=>$obj->percent,
'userid'=>$obj->user_id,
'login'=>$obj->user_login,
'userfirstname'=>$obj->user_firstname,
'userlastname'=>$obj->user_lastname,
'userphoto'=>$obj->user_photo,
'contact_id'=>$obj->fk_contact,
'socpeopleassigned' => $contactaction->socpeopleassigned,
'lastname'=>$obj->lastname,
'firstname'=>$obj->firstname,
'fk_element'=>$obj->fk_element,
'elementtype'=>$obj->elementtype,
// Type of event
'acode'=>$obj->acode,
'alabel'=>$obj->alabel,
'libelle'=>$obj->alabel, // deprecated
'apicto'=>$obj->apicto
);
} else {
$histo[$numaction] = array(
'type'=>$obj->type,
'tododone'=>'done',
'id'=>$obj->id,
'datestart'=>$db->jdate($obj->dp),
'dateend'=>$db->jdate($obj->dp2),
'note'=>$obj->label,
'message'=>$obj->message,
'percent'=>$obj->percent,
'acode'=>$obj->acode,
'userid'=>$obj->user_id,
'login'=>$obj->user_login,
'userfirstname'=>$obj->user_firstname,
'userlastname'=>$obj->user_lastname,
'userphoto'=>$obj->user_photo
);
} }
//if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; $numaction++;
//elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; $i++;
$tododone = '';
if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) {
$tododone = 'todo';
}
$histo[$numaction] = array(
'type'=>$obj->type,
'tododone'=>$tododone,
'id'=>$obj->id,
'datestart'=>$db->jdate($obj->dp),
'dateend'=>$db->jdate($obj->dp2),
'note'=>$obj->label,
'message'=>$obj->message,
'percent'=>$obj->percent,
'userid'=>$obj->user_id,
'login'=>$obj->user_login,
'userfirstname'=>$obj->user_firstname,
'userlastname'=>$obj->user_lastname,
'userphoto'=>$obj->user_photo,
'contact_id'=>$obj->fk_contact,
'socpeopleassigned' => $contactaction->socpeopleassigned,
'lastname'=>$obj->lastname,
'firstname'=>$obj->firstname,
'fk_element'=>$obj->fk_element,
'elementtype'=>$obj->elementtype,
// Type of event
'acode'=>$obj->acode,
'alabel'=>$obj->alabel,
'libelle'=>$obj->alabel, // deprecated
'apicto'=>$obj->apicto
);
} else {
$histo[$numaction] = array(
'type'=>$obj->type,
'tododone'=>'done',
'id'=>$obj->id,
'datestart'=>$db->jdate($obj->dp),
'dateend'=>$db->jdate($obj->dp2),
'note'=>$obj->label,
'message'=>$obj->message,
'percent'=>$obj->percent,
'acode'=>$obj->acode,
'userid'=>$obj->user_id,
'login'=>$obj->user_login,
'userfirstname'=>$obj->user_firstname,
'userlastname'=>$obj->user_lastname,
'userphoto'=>$obj->user_photo
);
} }
} else {
$numaction++; dol_print_error($db);
$i++;
} }
} else { }
dol_print_error($db);
// Set $out to sow events
$out = '';
if (empty($conf->agenda->enabled)) {
$langs->loadLangs(array("admin", "errors"));
$out = info_admin($langs->trans("WarningModuleXDisabledSoYouMayMissEventHere", $langs->transnoentitiesnoconv("Module2400Name")), 0, 0, 'warning');
} }
if (!empty($conf->agenda->enabled) || (!empty($conf->mailing->enabled) && !empty($objcon->email))) { if (!empty($conf->agenda->enabled) || (!empty($conf->mailing->enabled) && !empty($objcon->email))) {

View File

@ -161,6 +161,7 @@ class MailingTargets // This can't be abstract as it is used for some method
public function addTargetsToDatabase($mailing_id, $cibles) public function addTargetsToDatabase($mailing_id, $cibles)
{ {
global $conf; global $conf;
global $dolibarr_main_instance_unique_id;
$this->db->begin(); $this->db->begin();
@ -183,7 +184,7 @@ class MailingTargets // This can't be abstract as it is used for some method
$sql .= "'".$this->db->escape($targetarray['other'])."',"; $sql .= "'".$this->db->escape($targetarray['other'])."',";
$sql .= "'".$this->db->escape($targetarray['source_url'])."',"; $sql .= "'".$this->db->escape($targetarray['source_url'])."',";
$sql .= (empty($targetarray['source_id']) ? 'null' : "'".$this->db->escape($targetarray['source_id'])."'").","; $sql .= (empty($targetarray['source_id']) ? 'null' : "'".$this->db->escape($targetarray['source_id'])."'").",";
$sql .= "'".$this->db->escape(dol_hash($targetarray['email'].';'.$targetarray['lastname'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY))."',"; $sql .= "'".$this->db->escape(dol_hash($dolibarr_main_instance_unique_id.';'.$targetarray['email'].';'.$targetarray['lastname'].';'.$mailing_id.';'.$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY), 'md5')."',";
$sql .= "'".$this->db->escape($targetarray['source_type'])."')"; $sql .= "'".$this->db->escape($targetarray['source_type'])."')";
dol_syslog(__METHOD__, LOG_DEBUG); dol_syslog(__METHOD__, LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);

View File

@ -201,14 +201,24 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
print '<td id="'.$html_id.'" class="valuefield '.$object->element.'_extras_'.$tmpkeyextra.' wordbreak"'.(!empty($cols) ? ' colspan="'.$cols.'"' : '').'>'; print '<td id="'.$html_id.'" class="valuefield '.$object->element.'_extras_'.$tmpkeyextra.' wordbreak"'.(!empty($cols) ? ' colspan="'.$cols.'"' : '').'>';
// Convert date into timestamp format // Convert date into timestamp format
if (in_array($extrafields->attributes[$object->table_element]['type'][$tmpkeyextra], array('date', 'datetime'))) { if (in_array($extrafields->attributes[$object->table_element]['type'][$tmpkeyextra], array('date'))) {
$datenotinstring = $object->array_options['options_'.$tmpkeyextra]; $datenotinstring = $object->array_options['options_'.$tmpkeyextra];
// print 'X'.$object->array_options['options_' . $tmpkeyextra].'-'.$datenotinstring.'x'; // print 'X'.$object->array_options['options_' . $tmpkeyextra].'-'.$datenotinstring.'x';
if (!is_numeric($object->array_options['options_'.$tmpkeyextra])) { // For backward compatibility if (!is_numeric($object->array_options['options_'.$tmpkeyextra])) { // For backward compatibility
$datenotinstring = $db->jdate($datenotinstring); $datenotinstring = $db->jdate($datenotinstring);
} }
//print 'x'.$object->array_options['options_' . $tmpkeyextra].'-'.$datenotinstring.' - '.dol_print_date($datenotinstring, 'dayhour'); //print 'x'.$object->array_options['options_' . $tmpkeyextra].'-'.$datenotinstring.' - '.dol_print_date($datenotinstring, 'dayhour');
$value = GETPOSTISSET("options_".$tmpkeyextra) ? dol_mktime(GETPOST("options_".$tmpkeyextra."hour", 'int'), GETPOST("options_".$tmpkeyextra."min", 'int'), 0, GETPOST("options_".$tmpkeyextra."month", 'int'), GETPOST("options_".$tmpkeyextra."day", 'int'), GETPOST("options_".$tmpkeyextra."year", 'int')) : $datenotinstring; $value = GETPOSTISSET("options_".$tmpkeyextra) ? dol_mktime(12, 0, 0, GETPOST("options_".$tmpkeyextra."month", 'int'), GETPOST("options_".$tmpkeyextra."day", 'int'), GETPOST("options_".$tmpkeyextra."year", 'int')) : $datenotinstring;
}
if (in_array($extrafields->attributes[$object->table_element]['type'][$tmpkeyextra], array('datetime'))) {
$datenotinstring = $object->array_options['options_'.$tmpkeyextra];
// print 'X'.$object->array_options['options_' . $tmpkeyextra].'-'.$datenotinstring.'x';
if (!is_numeric($object->array_options['options_'.$tmpkeyextra])) // For backward compatibility
{
$datenotinstring = $db->jdate($datenotinstring);
}
//print 'x'.$object->array_options['options_' . $tmpkeyextra].'-'.$datenotinstring.' - '.dol_print_date($datenotinstring, 'dayhour');
$value = GETPOSTISSET("options_".$tmpkeyextra) ? dol_mktime(GETPOST("options_".$tmpkeyextra."hour", 'int'), GETPOST("options_".$tmpkeyextra."min", 'int'), GETPOST("options_".$tmpkeyextra."sec", 'int'), GETPOST("options_".$tmpkeyextra."month", 'int'), GETPOST("options_".$tmpkeyextra."day", 'int'), GETPOST("options_".$tmpkeyextra."year", 'int'), 'tzuserrel') : $datenotinstring;
} }
//TODO Improve element and rights detection //TODO Improve element and rights detection

View File

@ -104,10 +104,12 @@ if (($line->info_bits & 2) == 2) {
print '</a>'; print '</a>';
if ($line->description) { if ($line->description) {
if ($line->description == '(CREDIT_NOTE)' && $line->fk_remise_except > 0) { if ($line->description == '(CREDIT_NOTE)' && $line->fk_remise_except > 0) {
include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
$discount = new DiscountAbsolute($this->db); $discount = new DiscountAbsolute($this->db);
$discount->fetch($line->fk_remise_except); $discount->fetch($line->fk_remise_except);
print ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0)); print ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromCreditNote", $discount->getNomUrl(0));
} elseif ($line->description == '(DEPOSIT)' && $line->fk_remise_except > 0) { } elseif ($line->description == '(DEPOSIT)' && $line->fk_remise_except > 0) {
include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
$discount = new DiscountAbsolute($this->db); $discount = new DiscountAbsolute($this->db);
$discount->fetch($line->fk_remise_except); $discount->fetch($line->fk_remise_except);
print ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0)); print ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromDeposit", $discount->getNomUrl(0));
@ -115,11 +117,13 @@ if (($line->info_bits & 2) == 2) {
if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) { if (!empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) {
print ' ('.dol_print_date($discount->datec).')'; print ' ('.dol_print_date($discount->datec).')';
} }
} elseif ($line->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) { } elseif ($line->description == '(EXCESS RECEIVED)' && $objp->fk_remise_except > 0) {
include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
$discount = new DiscountAbsolute($this->db); $discount = new DiscountAbsolute($this->db);
$discount->fetch($line->fk_remise_except); $discount->fetch($line->fk_remise_except);
print ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0)); print ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessReceived", $discount->getNomUrl(0));
} elseif ($line->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) { } elseif ($line->description == '(EXCESS PAID)' && $objp->fk_remise_except > 0) {
include_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
$discount = new DiscountAbsolute($this->db); $discount = new DiscountAbsolute($this->db);
$discount->fetch($line->fk_remise_except); $discount->fetch($line->fk_remise_except);
print ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0)); print ($txt ? ' - ' : '').$langs->transnoentities("DiscountFromExcessPaid", $discount->getNomUrl(0));

View File

@ -545,13 +545,13 @@ if ($num > 0) {
print '<td class="center">'; print '<td class="center">';
if (!empty($obj->datestart)) { if (!empty($obj->datestart)) {
print dol_print_date($db->jdate($obj->datestart), 'dayhour'); print dol_print_date($db->jdate($obj->datestart), 'dayhour', 'tzserver');
} }
print '</td>'; print '</td>';
print '<td class="center">'; print '<td class="center">';
if (!empty($obj->dateend)) { if (!empty($obj->dateend)) {
print dol_print_date($db->jdate($obj->dateend), 'dayhour'); print dol_print_date($db->jdate($obj->dateend), 'dayhour', 'tzserver');
} }
print '</td>'; print '</td>';
@ -569,7 +569,7 @@ if ($num > 0) {
// Date start last run // Date start last run
print '<td class="center">'; print '<td class="center">';
if (!empty($datelastrun)) { if (!empty($datelastrun)) {
print dol_print_date($datelastrun, 'dayhoursec'); print dol_print_date($datelastrun, 'dayhoursec', 'tzserver');
} }
print '</td>'; print '</td>';

View File

@ -1009,16 +1009,7 @@ if ($action == 'create') {
$i++; $i++;
} }
print '}); print '});
jQuery("#autoreset").click(function() { console.log("Reset values to 0"); '; jQuery("#autoreset").click(function() { console.log("Reset values to 0"); jQuery(".qtyl").val(0); });
$i = 0;
while ($i < $numAsked) {
print 'jQuery("#qtyl'.$i.'").val(0);'."\n";
if (!empty($conf->productbatch->enabled)) {
print 'jQuery("#qtyl'.$i.'_'.$i.'").val(0);'."\n";
}
$i++;
}
print '});
}); });
</script>'; </script>';
@ -1252,7 +1243,7 @@ if ($action == 'create') {
$deliverableQty = min($quantityToBeDelivered, $batchStock); $deliverableQty = min($quantityToBeDelivered, $batchStock);
print '<!-- subj='.$subj.'/'.$nbofsuggested.' --><tr '.((($subj + 1) == $nbofsuggested) ? $bc[$var] : '').'>'; print '<!-- subj='.$subj.'/'.$nbofsuggested.' --><tr '.((($subj + 1) == $nbofsuggested) ? $bc[$var] : '').'>';
print '<td colspan="3" ></td><td class="center">'; print '<td colspan="3" ></td><td class="center">';
print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="'.$deliverableQty.'">'; print '<input class="qtyl" name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="'.$deliverableQty.'">';
print '</td>'; print '</td>';
print '<!-- Show details of lot -->'; print '<!-- Show details of lot -->';
@ -1284,7 +1275,7 @@ if ($action == 'create') {
} else { } else {
print '<!-- Case there is no details of lot at all -->'; print '<!-- Case there is no details of lot at all -->';
print '<tr class="oddeven"><td colspan="3"></td><td class="center">'; print '<tr class="oddeven"><td colspan="3"></td><td class="center">';
print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="0" disabled="disabled"> '; print '<input class="qtyl" name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="0" disabled="disabled"> ';
print '</td>'; print '</td>';
print '<td class="left">'; print '<td class="left">';
@ -1395,7 +1386,7 @@ if ($action == 'create') {
$deliverableQty = 0; $deliverableQty = 0;
} }
print '<!-- subj='.$subj.'/'.$nbofsuggested.' --><tr '.((($subj + 1) == $nbofsuggested) ? $bc[$var] : '').'><td colspan="3"></td><td class="center">'; print '<!-- subj='.$subj.'/'.$nbofsuggested.' --><tr '.((($subj + 1) == $nbofsuggested) ? $bc[$var] : '').'><td colspan="3"></td><td class="center">';
print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="'.$deliverableQty.'">'; print '<input class="qtyl" name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="'.$deliverableQty.'">';
print '</td>'; print '</td>';
print '<td class="left">'; print '<td class="left">';
@ -1439,7 +1430,7 @@ if ($action == 'create') {
if ($warehouse_selected_id <= 0) { // We did not force a given warehouse, so we won't have no warehouse to change qty. if ($warehouse_selected_id <= 0) { // We did not force a given warehouse, so we won't have no warehouse to change qty.
$disabled = 'disabled="disabled"'; $disabled = 'disabled="disabled"';
} }
print '<input name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="0"'.($disabled ? ' '.$disabled : '').'> '; print '<input class="qtyl" name="qtyl'.$indiceAsked.'_'.$subj.'" id="qtyl'.$indiceAsked.'_'.$subj.'" type="text" size="4" value="0"'.($disabled ? ' '.$disabled : '').'> ';
} else { } else {
print $langs->trans("NA"); print $langs->trans("NA");
} }
@ -2141,7 +2132,7 @@ if ($action == 'create') {
foreach ($lines[$i]->detail_batch as $detail_batch) { foreach ($lines[$i]->detail_batch as $detail_batch) {
print '<tr>'; print '<tr>';
// Qty to ship or shipped // Qty to ship or shipped
print '<td><input name="qtyl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->id.'" id="qtyl'.$line_id.'_'.$detail_batch->id.'" type="text" size="4" value="'.$detail_batch->qty.'"></td>'; print '<td><input class="qtyl" name="qtyl'.$detail_batch->fk_expeditiondet.'_'.$detail_batch->id.'" id="qtyl'.$line_id.'_'.$detail_batch->id.'" type="text" size="4" value="'.$detail_batch->qty.'"></td>';
// Batch number managment // Batch number managment
if ($lines[$i]->entrepot_id == 0) { if ($lines[$i]->entrepot_id == 0) {
// only show lot numbers from src warehouse when shipping from multiple warehouses // only show lot numbers from src warehouse when shipping from multiple warehouses
@ -2153,7 +2144,7 @@ if ($action == 'create') {
// add a 0 qty lot row to be able to add a lot // add a 0 qty lot row to be able to add a lot
print '<tr>'; print '<tr>';
// Qty to ship or shipped // Qty to ship or shipped
print '<td><input name="qtyl'.$line_id.'_0" id="qtyl'.$line_id.'_0" type="text" size="4" value="0"></td>'; print '<td><input class="qtyl" name="qtyl'.$line_id.'_0" id="qtyl'.$line_id.'_0" type="text" size="4" value="0"></td>';
// Batch number managment // Batch number managment
print '<td>'.$formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product).'</td>'; print '<td>'.$formproduct->selectLotStock('', 'batchl'.$line_id.'_0', '', 1, 0, $lines[$i]->fk_product).'</td>';
print '</tr>'; print '</tr>';
@ -2163,7 +2154,7 @@ if ($action == 'create') {
print '<!-- case edit 2 -->'; print '<!-- case edit 2 -->';
print '<tr>'; print '<tr>';
// Qty to ship or shipped // Qty to ship or shipped
print '<td><input name="qtyl'.$line_id.'" id="qtyl'.$line_id.'" type="text" size="4" value="'.$lines[$i]->qty_shipped.'"></td>'; print '<td><input class="qtyl" name="qtyl'.$line_id.'" id="qtyl'.$line_id.'" type="text" size="4" value="'.$lines[$i]->qty_shipped.'"></td>';
// Warehouse source // Warehouse source
print '<td>'.$formproduct->selectWarehouses($lines[$i]->entrepot_id, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).'</td>'; print '<td>'.$formproduct->selectWarehouses($lines[$i]->entrepot_id, 'entl'.$line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).'</td>';
// Batch number managment // Batch number managment
@ -2174,7 +2165,7 @@ if ($action == 'create') {
foreach ($lines[$i]->details_entrepot as $detail_entrepot) { foreach ($lines[$i]->details_entrepot as $detail_entrepot) {
print '<tr>'; print '<tr>';
// Qty to ship or shipped // Qty to ship or shipped
print '<td><input name="qtyl'.$detail_entrepot->line_id.'" id="qtyl'.$detail_entrepot->line_id.'" type="text" size="4" value="'.$detail_entrepot->qty_shipped.'"></td>'; print '<td><input class="qtyl" name="qtyl'.$detail_entrepot->line_id.'" id="qtyl'.$detail_entrepot->line_id.'" type="text" size="4" value="'.$detail_entrepot->qty_shipped.'"></td>';
// Warehouse source // Warehouse source
print '<td>'.$formproduct->selectWarehouses($detail_entrepot->entrepot_id, 'entl'.$detail_entrepot->line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).'</td>'; print '<td>'.$formproduct->selectWarehouses($detail_entrepot->entrepot_id, 'entl'.$detail_entrepot->line_id, '', 1, 0, $lines[$i]->fk_product, '', 1).'</td>';
// Batch number managment // Batch number managment
@ -2189,7 +2180,7 @@ if ($action == 'create') {
print '<!-- case edit 5 -->'; print '<!-- case edit 5 -->';
print '<tr>'; print '<tr>';
// Qty to ship or shipped // Qty to ship or shipped
print '<td><input name="qtyl'.$line_id.'" id="qtyl'.$line_id.'" type="text" size="4" value="'.$lines[$i]->qty_shipped.'"></td>'; print '<td><input class="qtyl" name="qtyl'.$line_id.'" id="qtyl'.$line_id.'" type="text" size="4" value="'.$lines[$i]->qty_shipped.'"></td>';
// Warehouse source // Warehouse source
print '<td></td>'; print '<td></td>';
// Batch number managment // Batch number managment

View File

@ -292,3 +292,4 @@ WarningFailedToAddFileIntoDatabaseIndex=Warning, failed to add file entry into E
WarningTheHiddenOptionIsOn=Warning, the hidden option <b>%s</b> is on. WarningTheHiddenOptionIsOn=Warning, the hidden option <b>%s</b> is on.
WarningCreateSubAccounts=Warning, you can't create directly a sub account, you must create a third party or an user and assign them an accounting code to find them in this list WarningCreateSubAccounts=Warning, you can't create directly a sub account, you must create a third party or an user and assign them an accounting code to find them in this list
WarningAvailableOnlyForHTTPSServers=Available only if using HTTPS secured connection. WarningAvailableOnlyForHTTPSServers=Available only if using HTTPS secured connection.
WarningModuleXDisabledSoYouMayMissEventHere=Module %s has not been enabled. So you may miss a lot of event here.

View File

@ -96,7 +96,7 @@ class Mo extends CommonObject
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",),
'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'position'=>5, 'notnull'=>1, 'default'=>'1', 'index'=>1), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'position'=>5, 'notnull'=>1, 'default'=>'1', 'index'=>1),
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1', 'noteditable'=>1), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>4, 'position'=>10, 'notnull'=>1, 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'showoncombobox'=>'1', 'noteditable'=>1),
'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0:t.status=1', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM", 'css'=>'maxwidth300'), 'fk_bom' => array('type'=>'integer:Bom:bom/class/bom.class.php:0:t.status=1', 'filter'=>'active=1', 'label'=>'BOM', 'enabled'=>1, 'visible'=>1, 'position'=>33, 'notnull'=>-1, 'index'=>1, 'comment'=>"Original BOM", 'css'=>'minwidth100 maxwidth300'),
'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:0', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce", 'css'=>'maxwidth300', 'picto'=>'product'), 'fk_product' => array('type'=>'integer:Product:product/class/product.class.php:0', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>35, 'notnull'=>1, 'index'=>1, 'comment'=>"Product to produce", 'css'=>'maxwidth300', 'picto'=>'product'),
'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'comment'=>"Qty to produce", 'css'=>'width75', 'default'=>1, 'isameasure'=>1), 'qty' => array('type'=>'real', 'label'=>'QtyToProduce', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>1, 'comment'=>"Qty to produce", 'css'=>'width75', 'default'=>1, 'isameasure'=>1),
'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>42, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'1',), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>42, 'notnull'=>-1, 'searchall'=>1, 'showoncombobox'=>'1',),

View File

@ -76,7 +76,7 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
// Default sort order (if not yet defined by previous GETPOST) // Default sort order (if not yet defined by previous GETPOST)
if (!$sortfield) { if (!$sortfield) {
$sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. $sortfield = "t.ref"; // Set here default search field. By default 1st field in definition.
} }
if (!$sortorder) { if (!$sortorder) {
$sortorder = "ASC"; $sortorder = "ASC";

View File

@ -133,18 +133,24 @@ if (empty($reshook)) {
$backurlforlist = dol_buildpath('/product/stock/productlot_list.php', 1); $backurlforlist = dol_buildpath('/product/stock/productlot_list.php', 1);
if ($action == 'seteatby' && $user->rights->stock->creer) { if ($action == 'seteatby' && $user->rights->stock->creer) {
$newvalue = dol_mktime(12, 0, 0, $_POST['eatbymonth'], $_POST['eatbyday'], $_POST['eatbyyear']); $newvalue = dol_mktime(12, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int'));
$result = $object->setValueFrom('eatby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); $result = $object->setValueFrom('eatby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
if ($result < 0) { if ($result < 0) {
dol_print_error($db, $object->error); setEventMessages($object->error, null, 'errors');
$action == 'editeatby';
} else {
$action = 'view';
} }
} }
if ($action == 'setsellby' && $user->rights->stock->creer) { if ($action == 'setsellby' && $user->rights->stock->creer) {
$newvalue = dol_mktime(12, 0, 0, $_POST['sellbymonth'], $_POST['sellbyday'], $_POST['sellbyyear']); $newvalue = dol_mktime(12, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int'));
$result = $object->setValueFrom('sellby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); $result = $object->setValueFrom('sellby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY');
if ($result < 0) { if ($result < 0) {
dol_print_error($db, $object->error); setEventMessages($object->error, null, 'errors');
$action == 'editsellby';
} else {
$action = 'view';
} }
} }
@ -172,8 +178,9 @@ if (empty($reshook)) {
} }
} }
if ($error) if ($error) {
$action = 'edit_extras'; $action = 'edit_extras';
}
} }
// Action to add record // Action to add record
@ -415,7 +422,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</tr>'; print '</tr>';
} }
// Other attributes. Fields from hook formObjectOptions and Extrafields. // Other attributes
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
print '</table>'; print '</table>';

View File

@ -46,6 +46,9 @@ if (!defined('NOREQUIREMENU')) {
if (!defined('NOIPCHECK')) { if (!defined('NOIPCHECK')) {
define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
} }
if (!defined("NOSESSION")) {
define("NOSESSION", '1');
}
/** /**
* Header empty * Header empty
@ -67,6 +70,8 @@ function llxFooter()
require '../../main.inc.php'; require '../../main.inc.php';
$mtid = GETPOST('mtid');
$email = GETPOST('email');
$tag = GETPOST('tag'); $tag = GETPOST('tag');
$securitykey = GETPOST('securitykey'); $securitykey = GETPOST('securitykey');
@ -83,23 +88,55 @@ if ($securitykey != $conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) {
} }
if (!empty($tag)) { if (!empty($tag)) {
$statut = '2'; dol_syslog("public/emailing/mailing-read.php : Update status of email target and thirdparty for tag ".$tag, LOG_DEBUG);
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles SET statut=".$statut." WHERE tag='".$db->escape($tag)."'";
dol_syslog("public/emailing/mailing-read.php : Mail read : ".$sql, LOG_DEBUG); $sql = "SELECT mc.rowid, mc.email, mc.statut, mc.source_type, mc.source_id, m.entity";
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."mailing as m";
$sql .= " WHERE mc.fk_mailing = m.rowid AND mc.tag='".$db->escape($tag)."'";
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) dol_print_error($db);
$obj = $db->fetch_object($resql);
if (empty($obj)) {
print 'Email target not valid. Operation canceled.';
exit;
}
if (empty($obj->email)) {
print 'Email target not valid. Operation canceled.';
exit;
}
if ($obj->statut == 2 || $obj->statut == 3) {
print 'Email target already set to read or unsubscribe. Operation canceled.';
exit;
}
// TODO Test that mtid and email match also with the one found from $tag
/*
if ($obj->email != $email)
{
print 'Email does not match tagnot found. No need to unsubscribe.';
exit;
}
*/
//Update status of target
$statut = '2';
$sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles SET statut=".$statut." WHERE rowid = ".((int) $obj->rowid);
$resql = $db->query($sql);
if (!$resql) dol_print_error($db);
//Update status communication of thirdparty prospect //Update status communication of thirdparty prospect
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=3 WHERE fk_stcomm != -1 AND rowid IN (SELECT source_id FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE tag='".$db->escape($tag)."' AND source_type='thirdparty' AND source_id is not null)"; if ($obj->source_id > 0 && $obj->source_type == 'thirdparty' && $obj->entity) {
dol_syslog("public/emailing/mailing-read.php : Mail read thirdparty : ".$sql, LOG_DEBUG); $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid = '.$obj->source_id;
$resql = $db->query($sql);
$resql = $db->query($sql); }
//Update status communication of contact prospect //Update status communication of contact prospect
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=3 WHERE fk_stcomm != -1 AND rowid IN (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."socpeople AS sc INNER JOIN ".MAIN_DB_PREFIX."mailing_cibles AS mc ON mc.tag = '".$db->escape($tag)."' AND mc.source_type = 'contact' AND mc.source_id = sc.rowid)"; if ($obj->source_id > 0 && $obj->source_type == 'contact' && $obj->entity) {
dol_syslog("public/emailing/mailing-read.php : Mail read contact : ".$sql, LOG_DEBUG); $sql = "UPDATE ".MAIN_DB_PREFIX.'societe SET fk_stcomm = 3 WHERE fk_stcomm <> -1 AND entity = '.$obj->entity.' AND rowid IN (SELECT sc.fk_soc FROM '.MAIN_DB_PREFIX.'socpeople AS sc WHERE sc.rowid = '.$obj->source_id.')';
$resql = $db->query($sql);
$resql = $db->query($sql); }
} }
$db->close(); $db->close();

View File

@ -42,6 +42,9 @@ if (!defined('NOREQUIREMENU')) {
if (!defined('NOIPCHECK')) { if (!defined('NOIPCHECK')) {
define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip
} }
if (!defined("NOSESSION")) {
define("NOSESSION", '1');
}
/** /**
* Header empty * Header empty
@ -68,6 +71,8 @@ global $user, $conf, $langs;
$langs->loadLangs(array("main", "mails")); $langs->loadLangs(array("main", "mails"));
$mtid = GETPOST('mtid');
$email = GETPOST('email');
$tag = GETPOST('tag'); $tag = GETPOST('tag');
$unsuscrib = GETPOST('unsuscrib'); $unsuscrib = GETPOST('unsuscrib');
$securitykey = GETPOST('securitykey'); $securitykey = GETPOST('securitykey');
@ -88,7 +93,7 @@ if ($securitykey != $conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY) {
if (!empty($tag) && ($unsuscrib == '1')) { if (!empty($tag) && ($unsuscrib == '1')) {
dol_syslog("public/emailing/mailing-unsubscribe.php : Launch unsubscribe requests", LOG_DEBUG); dol_syslog("public/emailing/mailing-unsubscribe.php : Launch unsubscribe requests", LOG_DEBUG);
$sql = "SELECT mc.email, m.entity"; $sql = "SELECT mc.rowid, mc.email, mc.statut, m.entity";
$sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."mailing as m"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."mailing as m";
$sql .= " WHERE mc.fk_mailing = m.rowid AND mc.tag='".$db->escape($tag)."'"; $sql .= " WHERE mc.fk_mailing = m.rowid AND mc.tag='".$db->escape($tag)."'";
@ -99,10 +104,26 @@ if (!empty($tag) && ($unsuscrib == '1')) {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if (empty($obj->email)) { if (empty($obj)) {
print 'Email not found. No need to unsubscribe.'; print 'Email target not valid. Operation canceled.';
exit; exit;
} }
if (empty($obj->email)) {
print 'Email target not valid. Operation canceled.';
exit;
}
if ($obj->statut == 3) {
print 'Email target already set to unsubscribe. Operation canceled.';
exit;
}
// TODO Test that mtid and email match also with the one found from $tag
/*
if ($obj->email != $email)
{
print 'Email does not match tagnot found. No need to unsubscribe.';
exit;
}
*/
// Update status of mail in recipient mailing list table // Update status of mail in recipient mailing list table
$statut = '3'; $statut = '3';
@ -128,7 +149,7 @@ if (!empty($tag) && ($unsuscrib == '1')) {
*/ */
// Update status communication of email (new usage) // Update status communication of email (new usage)
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe (date_creat, entity, email) VALUES ('".$db->idate(dol_now())."', ".$db->escape($obj->entity).", '".$db->escape($obj->email)."')"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."mailing_unsubscribe (date_creat, entity, email, unsubscribegroup, ip) VALUES ('".$db->idate(dol_now())."', ".$db->escape($obj->entity).", '".$db->escape($obj->email)."', '', '".$db->escape(getUserRemoteIP())."')";
$resql = $db->query($sql); $resql = $db->query($sql);
//if (! $resql) dol_print_error($db); No test on errors, may fail if already unsubscribed //if (! $resql) dol_print_error($db); No test on errors, may fail if already unsubscribed

View File

@ -126,14 +126,15 @@ class FactureRecTest extends PHPUnit\Framework\TestCase
print __METHOD__."\n"; print __METHOD__."\n";
} }
/** /**
* testFactureCreate * testFactureRecCreate
* *
* @return int * @return int
*/ */
public function testFactureRecCreate() public function testFactureRecCreate()
{ {
global $conf,$user,$langs,$db; global $conf,$user,$langs,$db;
$conf=$this->savconf; $conf=$this->savconf;
$user=$this->savuser; $user=$this->savuser;
$langs=$this->savlangs; $langs=$this->savlangs;
@ -141,36 +142,66 @@ class FactureRecTest extends PHPUnit\Framework\TestCase
$localobjectinv=new Facture($this->savdb); $localobjectinv=new Facture($this->savdb);
$localobjectinv->initAsSpecimen(); $localobjectinv->initAsSpecimen();
$localobjectinv->create($user); $result = $localobjectinv->create($user);
print __METHOD__." result=".$result."\n";
$localobject=new FactureRec($this->savdb); $localobject=new FactureRec($this->savdb);
$localobject->initAsSpecimen(); $localobject->initAsSpecimen();
$result=$localobject->create($user, $localobjectinv->id); $result = $localobject->create($user, $localobjectinv->id);
$this->assertLessThan($result, 0); print __METHOD__." result=".$result."\n";
print __METHOD__." result=".$result."\n"; $this->assertGreaterThan(0, $result, 'Create recurring invoice from common invoice');
return $result;
}
/** return $result;
* Edit an object to test updates }
*
* @param Facture $localobject Object Facture
* @return void
*/
public function changeProperties(&$localobject)
{
$localobject->note_private='New note';
//$localobject->note='New note after update';
}
/** /**
* Compare all public properties values of 2 objects * testFactureRecFetch
* *
* @param Object $oA Object operand 1 * @param int $id Id of created recuriing invoice
* @param Object $oB Object operand 2 * @return int
* @param boolean $ignoretype False will not report diff if type of value differs *
* @param array $fieldstoignorearray Array of fields to ignore in diff * @depends testFactureRecCreate
* The depends says test is run only if previous is ok
*/
public function testFactureRecFetch($id)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new FactureRec($this->savdb);
$result = $localobject->fetch($id);
print __METHOD__." result=".$result."\n";
$this->assertGreaterThan(0, $result);
return $result;
}
/**
* Edit an object to test updates
*
* @param FactureRec $localobject Object Facture rec
* @return void
*/
public function changeProperties(&$localobject)
{
$localobject->note_private='New note';
//$localobject->note='New note after update';
}
/**
* Compare all public properties values of 2 objects
*
* @param Object $oA Object operand 1
* @param Object $oB Object operand 2
* @param boolean $ignoretype False will not report diff if type of value differs
* @param array $fieldstoignorearray Array of fields to ignore in diff
* @return array Array with differences * @return array Array with differences
*/ */
public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id')) public function objCompare($oA, $oB, $ignoretype = true, $fieldstoignorearray = array('id'))