From cb736f5b93da0bb25f8caffe824cd148fb0e251e Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Wed, 21 Sep 2016 12:05:18 +0200 Subject: [PATCH 01/53] Add update_total function (like on other element) the goal is to have and use the same function in all the native standard element (proposal, order, bill / customer and fournish) --- .../fourn/class/fournisseur.facture.class.php | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 4a9960d49a4..604141cb1cf 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2481,6 +2481,38 @@ class SupplierInvoiceLine extends CommonObjectLine $this->db->rollback(); return -2; } - } -} + + /** + * Mise a jour de l'objet ligne de commande en base + * + * @return int <0 si ko, >0 si ok + */ + function update_total() + { + $this->db->begin(); + // Mise a jour ligne en base + $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET"; + $sql.= " total_ht='".price2num($this->total_ht)."'"; + $sql.= ", tva='".price2num($this->total_tva)."'"; + $sql.= ", total_localtax1='".price2num($this->total_localtax1)."'"; + $sql.= ", total_localtax2='".price2num($this->total_localtax2)."'"; + $sql.= ", total_ttc='".price2num($this->total_ttc)."'"; + $sql.= " WHERE rowid = ".$this->rowid; + + dol_syslog("CommandeFournisseurLigne.class.php::update_total", LOG_DEBUG); + + $resql=$this->db->query($sql); + if ($resql) + { + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -2; + } + } + } From c713eb987e05441c22fc842b78808dede87d78c9 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Wed, 21 Sep 2016 12:06:39 +0200 Subject: [PATCH 02/53] Update fournisseur.facture.class.php --- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 604141cb1cf..579e923f802 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2481,7 +2481,7 @@ class SupplierInvoiceLine extends CommonObjectLine $this->db->rollback(); return -2; } - + } /** * Mise a jour de l'objet ligne de commande en base * From f826013cb382918f6e8984d65894bb0ed7c79761 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Wed, 21 Sep 2016 12:07:43 +0200 Subject: [PATCH 03/53] Update fournisseur.facture.class.php --- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 579e923f802..23223f1e9ec 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2500,7 +2500,7 @@ class SupplierInvoiceLine extends CommonObjectLine $sql.= ", total_ttc='".price2num($this->total_ttc)."'"; $sql.= " WHERE rowid = ".$this->rowid; - dol_syslog("CommandeFournisseurLigne.class.php::update_total", LOG_DEBUG); + dol_syslog("FactureFournisseurLigne.class.php::update_total", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) From 41b6101a753aad7d16483b8cb3dd7a5d38e27943 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Mon, 3 Oct 2016 20:41:39 +0200 Subject: [PATCH 04/53] Work on supplier type (Replacement / deposit / credit note) invoice --- htdocs/fourn/facture/card.php | 604 ++++++++++++++++++++++------------ 1 file changed, 393 insertions(+), 211 deletions(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 5c6f21194a6..2a7d1e14d88 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -355,243 +355,425 @@ if (empty($reshook)) // Create elseif ($action == 'add' && $user->rights->fournisseur->facture->creer) { - $error=0; + if ($socid > 0) $object->socid = GETPOST('socid', 'int'); - $datefacture=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); - $datedue=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); + $db->begin(); - if (GETPOST('socid','int')<1) - { - setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('Supplier')), null, 'errors'); - $action='create'; - $error++; - } + $error = 0; - if ($datefacture == '') - { - setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('DateInvoice')), null, 'errors'); - $action='create'; - $_GET['socid']=$_POST['socid']; - $error++; - } - if (! GETPOST('ref_supplier')) - { - setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('RefSupplier')), null, 'errors'); - $action='create'; - $_GET['socid']=$_POST['socid']; - $error++; - } + // Fill array 'array_options' with data from add form + $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) $error++; - // Fill array 'array_options' with data from add form + $datefacture=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); + $datedue=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); - if (! $error) - { - $db->begin(); + // Replacement invoice + if ($_POST['type'] == FactureFournisseur::TYPE_REPLACEMENT) + { + if ($datefacture == '') + { + setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('DateInvoice')), null, 'errors'); + $action='create'; + $_GET['socid']=$_POST['socid']; + $error++; + } + if (! ($_POST['fac_replacement'] > 0)) { + $error ++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ReplaceInvoice")), null, 'errors'); + } - $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); - if ($ret < 0) $error++; + if (! $error) { + // This is a replacement invoice + $result = $object->fetch($_POST['fac_replacement']); + $object->fetch_thirdparty(); - $tmpproject = GETPOST('projectid', 'int'); + $object->ref = $_POST['ref']; + $object->ref_supplier = $_POST['ref_supplier']; + $object->socid = $_POST['socid']; + $object->libelle = $_POST['label']; + $object->date = $datefacture; + $object->date_echeance = $datedue; + $object->note_public = GETPOST('note_public'); + $object->note_private = GETPOST('note_private'); + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->fk_account = GETPOST('fk_account', 'int'); + $object->fk_project = ($tmpproject > 0) ? $tmpproject : null; + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); + $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); + $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); - // Creation facture - $object->ref = $_POST['ref']; - $object->ref_supplier = $_POST['ref_supplier']; - $object->socid = $_POST['socid']; - $object->libelle = $_POST['label']; - $object->date = $datefacture; - $object->date_echeance = $datedue; - $object->note_public = GETPOST('note_public'); - $object->note_private = GETPOST('note_private'); - $object->cond_reglement_id = GETPOST('cond_reglement_id'); - $object->mode_reglement_id = GETPOST('mode_reglement_id'); - $object->fk_account = GETPOST('fk_account', 'int'); - $object->fk_project = ($tmpproject > 0) ? $tmpproject : null; - $object->fk_incoterms = GETPOST('incoterm_id', 'int'); - $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); - $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); - $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); + // Proprietes particulieres a facture de remplacement + $object->fk_facture_source = $_POST['fac_replacement']; + $object->type = FactureFournisseur::TYPE_REPLACEMENT; - // Auto calculation of date due if not filled by user - if(empty($object->date_echeance)) $object->date_echeance = $object->calculate_date_lim_reglement(); + $id = $object->createFromCurrent($user); + if ($id <= 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + } - // If creation from another object of another module - if (! $error && $_POST['origin'] && $_POST['originid']) - { - // Parse element/subelement (ex: project_task) - $element = $subelement = $_POST['origin']; - /*if (preg_match('/^([^_]+)_([^_]+)/i',$_POST['origin'],$regs)) - { - $element = $regs[1]; - $subelement = $regs[2]; - }*/ + // Credit note invoice + if ($_POST['type'] == FactureFournisseur::TYPE_CREDIT_NOTE) + { + $sourceinvoice = GETPOST('fac_avoir'); + if (! ($sourceinvoice > 0) && empty($conf->global->INVOICE_CREDIT_NOTE_STANDALONE)) + { + $error ++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("CorrectInvoice")), null, 'errors'); + } + if (GETPOST('socid','int')<1) + { + setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('Supplier')), null, 'errors'); + $action='create'; + $error++; + } + if ($datefacture == '') + { + setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('DateInvoice')), null, 'errors'); + $action='create'; + $_GET['socid']=$_POST['socid']; + $error++; + } + if (! GETPOST('ref_supplier')) + { + setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('RefSupplier')), null, 'errors'); + $action='create'; + $_GET['socid']=$_POST['socid']; + $error++; + } - // For compatibility - if ($element == 'order') { - $element = $subelement = 'commande'; - } - if ($element == 'propal') { - $element = 'comm/propal'; $subelement = 'propal'; - } - if ($element == 'contract') { - $element = $subelement = 'contrat'; - } - if ($element == 'order_supplier') { - $element = 'fourn'; $subelement = 'fournisseur.commande'; - } - if ($element == 'project') - { - $element = 'projet'; - } - $object->origin = $_POST['origin']; - $object->origin_id = $_POST['originid']; + if (! $error) + { + $tmpproject = GETPOST('projectid', 'int'); - $id = $object->create($user); + // Creation facture + $object->ref = $_POST['ref']; + $object->ref_supplier = $_POST['ref_supplier']; + $object->socid = $_POST['socid']; + $object->libelle = $_POST['label']; + $object->date = $datefacture; + $object->date_echeance = $datedue; + $object->note_public = GETPOST('note_public'); + $object->note_private = GETPOST('note_private'); + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->fk_account = GETPOST('fk_account', 'int'); + $object->fk_project = ($tmpproject > 0) ? $tmpproject : null; + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); + $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); + $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); - // Add lines - if ($id > 0) - { - require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; - $classname = ucfirst($subelement); - if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; - $srcobject = new $classname($db); + // Proprietes particulieres a facture avoir + $object->fk_facture_source = $sourceinvoice > 0 ? $sourceinvoice : ''; + $object->type = FactureFournisseur::TYPE_CREDIT_NOTE; - $result=$srcobject->fetch($_POST['originid']); - if ($result > 0) - { - $lines = $srcobject->lines; - if (empty($lines) && method_exists($srcobject,'fetch_lines')) - { - $srcobject->fetch_lines(); - $lines = $srcobject->lines; - } + $id = $object->create($user); - $num=count($lines); - for ($i = 0; $i < $num; $i++) - { - $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); - $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + if (GETPOST('invoiceAvoirWithLines', 'int')==1 && $id>0) + { + $facture_source = new FactureFournisseur($db); // fetch origin object + if ($facture_source->fetch($object->fk_facture_source)>0) + { + $fk_parent_line = 0; - // Dates - // TODO mutualiser - $date_start=$lines[$i]->date_debut_prevue; - if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; - if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; - $date_end=$lines[$i]->date_fin_prevue; - if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; - if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + foreach($facture_source->lines as $line) + { + // Reset fk_parent_line for no child products and special product + if (($line->product_type != 9 && empty($line->fk_parent_line)) || $line->product_type == 9) { + $fk_parent_line = 0; + } - // FIXME Missing $lines[$i]->ref_supplier and $lines[$i]->label into addline and updateline methods. They are filled when coming from order for example. - $result = $object->addline( - $desc, - $lines[$i]->subprice, - $lines[$i]->tva_tx, - $lines[$i]->localtax1_tx, - $lines[$i]->localtax2_tx, - $lines[$i]->qty, - $lines[$i]->fk_product, - $lines[$i]->remise_percent, - $date_start, - $date_end, - 0, - $lines[$i]->info_bits, - 'HT', - $product_type, - $lines[$i]->rang, - 0, - $lines[$i]->array_options, - $lines[$i]->fk_unit, - $lines[$i]->id - ); + $line->fk_facture = $object->id; + $line->fk_parent_line = $fk_parent_line; - if ($result < 0) - { - $error++; - break; - } - } + $line->subprice =-$line->subprice; // invert price for object + $line->pa_ht = -$line->pa_ht; + $line->total_ht=-$line->total_ht; + $line->total_tva=-$line->total_tva; + $line->total_ttc=-$line->total_ttc; + $line->total_localtax1=-$line->total_localtax1; + $line->total_localtax2=-$line->total_localtax2; - // Now reload line - $object->fetch_lines(); - } - else - { - $error++; - } - } - else - { - $error++; - } - } - else if (! $error) - { - $id = $object->create($user); - if ($id < 0) - { - $error++; - } + $result = $line->insert(); - if (! $error) - { - // If some invoice's lines already known - for ($i = 1 ; $i < 9 ; $i++) - { - $label = $_POST['label'.$i]; - $amountht = price2num($_POST['amount'.$i]); - $amountttc = price2num($_POST['amountttc'.$i]); - $tauxtva = price2num($_POST['tauxtva'.$i]); - $qty = $_POST['qty'.$i]; - $fk_product = $_POST['fk_product'.$i]; - if ($label) - { - if ($amountht) - { - $price_base='HT'; $amount=$amountht; - } - else - { - $price_base='TTC'; $amount=$amountttc; - } - $atleastoneline=1; + $object->lines[] = $line; // insert new line in current object - $product=new Product($db); - $product->fetch($_POST['idprod'.$i]); + // Defined the new fk_parent_line + if ($result > 0 && $line->product_type == 9) { + $fk_parent_line = $result; + } + } - $ret=$object->addline($label, $amount, $tauxtva, $product->localtax1_tx, $product->localtax2_tx, $qty, $fk_product, $remise_percent, '', '', '', 0, $price_base, $_POST['rang'.$i], 1); - if ($ret < 0) $error++; - } - } - } - } + $object->update_price(1); + } - if ($error) - { - $langs->load("errors"); - $db->rollback(); + } - setEventMessages($object->error, $object->errors, 'errors'); - $action='create'; - $_GET['socid']=$_POST['socid']; - } - else - { - $db->commit(); + if(GETPOST('invoiceAvoirWithPaymentRestAmount', 'int')==1 && $id>0) + { + $facture_source = new FactureFournisseur($db); // fetch origin object if not previously defined + if ($facture_source->fetch($object->fk_facture_source)>0) + { + $totalpaye = $facture_source->getSommePaiement(); + $totalcreditnotes = $facture_source->getSumCreditNotesUsed(); + $totaldeposits = $facture_source->getSumDepositsUsed(); + $remain_to_pay = abs($facture_source->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits); - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - $outputlangs = $langs; - $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result < 0) - { - dol_print_error($db,$object->error,$object->errors); - exit; - } - } + $object->addline($langs->trans('invoiceAvoirLineWithPaymentRestAmount'),$remain_to_pay,1,0,0,0,0,0,'','','TTC'); + } + } - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); - exit; - } - } + // Add predefined lines + /* + TODO delete + for($i = 1; $i <= $NBLINES; $i ++) { + if ($_POST['idprod' . $i]) { + $product = new Product($db); + $product->fetch($_POST['idprod' . $i]); + $startday = dol_mktime(12, 0, 0, $_POST['date_start' . $i . 'month'], $_POST['date_start' . $i . 'day'], $_POST['date_start' . $i . 'year']); + $endday = dol_mktime(12, 0, 0, $_POST['date_end' . $i . 'month'], $_POST['date_end' . $i . 'day'], $_POST['date_end' . $i . 'year']); + $result = $object->addline($product->description, $product->price, $_POST['qty' . $i], $product->tva_tx, $product->localtax1_tx, $product->localtax2_tx, $_POST['idprod' . $i], $_POST['remise_percent' . $i], $startday, $endday, 0, 0, '', $product->price_base_type, $product->price_ttc, $product->type); + } + }*/ + } + } + + // Standard or deposit + if ($_POST['type'] == FactureFournisseur::TYPE_STANDARD || $_POST['type'] == FactureFournisseur::TYPE_DEPOSIT) + { + if (GETPOST('socid','int')<1) + { + setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('Supplier')), null, 'errors'); + $action='create'; + $error++; + } + + if ($datefacture == '') + { + setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('DateInvoice')), null, 'errors'); + $action='create'; + $_GET['socid']=$_POST['socid']; + $error++; + } + if (! GETPOST('ref_supplier')) + { + setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('RefSupplier')), null, 'errors'); + $action='create'; + $_GET['socid']=$_POST['socid']; + $error++; + } + + if (! $error) + { + $db->begin(); + + $tmpproject = GETPOST('projectid', 'int'); + + // Creation facture + $object->ref = $_POST['ref']; + $object->ref_supplier = $_POST['ref_supplier']; + $object->socid = $_POST['socid']; + $object->libelle = $_POST['label']; + $object->date = $datefacture; + $object->date_echeance = $datedue; + $object->note_public = GETPOST('note_public'); + $object->note_private = GETPOST('note_private'); + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->fk_account = GETPOST('fk_account', 'int'); + $object->fk_project = ($tmpproject > 0) ? $tmpproject : null; + $object->fk_incoterms = GETPOST('incoterm_id', 'int'); + $object->location_incoterms = GETPOST('location_incoterms', 'alpha'); + $object->multicurrency_code = GETPOST('multicurrency_code', 'alpha'); + $object->multicurrency_tx = GETPOST('originmulticurrency_tx', 'int'); + + // Auto calculation of date due if not filled by user + if(empty($object->date_echeance)) $object->date_echeance = $object->calculate_date_lim_reglement(); + + // If creation from another object of another module + if (! $error && $_POST['origin'] && $_POST['originid']) + { + // Parse element/subelement (ex: project_task) + $element = $subelement = $_POST['origin']; + /*if (preg_match('/^([^_]+)_([^_]+)/i',$_POST['origin'],$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + }*/ + + // For compatibility + if ($element == 'order') { + $element = $subelement = 'commande'; + } + if ($element == 'propal') { + $element = 'comm/propal'; $subelement = 'propal'; + } + if ($element == 'contract') { + $element = $subelement = 'contrat'; + } + if ($element == 'order_supplier') { + $element = 'fourn'; $subelement = 'fournisseur.commande'; + } + if ($element == 'project') + { + $element = 'projet'; + } + $object->origin = $_POST['origin']; + $object->origin_id = $_POST['originid']; + + $id = $object->create($user); + + // Add lines + if ($id > 0) + { + require_once DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'; + $classname = ucfirst($subelement); + if ($classname == 'Fournisseur.commande') $classname='CommandeFournisseur'; + $srcobject = new $classname($db); + + $result=$srcobject->fetch($_POST['originid']); + if ($result > 0) + { + $lines = $srcobject->lines; + if (empty($lines) && method_exists($srcobject,'fetch_lines')) + { + $srcobject->fetch_lines(); + $lines = $srcobject->lines; + } + + $num=count($lines); + for ($i = 0; $i < $num; $i++) + { + $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); + $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + + // Dates + // TODO mutualiser + $date_start=$lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; + $date_end=$lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + + // FIXME Missing $lines[$i]->ref_supplier and $lines[$i]->label into addline and updateline methods. They are filled when coming from order for example. + $result = $object->addline( + $desc, + $lines[$i]->subprice, + $lines[$i]->tva_tx, + $lines[$i]->localtax1_tx, + $lines[$i]->localtax2_tx, + $lines[$i]->qty, + $lines[$i]->fk_product, + $lines[$i]->remise_percent, + $date_start, + $date_end, + 0, + $lines[$i]->info_bits, + 'HT', + $product_type, + $lines[$i]->rang, + 0, + $lines[$i]->array_options, + $lines[$i]->fk_unit, + $lines[$i]->id + ); + + if ($result < 0) + { + $error++; + break; + } + } + + // Now reload line + $object->fetch_lines(); + } + else + { + $error++; + } + } + else + { + $error++; + } + } + else if (! $error) + { + $id = $object->create($user); + if ($id < 0) + { + $error++; + } + + if (! $error) + { + // If some invoice's lines already known + for ($i = 1 ; $i < 9 ; $i++) + { + $label = $_POST['label'.$i]; + $amountht = price2num($_POST['amount'.$i]); + $amountttc = price2num($_POST['amountttc'.$i]); + $tauxtva = price2num($_POST['tauxtva'.$i]); + $qty = $_POST['qty'.$i]; + $fk_product = $_POST['fk_product'.$i]; + if ($label) + { + if ($amountht) + { + $price_base='HT'; $amount=$amountht; + } + else + { + $price_base='TTC'; $amount=$amountttc; + } + $atleastoneline=1; + + $product=new Product($db); + $product->fetch($_POST['idprod'.$i]); + + $ret=$object->addline($label, $amount, $tauxtva, $product->localtax1_tx, $product->localtax2_tx, $qty, $fk_product, $remise_percent, '', '', '', 0, $price_base, $_POST['rang'.$i], 1); + if ($ret < 0) $error++; + } + } + } + } + + if ($error) + { + $langs->load("errors"); + $db->rollback(); + + setEventMessages($object->error, $object->errors, 'errors'); + $action='create'; + $_GET['socid']=$_POST['socid']; + } + else + { + $db->commit(); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $outputlangs = $langs; + $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result < 0) + { + dol_print_error($db,$object->error,$object->errors); + exit; + } + } + + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + exit; + } + } + } } // Edit line From cdc62f4054a88782d9ca7a028f0e462d3f53f741 Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 6 Oct 2016 17:38:00 +0200 Subject: [PATCH 05/53] NEW : bill orders from order list --- htdocs/commande/list.php | 227 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 224 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index b1abbcfb6b5..00cf1ed14de 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -39,6 +39,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $langs->load('orders'); @@ -153,7 +154,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab */ if (GETPOST('cancel')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; } $parameters=array('socid'=>$socid); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -203,6 +204,191 @@ if (empty($reshook)) } +if($massaction == 'confirm_createbills') { + + $orders = GETPOST('toselect'); + $createbills_onebythird = GETPOST('createbills_onebythird', 'int'); + $TOrderTMP = array(); + + $nb_bills_created = 0; + + $db->begin(); + + foreach($orders as $id_order) { + + $cmd = new Commande($db); + if($cmd->fetch($id_order) <= 0) continue; + + $object = new Facture($db); + if(!empty($createbills_onebythird) && !empty($TOrderTMP[$cmd->socid])) $object = &$TOrderTMP[$cmd->socid]; // To use only one bill for a third + else { + + $object->socid = $cmd->socid; + $object->type = Facture::TYPE_STANDARD; + $object->cond_reglement_id = $cmd->cond_reglement_id; + $object->mode_reglement_id = $cmd->mode_reglement_id; + $object->fk_project = $cmd->fk_project; + + $datefacture = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + if (empty($datefacture)) + { + $datefacture = dol_mktime(date("h"), date("M"), 0, date("m"), date("d"), date("Y")); + } + + $object->date = $datefacture; + $object->origin = 'commande'; + $object->origin_id = $id_order; + + if($object->create($user)) $nb_bills_created++; + + } + + if($object->id > 0) { + + $db->begin(); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element ("; + $sql.= "fk_source"; + $sql.= ", sourcetype"; + $sql.= ", fk_target"; + $sql.= ", targettype"; + $sql.= ") VALUES ("; + $sql.= $id_order; + $sql.= ", '".$object->origin."'"; + $sql.= ", ".$object->id; + $sql.= ", '".$object->element."'"; + $sql.= ")"; + + if ($db->query($sql)) + { + $db->commit(); + } + else + { + $db->rollback(); + } + + $lines = $cmd->lines; + if (empty($lines) && method_exists($cmd, 'fetch_lines')) + { + $cmd->fetch_lines(); + $lines = $cmd->lines; + } + + $fk_parent_line=0; + $num=count($lines); + + for ($i=0;$i<$num;$i++) + { + $desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle); + if ($lines[$i]->subprice < 0) + { + // Negative line, we create a discount line + $discount = new DiscountAbsolute($db); + $discount->fk_soc=$object->socid; + $discount->amount_ht=abs($lines[$i]->total_ht); + $discount->amount_tva=abs($lines[$i]->total_tva); + $discount->amount_ttc=abs($lines[$i]->total_ttc); + $discount->tva_tx=$lines[$i]->tva_tx; + $discount->fk_user=$user->id; + $discount->description=$desc; + $discountid=$discount->create($user); + if ($discountid > 0) + { + $result=$object->insert_discount($discountid); + //$result=$discount->link_to_invoice($lineid,$id); + } + else + { + setEventMessages($discount->error, $discount->errors, 'errors'); + $error++; + break; + } + } + else + { + // Positive line + $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + // Date start + $date_start=false; + if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue; + if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel; + if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start; + //Date end + $date_end=false; + if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue; + if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; + if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + // Reset fk_parent_line for no child products and special product + if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) + { + $fk_parent_line = 0; + } + $result = $object->addline( + $desc, + $lines[$i]->subprice, + $lines[$i]->qty, + $lines[$i]->tva_tx, + $lines[$i]->localtax1_tx, + $lines[$i]->localtax2_tx, + $lines[$i]->fk_product, + $lines[$i]->remise_percent, + $date_start, + $date_end, + 0, + $lines[$i]->info_bits, + $lines[$i]->fk_remise_except, + 'HT', + 0, + $product_type, + $ii, + $lines[$i]->special_code, + $object->origin, + $lines[$i]->rowid, + $fk_parent_line, + $lines[$i]->fk_fournprice, + $lines[$i]->pa_ht, + $lines[$i]->label + ); + if ($result > 0) + { + $lineid=$result; + } + else + { + $lineid=0; + $error++; + break; + } + // Defined the new fk_parent_line + if ($result > 0 && $lines[$i]->product_type == 9) + { + $fk_parent_line = $result; + } + } + } + + } + + // Une fois fini : + if(!empty($createbills_onebythird) && empty($TOrderTMP[$cmd->socid])) $TOrderTMP[$cmd->socid] = $object; + } + + if (! $error) + { + $db->commit(); + setEventMessage($nb_bills_created.' factures créées'); + } + else + { + $db->rollback(); + $action='create'; + $_GET["origin"]=$_POST["origin"]; + $_GET["originid"]=$_POST["originid"]; + setEventMessages($object->error, $object->errors, 'errors'); + $error++; + } + +} /* @@ -416,8 +602,9 @@ if ($resql) 'presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"), ); + if($user->rights->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); if ($user->rights->commande->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete"); - if ($massaction == 'presend') $arrayofmassactions=array(); + if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); // Lines of title fields @@ -527,6 +714,38 @@ if ($resql) dol_fiche_end(); } + elseif ($massaction == 'createbills') + { + //var_dump($_REQUEST); + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans('DateInvoice'); + print ''; + print $form->select_date('', '', '', '', '', "addprop", 1, 1); + print '
'; + print $langs->trans('Créer une facture par tiers'); + print ''; + print $form->selectyesno('createbills_onebythird', '', 1); + print '
'; + + print '
'; + print '
'; + print ' '; + print ''; + print '
'; + print '
'; + + } if ($sall) { @@ -1155,9 +1374,11 @@ if ($resql) print ''."\n"; + print '
'; + print ''."\n"; - print '
'.img_help(1,'').' '.$langs->trans("ToBillSeveralOrderSelectCustomer", $langs->transnoentitiesnoconv("CreateInvoiceForThisCustomer")).'
'; + //print '
'.img_help(1,'').' '.$langs->trans("ToBillSeveralOrderSelectCustomer", $langs->transnoentitiesnoconv("CreateInvoiceForThisCustomer")).'
'; if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { From fbd06e48cde02bfc2e15f27bb5ece070f597f22a Mon Sep 17 00:00:00 2001 From: gauthier Date: Fri, 7 Oct 2016 09:20:34 +0200 Subject: [PATCH 06/53] NEW : classify billed orders and trads --- htdocs/commande/list.php | 7 ++++--- htdocs/langs/en_US/bills.lang | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 00cf1ed14de..764e0a1dffd 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -369,14 +369,15 @@ if($massaction == 'confirm_createbills') { } - // Une fois fini : + $cmd->classifyBilled($user); + if(!empty($createbills_onebythird) && empty($TOrderTMP[$cmd->socid])) $TOrderTMP[$cmd->socid] = $object; } if (! $error) { $db->commit(); - setEventMessage($nb_bills_created.' factures créées'); + setEventMessage($langs->trans('BillCreated', $nb_bills_created)); } else { @@ -730,7 +731,7 @@ if ($resql) print ''; print ''; print ''; - print $langs->trans('Créer une facture par tiers'); + print $langs->trans('CreateOneBillByThird'); print ''; print ''; print $form->selectyesno('createbills_onebythird', '', 1); diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index ce839d04eed..deee06e3690 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -482,4 +482,5 @@ ToCreateARecurringInvoiceGene=To generate future invoices regularly and manually ToCreateARecurringInvoiceGeneAuto=If you need to have such invoices generated automatically, ask you administrator to enable and setup module %s. Note that both method (manual and automatic) can be used together with no risk of duplication. DeleteRepeatableInvoice=Delete template invoice ConfirmDeleteRepeatableInvoice=Are your sure you want to delete the template invoice ? - +CreateOneBillByThird=Create one bill by third +BillCreated=%s bill(s) created \ No newline at end of file From 23255976ef995efe251177d252529c469ec79144 Mon Sep 17 00:00:00 2001 From: gauthier Date: Fri, 7 Oct 2016 11:21:58 +0200 Subject: [PATCH 07/53] FIX : require class discount --- htdocs/commande/list.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 764e0a1dffd..d157057b016 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -35,6 +35,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; From 5803087d4f1775e40dbc08fd403e6d190a270b5e Mon Sep 17 00:00:00 2001 From: gauthier Date: Fri, 7 Oct 2016 14:32:27 +0200 Subject: [PATCH 08/53] NEW : concat of all invoice pdf if invoice validation --- htdocs/commande/list.php | 58 ++++++++++++++++++++++++++++++----- htdocs/langs/en_US/bills.lang | 1 + 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index d157057b016..35ea4489cff 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -209,7 +209,10 @@ if($massaction == 'confirm_createbills') { $orders = GETPOST('toselect'); $createbills_onebythird = GETPOST('createbills_onebythird', 'int'); - $TOrderTMP = array(); + $validate_invoices = GETPOST('valdate_invoices', 'int'); + + $TFact = array(); + $TFactThird = array(); $nb_bills_created = 0; @@ -221,7 +224,7 @@ if($massaction == 'confirm_createbills') { if($cmd->fetch($id_order) <= 0) continue; $object = new Facture($db); - if(!empty($createbills_onebythird) && !empty($TOrderTMP[$cmd->socid])) $object = &$TOrderTMP[$cmd->socid]; // To use only one bill for a third + if(!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // To use only one bill for a third else { $object->socid = $cmd->socid; @@ -240,7 +243,9 @@ if($massaction == 'confirm_createbills') { $object->origin = 'commande'; $object->origin_id = $id_order; - if($object->create($user)) $nb_bills_created++; + $res = $object->create($user); + + if($res > 0) $nb_bills_created++; } @@ -369,12 +374,40 @@ if($massaction == 'confirm_createbills') { } } - + $cmd->classifyBilled($user); - - if(!empty($createbills_onebythird) && empty($TOrderTMP[$cmd->socid])) $TOrderTMP[$cmd->socid] = $object; - } + if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object; + else $TFact[$object->id] = $object; + } + + // Build doc with all invoices + $TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird; + $toselect = array(); + + if(!empty($validate_invoices)) { + + $massaction = $action = 'builddoc'; + + foreach($TAllFact as &$object) { + $object->validate($user); + $toselect[] = $object->id; // For builddoc action + + // Fac builddoc + $upload_dir = $conf->facture->dir_output; + $permissioncreate=$user->rights->facture->creer; + include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php'; + } + + $objectclass='Facture'; + $objectlabel='Invoice'; + $permtoread = $user->rights->facture->lire; + $permtodelete = $user->rights->facture->supprimer; + $uploaddir = $conf->facture->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + + } + if (! $error) { $db->commit(); @@ -591,6 +624,7 @@ if ($resql) if ($search_total_ttc != '') $param.='&search_total_ttc='.$search_total_ttc; if ($show_files) $param.='&show_files=' .$show_files; if ($optioncss != '') $param.='&optioncss='.$optioncss; + if ($billed != '') $param.='&billed='.$billed; // Add $param from extra fields foreach ($search_array_options as $key => $val) { @@ -727,7 +761,7 @@ if ($resql) print $langs->trans('DateInvoice'); print ''; print ''; - print $form->select_date('', '', '', '', '', "addprop", 1, 1); + print $form->select_date('', '', '', '', '', '', 1, 1); print ''; print ''; print ''; @@ -738,6 +772,14 @@ if ($resql) print $form->selectyesno('createbills_onebythird', '', 1); print ''; print ''; + print ''; + print ''; + print $langs->trans('ValidateInvoices'); + print ''; + print ''; + print $form->selectyesno('valdate_invoices', 1, 1); + print ''; + print ''; print ''; print '
'; diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index deee06e3690..3f23893855c 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -421,6 +421,7 @@ ShowUnpaidAll=Show all unpaid invoices ShowUnpaidLateOnly=Show late unpaid invoices only PaymentInvoiceRef=Payment invoice %s ValidateInvoice=Validate invoice +ValidateInvoices=Validate invoices Cash=Cash Reported=Delayed DisabledBecausePayments=Not possible since there are some payments From 416311a7b94013591f3d520a3a74cf9d5d9ca1e7 Mon Sep 17 00:00:00 2001 From: gauthier Date: Fri, 16 Sep 2016 11:17:19 +0200 Subject: [PATCH 09/53] NEW : allow to save a parent warehouse # Conflicts: # htdocs/product/stock/card.php --- .../install/mysql/migration/4.0.0-5.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_entrepot.sql | 3 ++- htdocs/langs/en_US/stocks.lang | 1 + .../product/class/html.formproduct.class.php | 12 ++++++--- htdocs/product/stock/card.php | 25 +++++++++++++++++++ htdocs/product/stock/class/entrepot.class.php | 8 +++--- 6 files changed, 43 insertions(+), 8 deletions(-) diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index 359d01fcc54..aebc549413e 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -135,3 +135,5 @@ ALTER TABLE llx_accounting_bookkeeping ADD COLUMN tms timestamp; ALTER TABLE llx_accounting_account ADD INDEX uk_accounting_account (account_number, entity); ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint + +ALTER TABLE llx_entrepot ADD COLUMN fk_parent integer DEFAULT NULL diff --git a/htdocs/install/mysql/tables/llx_entrepot.sql b/htdocs/install/mysql/tables/llx_entrepot.sql index a8898a7ec92..827675a5c0a 100644 --- a/htdocs/install/mysql/tables/llx_entrepot.sql +++ b/htdocs/install/mysql/tables/llx_entrepot.sql @@ -34,5 +34,6 @@ create table llx_entrepot fk_pays integer DEFAULT 0, statut tinyint DEFAULT 1, -- 1 open, 0 close fk_user_author integer, - import_key varchar(14) + import_key varchar(14), + fk_parent integer DEFAULT NULL )ENGINE=innodb; diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 413e6c80088..d5fa618b1e0 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -2,6 +2,7 @@ WarehouseCard=Warehouse card Warehouse=Warehouse Warehouses=Warehouses +ParentWarehouse=Parent warehouse NewWarehouse=New warehouse / Stock area WarehouseEdit=Modify warehouse MenuNewWarehouse=New warehouse diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index cedf40678d2..9e08ad86159 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -58,12 +58,14 @@ class FormProduct * @param boolean $sumStock sum total stock of a warehouse, default true * @return int Nb of loaded lines, 0 if already loaded, <0 if KO */ - function loadWarehouses($fk_product=0, $batch = '', $status=null, $sumStock = true) + function loadWarehouses($fk_product=0, $batch = '', $status=null, $sumStock = true, $exclude='') { global $conf, $langs; if (empty($fk_product) && count($this->cache_warehouses)) return 0; // Cache already loaded and we do not want a list with information specific to a product - + + if (is_array($exclude)) $excludeGroups = implode("','",$exclude); + $sql = "SELECT e.rowid, e.label, e.description"; if (!empty($fk_product)) { @@ -100,6 +102,8 @@ class FormProduct $sql.= " AND e.statut = 1"; } + if(!empty($exclude)) $sql.= ' AND e.rowid NOT IN('.implode(',', $exclude).')'; + if ($sumStock && empty($fk_product)) $sql.= " GROUP BY e.rowid, e.label, e.description"; $sql.= " ORDER BY e.label"; @@ -144,7 +148,7 @@ class FormProduct * @param string $morecss Add more css classes * @return string HTML select */ - function selectWarehouses($selected='',$htmlname='idwarehouse',$filtertype='',$empty=0,$disabled=0,$fk_product=0,$empty_label='', $showstock=0, $forcecombo=0, $events=array(), $morecss='minwidth200') + function selectWarehouses($selected='',$htmlname='idwarehouse',$filtertype='',$empty=0,$disabled=0,$fk_product=0,$empty_label='', $showstock=0, $forcecombo=0, $events=array(), $morecss='minwidth200', $exclude='') { global $conf,$langs,$user; @@ -152,7 +156,7 @@ class FormProduct $out=''; - $this->loadWarehouses($fk_product, '', + $filtertype); // filter on numeric status + $this->loadWarehouses($fk_product, '', + $filtertype, true, $exclude); // filter on numeric status $nbofwarehouses=count($this->cache_warehouses); if ($conf->use_javascript_ajax && ! $forcecombo) diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 60f7938de06..5a3c5f7249b 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -31,10 +31,12 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $langs->load("products"); $langs->load("stocks"); $langs->load("companies"); +$langs->load("categories"); $action=GETPOST('action'); $cancel=GETPOST('cancel'); @@ -64,6 +66,7 @@ $object = new Entrepot($db); if ($action == 'add' && $user->rights->stock->creer) { $object->ref = GETPOST("ref"); + $object->fk_parent = GETPOST("fk_parent"); $object->libelle = GETPOST("libelle"); $object->description = GETPOST("desc"); $object->statut = GETPOST("statut"); @@ -128,6 +131,7 @@ if ($action == 'update' && $cancel <> $langs->trans("Cancel")) if ($object->fetch($id)) { $object->libelle = GETPOST("libelle"); + $object->fk_parent = GETPOST("fk_parent"); $object->description = GETPOST("desc"); $object->statut = GETPOST("statut"); $object->lieu = GETPOST("lieu"); @@ -166,6 +170,7 @@ if ($cancel == $langs->trans("Cancel")) $productstatic=new Product($db); $form=new Form($db); +$formproduct=new FormProduct($db); $formcompany=new FormCompany($db); $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; @@ -189,6 +194,11 @@ if ($action == 'create') print ''.$langs->trans("Ref").''; print ''.$langs->trans("LocationSummary").''; + + // Parent entrepot + print ''.$langs->trans("AddIn").''; + print $formproduct->selectWarehouses('', 'fk_parent', '', 1); + print ''; // Description print ''.$langs->trans("Description").''; @@ -346,6 +356,16 @@ else //print ''.$langs->trans("LocationSummary").''.$object->lieu.''; + // Parent entrepot + $e = new Entrepot($db); + if(!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0) { + + print ''.$langs->trans("ParentWarehouse").''; + print $e->getNomUrl(3); + print ''; + + } + // Description print ''.$langs->trans("Description").''.nl2br($object->description).''; @@ -623,6 +643,11 @@ else print ''.$langs->trans("Ref").''; print ''.$langs->trans("LocationSummary").''; + + // Parent entrepot + print ''.$langs->trans("AddIn").''; + print $formproduct->selectWarehouses('', 'fk_parent', '', 1, 0, 0, '', 0, 0, array(), 'minwidth200', array($object->id)); + print ''; // Description print ''.$langs->trans("Description").''; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index aee38a67ccf..6bec94d9640 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -123,8 +123,8 @@ class Entrepot extends CommonObject $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (entity, datec, fk_user_author, label)"; - $sql .= " VALUES (".$conf->entity.",'".$this->db->idate($now)."',".$user->id.",'".$this->db->escape($this->libelle)."')"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (entity, datec, fk_user_author, label, fk_parent)"; + $sql .= " VALUES (".$conf->entity.",'".$this->db->idate($now)."',".$user->id.",'".$this->db->escape($this->libelle)."', ".($this->fk_parent > 0 ? $this->fk_parent : 'NULL').")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); $result=$this->db->query($sql); @@ -184,6 +184,7 @@ class Entrepot extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."entrepot "; $sql .= " SET label = '" . $this->db->escape($this->libelle) ."'"; + $sql .= ", fk_parent = '" . (($this->fk_parent > 0) ? $this->fk_parent : 'NULL') ."'"; $sql .= ", description = '" . $this->db->escape($this->description) ."'"; $sql .= ", statut = " . $this->statut; $sql .= ", lieu = '" . $this->db->escape($this->lieu) ."'"; @@ -294,7 +295,7 @@ class Entrepot extends CommonObject { global $conf; - $sql = "SELECT rowid, label, description, statut, lieu, address, zip, town, fk_pays as country_id"; + $sql = "SELECT rowid, fk_parent, label, description, statut, lieu, address, zip, town, fk_pays as country_id"; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot"; if ($id) @@ -317,6 +318,7 @@ class Entrepot extends CommonObject $obj=$this->db->fetch_object($result); $this->id = $obj->rowid; + $this->fk_parent = $obj->fk_parent; $this->ref = $obj->rowid; $this->libelle = $obj->label; $this->description = $obj->description; From fe1bcb7e0a4ba9cd680d0203d82a1a85164e9759 Mon Sep 17 00:00:00 2001 From: gauthier Date: Fri, 16 Sep 2016 10:18:36 +0200 Subject: [PATCH 10/53] NEW : function to display full path to current warehouse --- .../product/class/html.formproduct.class.php | 2 +- htdocs/product/stock/class/entrepot.class.php | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 9e08ad86159..1d8eb4578ca 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -118,7 +118,7 @@ class FormProduct $obj = $this->db->fetch_object($resql); if ($sumStock) $obj->stock = price2num($obj->stock,5); $this->cache_warehouses[$obj->rowid]['id'] =$obj->rowid; - $this->cache_warehouses[$obj->rowid]['label']=$obj->label; + $this->cache_warehouses[$obj->rowid]['label']=$o->get_full_arbo(); $this->cache_warehouses[$obj->rowid]['description'] = $obj->description; $this->cache_warehouses[$obj->rowid]['stock'] = $obj->stock; $i++; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 6bec94d9640..539b714ec2e 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -606,4 +606,33 @@ class Entrepot extends CommonObject $this->country_id=1; $this->country_code='FR'; } + + function get_full_arbo() { + + global $user,$langs,$conf; + + $TArbo = array($this->libelle); + + $id = $this->id; + + while(true) { + $sql = 'SELECT fk_parent + FROM '.MAIN_DB_PREFIX.'entrepot + WHERE rowid = '.$id; + + $resql = $this->db->query($sql); + if($resql) { + $res = $this->db->fetch_object($resql); + if(empty($res->fk_parent)) break; + $id = $res->fk_parent; + $o = new Entrepot($this->db); + $o->fetch($id); + $TArbo[] = $o->libelle; + } else break; + } + + return implode(' >> ', array_reverse($TArbo)); + + } + } From 1a648cfc892d908dabd4055cc4dfd3b1312fdd32 Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 20 Sep 2016 09:27:27 +0200 Subject: [PATCH 11/53] NEW : getNomUrl displays full path to warehouse # Conflicts: # htdocs/product/stock/class/entrepot.class.php --- htdocs/product/class/html.formproduct.class.php | 2 ++ htdocs/product/stock/card.php | 2 +- htdocs/product/stock/class/entrepot.class.php | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 1d8eb4578ca..9a8f6c1a94d 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -117,6 +117,8 @@ class FormProduct { $obj = $this->db->fetch_object($resql); if ($sumStock) $obj->stock = price2num($obj->stock,5); + $o = new Entrepot($this->db); + $o->fetch($obj->rowid); $this->cache_warehouses[$obj->rowid]['id'] =$obj->rowid; $this->cache_warehouses[$obj->rowid]['label']=$o->get_full_arbo(); $this->cache_warehouses[$obj->rowid]['description'] = $obj->description; diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 5a3c5f7249b..203288170c8 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -646,7 +646,7 @@ else // Parent entrepot print ''.$langs->trans("AddIn").''; - print $formproduct->selectWarehouses('', 'fk_parent', '', 1, 0, 0, '', 0, 0, array(), 'minwidth200', array($object->id)); + print $formproduct->selectWarehouses($object->fk_parent, 'fk_parent', '', 1, 0, 0, '', 0, 0, array(), 'minwidth200', array($object->id)); print ''; // Description diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 539b714ec2e..0132ec68fab 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -575,7 +575,7 @@ class Entrepot extends CommonObject $linkend=''; if ($withpicto) $result.=($link.img_object($label, 'stock', 'class="classfortooltip"').$linkend.' '); - $result.=$link.(empty($this->label)?$this->libelle:$this->label).$linkend; + $result.=$link.$this->get_full_arbo().$linkend; return $result; } From 61a318835387695ca4fb45e8e0f8e5a10428ba65 Mon Sep 17 00:00:00 2001 From: gauthier Date: Fri, 14 Oct 2016 11:59:07 +0200 Subject: [PATCH 12/53] FIX : new parameter documentation --- htdocs/product/class/html.formproduct.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 9a8f6c1a94d..d550daf6ecb 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -56,6 +56,7 @@ class FormProduct * @param string $batch Add quantity of batch stock in label for product with batch name batch, batch name precedes batch_id. Nothing if ''. * @param int $status additional filter on status other then 1 * @param boolean $sumStock sum total stock of a warehouse, default true + * @param array $exclude warehouses ids to exclude * @return int Nb of loaded lines, 0 if already loaded, <0 if KO */ function loadWarehouses($fk_product=0, $batch = '', $status=null, $sumStock = true, $exclude='') @@ -148,6 +149,7 @@ class FormProduct * @param int $forcecombo force combo iso ajax select2 * @param array $events events to add to select2 * @param string $morecss Add more css classes + * @param array $exclude warehouses ids to exclude * @return string HTML select */ function selectWarehouses($selected='',$htmlname='idwarehouse',$filtertype='',$empty=0,$disabled=0,$fk_product=0,$empty_label='', $showstock=0, $forcecombo=0, $events=array(), $morecss='minwidth200', $exclude='') From 805b65addda30517c3bf70bad7c89cdb6576a986 Mon Sep 17 00:00:00 2001 From: gauthier Date: Fri, 14 Oct 2016 12:02:24 +0200 Subject: [PATCH 13/53] FIX : semicolon --- htdocs/install/mysql/migration/4.0.0-5.0.0.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index aebc549413e..7b4581d2dce 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -134,6 +134,6 @@ ALTER TABLE llx_accounting_bookkeeping ADD COLUMN tms timestamp; ALTER TABLE llx_accounting_account ADD INDEX uk_accounting_account (account_number, entity); -ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint +ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint; -ALTER TABLE llx_entrepot ADD COLUMN fk_parent integer DEFAULT NULL +ALTER TABLE llx_entrepot ADD COLUMN fk_parent integer DEFAULT NULL; From 012be8e4003f26e58930f0d2feef935d718971f2 Mon Sep 17 00:00:00 2001 From: gauthier Date: Fri, 14 Oct 2016 12:42:42 +0200 Subject: [PATCH 14/53] NEW : security check to avoid adding a parent warehouse chich is already a child of current one --- htdocs/langs/en_US/main.lang | 1 + htdocs/product/stock/class/entrepot.class.php | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index fa9a4eec9e2..05a754eb317 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -62,6 +62,7 @@ ErrorCantLoadUserFromDolibarrDatabase=Failed to find user %s in Dolibarr ErrorNoVATRateDefinedForSellerCountry=Error, no vat rates defined for country '%s'. ErrorNoSocialContributionForSellerCountry=Error, no social/fiscal taxes type defined for country '%s'. ErrorFailedToSaveFile=Error, failed to save file. +ErrorCannotAddThisParentWarehouse=You are trying to add a parent warehouse which is already a child of current one NotAuthorized=You are not authorized to do that. SetDate=Set date SelectDate=Select a date diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 0132ec68fab..452d9a59b69 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -172,6 +172,16 @@ class Entrepot extends CommonObject */ function update($id, $user) { + // Check if new parent is already a child of current warehouse + if(!empty($this->fk_parent)) { + $TChildWarehouses = array(); + $TChildWarehouses = $this->get_children_warehouses($this->id, $TChildWarehouses); + if(in_array($this->fk_parent, $TChildWarehouses)) { + $this->error = 'ErrorCannotAddThisParentWarehouse'; + return -2; + } + } + $this->libelle=trim($this->libelle); $this->description=trim($this->description); @@ -634,5 +644,23 @@ class Entrepot extends CommonObject return implode(' >> ', array_reverse($TArbo)); } + + function get_children_warehouses($id, &$TChildWarehouses) { + + $sql = 'SELECT rowid + FROM '.MAIN_DB_PREFIX.'entrepot + WHERE fk_parent = '.$id; + + $resql = $this->db->query($sql); + if($resql) { + while($res = $this->db->fetch_object($resql)) { + $TChildWarehouses[] = $res->rowid; + $this->get_children_warehouses($res->rowid, $TChildWarehouses); + } + } + + return $TChildWarehouses; + + } } From 1af1e4dc9c52c898643d041f817b1a57e74f6d62 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 16 Oct 2016 13:38:29 +0200 Subject: [PATCH 15/53] Accountancy - Add loan module in step to configure the accountancy --- htdocs/accountancy/index.php | 9 +++++++++ htdocs/langs/en_US/accountancy.lang | 1 + 2 files changed, 10 insertions(+) diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index eaba769677e..39f312c8a88 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -45,6 +45,7 @@ $langs->load("bills"); $langs->load("accountancy"); $langs->load("compta"); $langs->load("banks"); +$langs->load("loans"); /* * Actions @@ -107,6 +108,14 @@ if (! empty($conf->salaries->enabled)) print "
\n"; print "
\n"; } +if (! empty($conf->loan->enabled)) +{ + $step++; + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescLoan", $step, ''.$langs->transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("Modules")."-".$langs->transnoentitiesnoconv("Loans").''); + // htdocs/admin/loan.php + print "
\n"; + print "
\n"; +} if (! empty($conf->don->enabled)) { $step++; diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index ca8ab6f65e0..abb32f9e86c 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -27,6 +27,7 @@ AccountancyAreaDescVat=STEP %s: Check the binding between vat payment and accoun AccountancyAreaDescSal=STEP %s: Check the binding between salaries payment and accounting account is done. Complete missing bindings. This will save you time in future for the next steps by suggesting you the correct default accounting account on record related to payment of salaries.
For this you can use the menu entry %s. AccountancyAreaDescContrib=STEP %s: Check the binding between special expences (social or fiscal contributions) and accounting account is done. Complete missing bindings. This will save you time in future for the next steps by suggesting you the correct default accounting account on record related to payments of social contributions.
For this you can use the menu entry %s. AccountancyAreaDescDonation=STEP %s: Check the binding between donation and accounting account is done. Complete missing bindings. This will save you time in future for the next steps by suggesting you the correct default accounting account on record related to payments of donation.
You can set the account dedicated for that from the menu entry %s. +AccountancyAreaDescLoan=STEP %s: Check the binding between loans payment and accounting account is done. Complete missing bindings. This will save you time in future for the next steps by suggesting you the correct default accounting account on record related to payment of loans.
For this you can use the menu entry %s. AccountancyAreaDescCustomer=STEP %s: Check the binding between existing customer invoice lines and accounting account is done. Complete missing bindings. Once binding is complete, application will be able to record transactions in General Ledger in one click.
For this you can use the menu entry %s. AccountancyAreaDescSupplier=STEP %s: Check the binding between existing supplier invoice lines and accounting account is done. Complete missing bindings. Once binding is complete, application will be able to record transactions in General Ledger in one click.
For this you can use the menu entry %s. From b6b4c8a05305462cef09b0f4b9e121cb2513a241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Mon, 17 Oct 2016 18:55:36 +0200 Subject: [PATCH 16/53] Add deprecated property explicitly Remove properties inherited from CommonObject Add type hinting to existing properties --- .../adherents/class/adherent_type.class.php | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 5fb3d8140bd..7520bdbf6a5 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -33,17 +33,28 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; */ class AdherentType extends CommonObject { - public $table_element = 'adherent_type'; - public $element = 'adherent_type'; + public $table_element = 'adherent_type'; + public $element = 'adherent_type'; - var $id; - var $ref; - var $libelle; - var $subscription; // Subscription required - var $note; - var $vote; // Can vote - var $mail_valid; // mail sent during validation - var $statut; + /** @var string Label */ + public $libelle; + /** + * @var bool + * @deprecated Use subscription + * @see subscription + */ + public $cotisation; + /** + * @var bool Subsription required + * @since 5.0 + */ + public $subscription; + /** @var string Public note */ + public $note; + /** @var bool Can vote*/ + public $vote; + /** @var bool Email sent during validation */ + public $mail_valid; /** From 7d63925118fcf68c981ff5ce1722c508a12758aa Mon Sep 17 00:00:00 2001 From: gauthier Date: Tue, 18 Oct 2016 15:25:07 +0200 Subject: [PATCH 17/53] NEW : param socid find_min_price_product_fournisseur() function --- htdocs/fourn/class/fournisseur.product.class.php | 4 +++- htdocs/fourn/commande/card.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 34a11663e2a..e59144abc2e 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -521,9 +521,10 @@ class ProductFournisseur extends Product * * @param int $prodid Product id * @param int $qty Minimum quantity + * @param int $socid get min price for specific supplier * @return int <0 if KO, 0=Not found of no product id provided, >0 if OK */ - function find_min_price_product_fournisseur($prodid, $qty=0) + function find_min_price_product_fournisseur($prodid, $qty=0, $socid=0) { global $conf; @@ -556,6 +557,7 @@ class ProductFournisseur extends Product $sql.= " AND pfp.fk_soc = s.rowid"; $sql.= " AND s.status = 1"; // only enabled society if ($qty > 0) $sql.= " AND pfp.quantity <= ".$qty; + if ($socid > 0) $sql.= ' AND pfp.fk_soc = '.$socid; dol_syslog(get_class($this)."::find_min_price_product_fournisseur", LOG_DEBUG); diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 4460a335463..828809d43d3 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1059,7 +1059,7 @@ if (empty($reshook)) $array_option = $lines[$i]->array_options; } - $result = $productsupplier->find_min_price_product_fournisseur($lines[$i]->fk_product, $lines[$i]->qty); + $result = $productsupplier->find_min_price_product_fournisseur($lines[$i]->fk_product, $lines[$i]->qty, $srcobject->socid); if ($result>=0) { $tva_tx = $lines[$i]->tva_tx; From a30d4a0a38e1fbefeb7f42745a426655321c7431 Mon Sep 17 00:00:00 2001 From: Sof Date: Tue, 18 Oct 2016 16:58:50 +0200 Subject: [PATCH 18/53] Fix : Custom menu handler is not accessible for editing --- htdocs/admin/menus/edit.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index afe56aa8dcf..0a2669e960d 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007 Patrick Raguin * Copyright (C) 2007-2012 Laurent Destailleur * Copyright (C) 2009-2011 Regis Houssin + * Copyright (C) 2016 Meziane Sof * * 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 @@ -33,10 +34,14 @@ $langs->load('other'); if (! $user->admin) accessforbidden(); -$dirstandard = "/core/menus/standard"; -$dirsmartphone = "/core/menus/smartphone"; - -$dirmenu = array($dirstandard,$dirsmartphone); +$dirstandard = array(); +$dirsmartphone = array(); +$dirmenus=array_merge(array("/core/menus/"),(array) $conf->modules_parts['menus']); +foreach($dirmenus as $dirmenu) +{ + $dirstandard[]=$dirmenu.'standard'; + $dirsmartphone[]=$dirmenu.'smartphone'; +} $action=GETPOST('action'); @@ -244,7 +249,7 @@ if ($action == 'confirm_delete' && $_POST["confirm"] == 'yes') $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".GETPOST('menuId', 'int'); - $db->query($sql); + $result=$db->query($sql); if ($result == 0) { @@ -331,7 +336,7 @@ if ($action == 'create') // Handler print ''.$langs->trans('MenuHandler').''; print ''; - $formadmin->select_menu_families($menu_handler,'menu_handler',$dirmenu); + $formadmin->select_menu_families($menu_handler.(preg_match('/_menu/',$menu_handler)?'':'_menu'),'menu_handler',array_merge($dirstandard,$dirsmartphone)); print ''; print ''.$langs->trans('DetailMenuHandler').''; From 46c0aa3f03c6a519c768f4be6aa721e4abfdba11 Mon Sep 17 00:00:00 2001 From: BeltranBot Date: Tue, 18 Oct 2016 11:32:35 -0500 Subject: [PATCH 19/53] misspelling fix fixing a misspelling --- dev/skeletons/skeleton_list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/skeletons/skeleton_list.php b/dev/skeletons/skeleton_list.php index 0ca6962bbef..7715b17b4d8 100644 --- a/dev/skeletons/skeleton_list.php +++ b/dev/skeletons/skeleton_list.php @@ -296,7 +296,7 @@ if ($resql) $moreforfilter = ''; $moreforfilter.='
'; - $moreforfilter.= $langs->trans('MyFilter') . ': '; + $moreforfilter.= $langs->trans('MyFilter') . ': '; $moreforfilter.= '
'; $parameters=array(); From 9ee61d20e3c79d964d6c00e3ccfbc7af2d99b8b1 Mon Sep 17 00:00:00 2001 From: philippe-opendsi Date: Tue, 18 Oct 2016 22:23:03 +0200 Subject: [PATCH 20/53] Add create events on project card when MAIN_ADD_EVENT_ON_ELEMENT_CARD is enabled like for propal, order and invoice The new event is linked to the project --- htdocs/projet/card.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index cc3a97fac5b..5817f44db65 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -970,7 +970,16 @@ else { if ($action != "edit" ) { - // Modify + + // Create event + if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a + // "workflow" action so should appears somewhere else on + // page. + { + print ''; + } + + // Modify if ($object->statut != 2 && $user->rights->projet->creer) { if ($userWrite > 0) From 54a154fa4f91b6058e9cabdf65bb269baf914601 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 19 Oct 2016 22:14:51 +0200 Subject: [PATCH 21/53] NEW : Add ressource extrafields --- htdocs/admin/resource.php | 148 +++++++++++++ htdocs/admin/resource_extrafields.php | 122 +++++++++++ htdocs/core/lib/resource.lib.php | 31 ++- htdocs/core/modules/modResource.class.php | 10 +- .../install/mysql/migration/4.0.0-5.0.0.sql | 10 + .../tables/llx_resource_extrafields.key.sql | 20 ++ .../mysql/tables/llx_resource_extrafields.sql | 26 +++ htdocs/langs/en_US/admin.lang | 7 +- htdocs/resource/add.php | 21 ++ htdocs/resource/card.php | 35 ++- htdocs/resource/class/dolresource.class.php | 151 ++++++++++--- htdocs/resource/list.php | 202 ++++++++++++++++-- 12 files changed, 728 insertions(+), 55 deletions(-) create mode 100644 htdocs/admin/resource.php create mode 100644 htdocs/admin/resource_extrafields.php create mode 100644 htdocs/install/mysql/tables/llx_resource_extrafields.key.sql create mode 100644 htdocs/install/mysql/tables/llx_resource_extrafields.sql diff --git a/htdocs/admin/resource.php b/htdocs/admin/resource.php new file mode 100644 index 00000000000..fd3fe4829c1 --- /dev/null +++ b/htdocs/admin/resource.php @@ -0,0 +1,148 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +/** + * \file htdocs/admin/resource.php + * \ingroup resource + * \brief Setup page to configure resource module + */ + +require '../main.inc.php'; + +// Class +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php'; +if (! empty($conf->resouce->enabled)) require_once DOL_DOCUMENT_ROOT . '/resource/class/html.formresource.class.php'; + +$langs->load("admin"); +$langs->load("resource"); + +// Security check +if (!$user->admin) + accessforbidden(); + +$action = GETPOST('action', 'alpha'); + + +/* + * Actions + */ + +if ($action == 'update') +{ + $error = 0; + + foreach ($list as $constname) { + $constvalue = GETPOST($constname, 'alpha'); + + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } + + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + +/* + * View + */ + +llxHeader('',$langs->trans('ResourceSetup')); + +$form = new Form($db); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans('ResourceSetup'),$linkback,'title_setup'); + +$head=resource_admin_prepare_head(); + +dol_fiche_head($head, 'attributes', $langs->trans("ResourceSingular"), 0, 'action'); + +print '
'; +print ''; +print ''; + +$var=true; +print ''; +print ''; +print ''."\n"; +print ''."\n"; + + +// Utilisation formulaire Ajax sur choix produit +$var=!$var; +print ''; +print ''; +if (empty($conf->use_javascript_ajax)) +{ + print ''; +} +else +{ + print ''; +} +print ''; + +$var=!$var; +print ''; +print ''; +print ''; +print ''; +print ''; + +$var=!$var; +print ''; +print ''; +print ''; +print ''; + +print '
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'.$langs->trans("UseSearchToSelectResource").''; + print $langs->trans("NotAvailableWhenAjaxDisabled"); + print ''; + $arrval=array( + '0'=>$langs->trans("No"), + '1'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",1).')', + '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')', + '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')', + ); + print $form->selectarray("activate_usesearchtoselectproduct",$arrval,$conf->global->RESOURCE_USE_SEARCH_TO_SELECT); + print '
'.$langs->trans('DisabledResourceLinkUser').''; +echo ajax_constantonoff('RESOURCE_HIDE_ADD_CONTACT_USER'); +print '
'.$langs->trans('DisabledResourceLinkContact').''; +echo ajax_constantonoff('RESOURCE_HIDE_ADD_CONTACT_THIPARTY'); +print '
'; + +print '
'; + + +//RESOURCE_HIDE_ADD_CONTACT_USER +//RESOURCE_HIDE_ADD_CONTACT_THIPARTY + +dol_fiche_end(); + + +llxFooter(); +$db->close(); diff --git a/htdocs/admin/resource_extrafields.php b/htdocs/admin/resource_extrafields.php new file mode 100644 index 00000000000..c3d90fac3e5 --- /dev/null +++ b/htdocs/admin/resource_extrafields.php @@ -0,0 +1,122 @@ + + * Copyright (C) 2003 Jean-Louis Bergamo + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2016 Florian Henry + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/admin/resource_extrafields.php + * \ingroup agenda + * \brief Page to setup extra fields of resource + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + + +if (!$user->admin) + accessforbidden(); + +$langs->load("admin"); +$langs->load("other"); +$langs->load("resource"); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=ExtraFields::$type2label; +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); +$elementtype='resource'; //Must be the $table_element of the class that manage extrafield + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + + +/* + * View + */ + +$textobject=$langs->transnoentitiesnoconv("ResourceSingular"); + +llxHeader('',$langs->trans("ResourceSetup")); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("ResourceSetup"),$linkback,'title_setup'); +print "
\n"; + +$head=resource_admin_prepare_head(); + +dol_fiche_head($head, 'attributes', $langs->trans("ResourceSingular"), 0, 'action'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print "".$langs->trans("NewAttribute").""; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Creation of an optional field */ +/* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "
"; + print load_fiche_titre($langs->trans('NewAttribute')); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php'; +} + +/* ************************************************************************** */ +/* */ +/* Edition of an optional field */ +/* */ +/* ************************************************************************** */ +if ($action == 'edit' && ! empty($attrname)) +{ + print "
"; + print load_fiche_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +llxFooter(); + +$db->close(); diff --git a/htdocs/core/lib/resource.lib.php b/htdocs/core/lib/resource.lib.php index 58fffbae5b7..687ccacc15a 100644 --- a/htdocs/core/lib/resource.lib.php +++ b/htdocs/core/lib/resource.lib.php @@ -81,8 +81,37 @@ function resource_prepare_head($object) $head[$h][1] = $langs->trans('Info'); $head[$h][2] = 'info'; $h++;*/ - + complete_head_from_modules($conf,$langs,$object,$head,$h,'resource', 'remove'); return $head; } + +function resource_admin_prepare_head() { + + global $langs, $conf, $user; + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/admin/resource.php'; + $head[$h][1] = $langs->trans("Miscellaneous"); + $head[$h][2] = 'general'; + $h++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab + complete_head_from_modules($conf,$langs,null,$head,$h,'resource_admin'); + + $head[$h][0] = DOL_URL_ROOT.'/admin/resource_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFields"); + $head[$h][2] = 'attributes'; + $h++; + + complete_head_from_modules($conf,$langs,null,$head,$h,'resource_admin','remove'); + + return $head; + +} diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php index ee6162569b1..d3aa3405d0b 100644 --- a/htdocs/core/modules/modResource.class.php +++ b/htdocs/core/modules/modResource.class.php @@ -48,7 +48,7 @@ class modResource extends DolibarrModules // Use a free id here // (See in Home -> System information -> Dolibarr for list of used modules id). $this->numero = 63000; - + // Key text used to identify module (for permissions, menus, etc...) $this->rights_class = 'resource'; @@ -109,7 +109,7 @@ class modResource extends DolibarrModules // Config pages. Put here list of php pages // stored into resource/admin directory, used to setup module. - //$this->config_page_url = array("admin_resource.php@resource"); + $this->config_page_url = array("resource.php"); // Dependencies // List of modules id that must be enabled if this module is enabled @@ -199,8 +199,8 @@ class modResource extends DolibarrModules // Menus //------- $this->menu = 1; // This module add menu entries. They are coded into menu manager. - - + + // Add here list of permission defined by // an id, a label, a boolean and two constant strings. // Example: @@ -266,7 +266,7 @@ class modResource extends DolibarrModules 'target'=> '', 'user'=> 0 ); - + // Exports $r = 1; diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index 1b50ae0cc15..e14562c3480 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -140,3 +140,13 @@ ALTER TABLE llx_accounting_bookkeeping ADD COLUMN tms timestamp; ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (account_number, entity, fk_pcg_version); ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint + +create table llx_resource_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + +ALTER TABLE llx_resource_extrafields ADD INDEX idx_resource_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_resource_extrafields.key.sql b/htdocs/install/mysql/tables/llx_resource_extrafields.key.sql new file mode 100644 index 00000000000..af77b0c2474 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_resource_extrafields.key.sql @@ -0,0 +1,20 @@ +-- =================================================================== +-- Copyright (C) 2016 Florian Henry +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- =================================================================== + + +ALTER TABLE llx_resource_extrafields ADD INDEX idx_resource_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_resource_extrafields.sql b/htdocs/install/mysql/tables/llx_resource_extrafields.sql new file mode 100644 index 00000000000..4bda4091de4 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_resource_extrafields.sql @@ -0,0 +1,26 @@ +-- ======================================================================== +-- Copyright (C) 2016 Florian Henry +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + +create table llx_resource_extrafields +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + fk_object integer NOT NULL, + import_key varchar(14) -- import key +) ENGINE=innodb; + diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index f67a3df5429..ebe5f9a1aef 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1631,4 +1631,9 @@ LandingPage=Landing page SamePriceAlsoForSharedCompanies=If you use a multicompany module, with the choice "Single price", price will be also the same for all companies if products are shared between environments ModuleEnabledAdminMustCheckRights=Module has been activated. Permissions for activated module(s) were given to admin users only. You may need to grant permissions to other users manually if necessary. UserHasNoPermissions=This user has no permission defined -TypeCdr=Use "None" if the date of payment term is date of invoice plus a delta in days (delta is field "Nb of days")
Use "At end of month", if, after delta, the date must be increased to reach the end of month (+ an optional "Offset" in days)
Use "Current/Next" to have payment term date being the first Nth of the month (N is stored into field "Nb of days") \ No newline at end of file +TypeCdr=Use "None" if the date of payment term is date of invoice plus a delta in days (delta is field "Nb of days")
Use "At end of month", if, after delta, the date must be increased to reach the end of month (+ an optional "Offset" in days)
Use "Current/Next" to have payment term date being the first Nth of the month (N is stored into field "Nb of days") +##### Resource #### +ResourceSetup=Configuration du module Resource +UseSearchToSelectResource=Use a search form to choose a resource (rather than a drop-down list). +DisabledResourceLinkUser=Disabled resource link to user +DisabledResourceLinkContact=Disabled resource link to contact \ No newline at end of file diff --git a/htdocs/resource/add.php b/htdocs/resource/add.php index 7608e1b6cf3..7c60bf8091d 100644 --- a/htdocs/resource/add.php +++ b/htdocs/resource/add.php @@ -27,6 +27,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load traductions files required by page $langs->load("resource"); @@ -60,6 +61,11 @@ if ($user->societe_id > 0) $object = new DolResource($db); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); + if ($action == 'confirm_add_resource') { if (! $cancel) @@ -84,6 +90,12 @@ if ($action == 'confirm_add_resource') $object->description=$description; $object->fk_code_type_resource=$fk_code_type_resource; + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) { + $error ++; + } + $result=$object->create($user); if ($result > 0) { @@ -162,6 +174,15 @@ if (! $action) print ''; print ''; + // Other attributes + $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $object->showOptionals($extrafields,'edit'); + } + + print ''; dol_fiche_end(''); diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 95f5cf0574b..d2ec14efd71 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -29,9 +29,10 @@ if (! $res) $res=@include("../../main.inc.php"); // For "custom" directory if (! $res) die("Include of main fails"); require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; -require_once 'class/dolresource.class.php'; -require_once 'class/html.formresource.class.php'; +require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; +require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load traductions files requiredby by page $langs->load("resource"); @@ -58,6 +59,11 @@ if( ! $user->rights->resource->read) $object = new Dolresource($db); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); + $hookmanager->initHooks(array('resource_card','globalcard')); $parameters=array('resource_id'=>$id); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -88,6 +94,12 @@ if (empty($reshook)) $object->description = $description; $object->fk_code_type_resource = $fk_code_type_resource; + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + if ($ret < 0) { + $error ++; + } + $result=$object->update($user); if ($result > 0) { @@ -126,7 +138,7 @@ if (empty($reshook)) Header('Location: '.DOL_URL_ROOT.'/resource/list.php'); exit; } - else + else { setEventMessages($object->error, $object->errors, 'errors'); } @@ -188,6 +200,14 @@ if ( $object->fetch($id) > 0 ) print ''; print ''; + // Other attributes + $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $object->showOptionals($extrafields,'edit'); + } + print ''; dol_fiche_end(); @@ -235,6 +255,15 @@ if ( $object->fetch($id) > 0 ) print ''; print $object->description; print ''; + + // Other attributes + $parameters=array(); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + print $object->showOptionals($extrafields); + } + print ''; print ''; diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 633be01aa1b..2cf93493739 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -63,7 +63,7 @@ class Dolresource extends CommonObject */ function create($user, $notrigger=0) { - global $conf, $langs; + global $conf, $langs, $hookmanager; $error=0; // Clean parameters @@ -107,14 +107,40 @@ class Dolresource extends CommonObject if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element); + } + if (! $error) + { + $action='create'; + + // Actions on extra fields (by external module or standard code) + // TODO le hook fait double emploi avec le trigger !! + $hookmanager->initHooks(array('actioncommdao')); + $parameters=array('actcomm'=>$this->id); + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + else if ($reshook < 0) $error++; + } + + if (! $error) + { if (! $notrigger) { //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('RESOURCE_CREATE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('RESOURCE_CREATE',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers } } @@ -177,6 +203,13 @@ class Dolresource extends CommonObject $this->note_private = $obj->note_private; $this->type_label = $obj->type_label; + // Retreive all extrafield for thirdparty + // fetch optionals attributes and labels + require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); + $extrafields=new ExtraFields($this->db); + $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); + $this->fetch_optionals($this->id,$extralabels); + } $this->db->free($resql); @@ -199,7 +232,7 @@ class Dolresource extends CommonObject */ function update($user=null, $notrigger=0) { - global $conf, $langs; + global $conf, $langs, $hookmanager; $error=0; // Clean parameters @@ -229,13 +262,35 @@ class Dolresource extends CommonObject // want this action calls a trigger. //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('RESOURCE_MODIFY',$this,$user,$langs,$conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers } } + if (! $error) + { + $action='update'; + + // Actions on extra fields (by external module or standard code) + // TODO le hook fait double emploi avec le trigger !! + $hookmanager->initHooks(array('actioncommdao')); + $parameters=array('actcomm'=>$this->id); + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + else if ($reshook < 0) $error++; + } // Commit or rollback if ($error) @@ -294,10 +349,12 @@ class Dolresource extends CommonObject $this->mandatory = $obj->mandatory; $this->fk_user_create = $obj->fk_user_create; - if($obj->resource_id && $obj->resource_type) + if($obj->resource_id && $obj->resource_type) { $this->objresource = fetchObjectByElement($obj->resource_id,$obj->resource_type); - if($obj->element_id && $obj->element_type) + } + if($obj->element_id && $obj->element_type) { $this->objelement = fetchObjectByElement($obj->element_id,$obj->element_type); + } } $this->db->free($resql); @@ -324,36 +381,57 @@ class Dolresource extends CommonObject $error=0; - if (! $notrigger) - { - // Call trigger - $result=$this->call_trigger('RESOURCE_DELETE',$user); - if ($result < 0) return -1; - // End call triggers - } + $this->db->begin(); $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; $sql.= " WHERE rowid =".$rowid; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); + dol_syslog(get_class($this), LOG_DEBUG); if ($this->db->query($sql)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources"; $sql.= " WHERE element_type='resource' AND resource_id =".$this->db->escape($rowid); dol_syslog(get_class($this)."::delete", LOG_DEBUG); - if ($this->db->query($sql)) + $resql=$this->db->query($sql); + if (!$resql) { - return 1; - } - else { - $this->error=$this->db->lasterror(); - return -1; + $this->error=$this->db->lasterror(); + $error++; } } else { $this->error=$this->db->lasterror(); - return -1; + $error++; + } + + // Removed extrafields + if (! $error) { + $result=$this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error -3 ".$this->error, LOG_ERR); + } + } + + if (! $notrigger) + { + // Call trigger + $result=$this->call_trigger('RESOURCE_DELETE',$user); + if ($result < 0) $error++; + // End call triggers + } + + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; } } @@ -377,9 +455,20 @@ class Dolresource extends CommonObject $sql.= " t.description,"; $sql.= " t.fk_code_type_resource,"; $sql.= " t.tms,"; + + require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'); + $extrafields=new ExtraFields($this->db); + $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true); + if (is_array($extralabels) && count($extralabels)>0) { + foreach($extralabels as $label=>$code) { + $sql.= " ef.".$code." as extra_".$code.","; + } + } + $sql.= " ty.label as type_label"; $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_resource as ty ON ty.code=t.fk_code_type_resource"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX.$this->table_element."_extrafields as ef ON ef.fk_object=t.rowid"; $sql.= " WHERE t.entity IN (".getEntity('resource',1).")"; //Manage filter @@ -388,6 +477,9 @@ class Dolresource extends CommonObject if (strpos($key,'date')) { $sql.= ' AND '.$key.' = \''.$this->db->idate($value).'\''; } + elseif (strpos($key,'ef.')!==false){ + $sql.= $value; + } else { $sql.= ' AND '.$key.' LIKE \'%'.$value.'%\''; } @@ -419,6 +511,11 @@ class Dolresource extends CommonObject $line->fk_code_type_resource = $obj->fk_code_type_resource; $line->type_label = $obj->type_label; + // Retreive all extrafield for thirdparty + // fetch optionals attributes and labels + + $line->fetch_optionals($line->id,$extralabels); + $this->lines[] = $line; } $this->db->free($resql); diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 90eed125284..3b6338f0fce 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -41,28 +41,103 @@ $resource_id = GETPOST('resource_id','int'); $sortorder = GETPOST('sortorder','alpha'); $sortfield = GETPOST('sortfield','alpha'); -$page = GETPOST('page','int'); + +// Initialize context for list +$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'resourcelist'; $object = new Dolresource($db); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); +$search_ref=GETPOST("search_ref"); +$search_type=GETPOST("search_type"); + +$filter=array(); + +if ($search_ref != ''){ + $param.='&search_ref='.$search_ref; + $filter['t.ref']=$search_ref; +} +if ($search_type != ''){ + $param.='&search_type='.$search_type; + $filter['ty.label']=$search_type; +} +if ($search_label != '') $param.='&search_label='.$search_label; +// Add $param from extra fields +foreach ($search_array_options as $key => $val) +{ + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; + if ($val != '') { + $param.='&search_options_'.$tmpkey.'='.urlencode($val); + } + $mode=0; + if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric + if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) + { + $filter['ef.'.$tmpkey]=natural_search('ef.'.$tmpkey, $crit, $mode); + } +} +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + + $hookmanager->initHooks(array('resource_list')); if (empty($sortorder)) $sortorder="ASC"; if (empty($sortfield)) $sortfield="t.rowid"; if (empty($arch)) $arch = 0; +$page = GETPOST('page','int'); if ($page == -1) { - $page = 0 ; + $page = 0 ; } - -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; -$offset = $limit * $page ; +$page = is_numeric($page) ? $page : 0; +$page = $page == -1 ? 0 : $page; +if (! $sortfield) $sortfield="p.ref"; +if (! $sortorder) $sortorder="ASC"; +$offset = $conf->liste_limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; -if( ! $user->rights->resource->read) +if( ! $user->rights->resource->read) { accessforbidden(); +} +$arrayfields = array( + 't.ref' => array( + 'label' => $langs->trans("Ref"), + 'checked' => 1 + ), + 'ty.label' => array( + 'label' => $langs->trans("ResourceType"), + 'checked' => 1 + ), +); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { + foreach ( $extrafields->attribute_label as $key => $val ) { + $arrayfields["ef." . $key] = array( + 'label' => $extrafields->attribute_label[$key], + 'checked' => $extrafields->attribute_list[$key], + 'position' => $extrafields->attribute_pos[$key], + 'enabled' => $extrafields->attribute_perms[$key] + ); + } +} +include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + +// Do we click on purge search criteria ? +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers +{ + $search_ref=""; + $search_label=""; + $search_array_options=array(); + $filter=array(); +} /* * Action @@ -73,7 +148,6 @@ $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - /* * View */ @@ -86,11 +160,11 @@ llxHeader('',$pagetitle,''); // Confirmation suppression resource line if ($action == 'delete_resource') { - print $form->formconfirm($_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id."&lineid=".$lineid,$langs->trans("DeleteResource"),$langs->trans("ConfirmDeleteResourceElement"),"confirm_delete_resource",'','',1); + print $form->formconfirm($_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id."&lineid=".$lineid,$langs->trans("DeleteResource"),$langs->trans("ConfirmDeleteResourceElement"),"confirm_delete_resource",'','',1); } // Load object list -$ret = $object->fetch_all($sortorder, $sortfield, $limit, $offset); +$ret = $object->fetch_all($sortorder, $sortfield, $limit, $offset, $filter); if($ret == -1) { dol_print_error($db,$object->error); exit; @@ -100,11 +174,78 @@ if($ret == -1) { $var=true; +$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; +$selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + print ''."\n"; print ''; -print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'t.ref','',$param,'',$sortfield,$sortorder); -print_liste_field_titre($langs->trans('ResourceType'),$_SERVER['PHP_SELF'],'ty.code','',$param,'',$sortfield,$sortorder); -print_liste_field_titre('',"","","","",'width="60" align="center"',"",""); +if (! empty($arrayfields['t.ref']['checked'])) print_liste_field_titre($arrayfields['t.ref']['label'],$_SERVER["PHP_SELF"],"t.ref","",$param,"",$sortfield,$sortorder); +if (! empty($arrayfields['ty.label']['checked'])) print_liste_field_titre($arrayfields['ty.label']['label'],$_SERVER["PHP_SELF"],"t.code","",$param,"",$sortfield,$sortorder); +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); + } + } +} +print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); +print "\n"; + +print ''; +if (! empty($arrayfields['t.ref']['checked'])) +{ + print ''; +} +if (! empty($arrayfields['ty.label']['checked'])) +{ + print ''; +} +// Extra fields +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) +{ + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } + } +} +// Action column +print ''; print "\n"; if ($ret) @@ -118,13 +259,37 @@ if ($ret) print ''; - print ''; + if (! empty($arrayfields['t.ref']['checked'])) + { + print ''; + } - print ''; + if (! empty($arrayfields['ty.label']['checked'])) + { + print ''; + } + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + print 'getAlignFlag($key); + if ($align) print ' align="'.$align.'"'; + print '>'; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $resource->array_options[$tmpkey], '', 1); + print ''; + } + } + if (! $i) $totalarray['nbfield']++; + } print '
'; + print ''; + print ''; + print ''; + print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select'))) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; +$searchpitco=$form->showFilterAndCheckAddButtons(0); +print $searchpitco; +print '
'; - print $resource->getNomUrl(5); - print ''; + print $resource->getNomUrl(5); + print ''; - print $resource->type_label; - print ''; + print $resource->type_label; + print ''; print ''; @@ -140,6 +305,7 @@ if ($ret) } print '
'; + print "
\n"; } else { From 5bf03de3fbd000cc33d72387169359ce21d5459d Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 19 Oct 2016 22:24:04 +0200 Subject: [PATCH 22/53] Fix setup page --- htdocs/admin/resource.php | 44 +++++++++++++++----------------- htdocs/core/lib/resource.lib.php | 2 +- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/htdocs/admin/resource.php b/htdocs/admin/resource.php index fd3fe4829c1..d8fdddd2bb5 100644 --- a/htdocs/admin/resource.php +++ b/htdocs/admin/resource.php @@ -44,26 +44,17 @@ $action = GETPOST('action', 'alpha'); * Actions */ -if ($action == 'update') +if ($action == 'updateoptions') { - $error = 0; - - foreach ($list as $constname) { - $constvalue = GETPOST($constname, 'alpha'); - - if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } - - if (! $error) - { - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - } - else - { - setEventMessages($langs->trans("Error"), null, 'errors'); - } + if (GETPOST('activate_RESOURCE_USE_SEARCH_TO_SELECT')) + { + if (dolibarr_set_const($db, "RESOURCE_USE_SEARCH_TO_SELECT", GETPOST('activate_RESOURCE_USE_SEARCH_TO_SELECT'), 'chaine', 0, '', $conf->entity)) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } + } } /* @@ -79,23 +70,24 @@ print load_fiche_titre($langs->trans('ResourceSetup'),$linkback,'title_setup'); $head=resource_admin_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("ResourceSingular"), 0, 'action'); +dol_fiche_head($head, 'general', $langs->trans("ResourceSingular"), 0, 'action'); print '
'; print ''; -print ''; +print ''; $var=true; print ''; print ''; print ''."\n"; print ''."\n"; +print ''; // Utilisation formulaire Ajax sur choix produit $var=!$var; print ''; -print ''; +print ''; if (empty($conf->use_javascript_ajax)) { print ''; + print ''; } print ''; @@ -119,10 +114,10 @@ print ''; $var=!$var; print ''; print ''; -print ''; print ''; +print ''; print ''; $var=!$var; @@ -131,6 +126,7 @@ print ''; print ''; +print ''; print ''; print '
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'.$langs->trans("UseSearchToSelectResource").''.$langs->trans("UseSearchToSelectResource").''; @@ -111,7 +103,10 @@ else '2'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",2).')', '3'=>$langs->trans("Yes").' ('.$langs->trans("NumberOfKeyToSearch",3).')', ); - print $form->selectarray("activate_usesearchtoselectproduct",$arrval,$conf->global->RESOURCE_USE_SEARCH_TO_SELECT); + print $form->selectarray("activate_RESOURCE_USE_SEARCH_TO_SELECT",$arrval,$conf->global->RESOURCE_USE_SEARCH_TO_SELECT); + print ''; + print ''; print '
'.$langs->trans('DisabledResourceLinkUser').''; echo ajax_constantonoff('RESOURCE_HIDE_ADD_CONTACT_USER'); print '
'.$langs->trans('DisabledResourceLinkContact').''; echo ajax_constantonoff('RESOURCE_HIDE_ADD_CONTACT_THIPARTY'); print '
'; diff --git a/htdocs/core/lib/resource.lib.php b/htdocs/core/lib/resource.lib.php index 687ccacc15a..a6c63dc51e4 100644 --- a/htdocs/core/lib/resource.lib.php +++ b/htdocs/core/lib/resource.lib.php @@ -95,7 +95,7 @@ function resource_admin_prepare_head() { $head = array(); $head[$h][0] = DOL_URL_ROOT.'/admin/resource.php'; - $head[$h][1] = $langs->trans("Miscellaneous"); + $head[$h][1] = $langs->trans("ResourceSetup"); $head[$h][2] = 'general'; $h++; From d85dd69184595ae29daef0a6e1bfd713924fa30a Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 20 Oct 2016 13:14:28 +0200 Subject: [PATCH 23/53] NEW : get_full_arbo() & get_children_warehouses() functions documentation --- htdocs/product/stock/class/entrepot.class.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 452d9a59b69..109460cfa1a 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -616,7 +616,12 @@ class Entrepot extends CommonObject $this->country_id=1; $this->country_code='FR'; } - + + /** + * Return full path to current warehouse + * + * @return string String full path to current warehouse separated by " >> " + */ function get_full_arbo() { global $user,$langs,$conf; @@ -645,6 +650,13 @@ class Entrepot extends CommonObject } + /** + * Return array of children warehouses ids from $id warehouse (recursive function) + * + * @param int $id id parent warehouse + * @param array() $TChildWarehouses array which will contain all children (param by reference) + * @return array() $TChildWarehouses array which will contain all children + */ function get_children_warehouses($id, &$TChildWarehouses) { $sql = 'SELECT rowid From 9a3d4031c5dd6aa8d59bacac4ed6fc1a67736d93 Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 20 Oct 2016 13:30:47 +0200 Subject: [PATCH 24/53] FIX : param $protection - Deep counter to avoid infinite loop --- htdocs/product/stock/class/entrepot.class.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 109460cfa1a..da39522126a 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -620,17 +620,20 @@ class Entrepot extends CommonObject /** * Return full path to current warehouse * - * @return string String full path to current warehouse separated by " >> " + * @param int $protection Deep counter to avoid infinite loop + * @return string String full path to current warehouse separated by " >> " */ - function get_full_arbo() { + function get_full_arbo($protection=1000) { global $user,$langs,$conf; $TArbo = array($this->libelle); $id = $this->id; + + $i=0; - while(true) { + while((empty($protection) || $i < $protection)) { $sql = 'SELECT fk_parent FROM '.MAIN_DB_PREFIX.'entrepot WHERE rowid = '.$id; @@ -644,6 +647,9 @@ class Entrepot extends CommonObject $o->fetch($id); $TArbo[] = $o->libelle; } else break; + + $i++; + } return implode(' >> ', array_reverse($TArbo)); From 59941f998066ece0923d6748b645c7bc137fe2da Mon Sep 17 00:00:00 2001 From: gauthier Date: Thu, 20 Oct 2016 14:29:51 +0200 Subject: [PATCH 25/53] FIX : must not get full path with recursive query --- .../product/class/html.formproduct.class.php | 38 ++++++++++++++++--- htdocs/product/stock/card.php | 2 +- htdocs/product/stock/class/entrepot.class.php | 2 +- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index d550daf6ecb..d1fe225ba0e 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -67,7 +67,7 @@ class FormProduct if (is_array($exclude)) $excludeGroups = implode("','",$exclude); - $sql = "SELECT e.rowid, e.label, e.description"; + $sql = "SELECT e.rowid, e.label, e.description, e.fk_parent"; if (!empty($fk_product)) { if (!empty($batch)) @@ -118,14 +118,19 @@ class FormProduct { $obj = $this->db->fetch_object($resql); if ($sumStock) $obj->stock = price2num($obj->stock,5); - $o = new Entrepot($this->db); - $o->fetch($obj->rowid); $this->cache_warehouses[$obj->rowid]['id'] =$obj->rowid; - $this->cache_warehouses[$obj->rowid]['label']=$o->get_full_arbo(); + $this->cache_warehouses[$obj->rowid]['label']=$obj->label; + $this->cache_warehouses[$obj->rowid]['parent_id']=$obj->fk_parent; $this->cache_warehouses[$obj->rowid]['description'] = $obj->description; $this->cache_warehouses[$obj->rowid]['stock'] = $obj->stock; $i++; } + + // Full label init + foreach($this->cache_warehouses as $obj_rowid=>$tab) { + $this->cache_warehouses[$obj_rowid]['full_label'] = $this->get_parent_path($tab); + } + return $num; } else @@ -134,6 +139,29 @@ class FormProduct return -1; } } + + /** + * Return full path to current warehouse in $tab (recursive function) + * + * @param array $tab warehouse data in $this->cache_warehouses line + * @param String $final_label full label with all parents, separated by ' >> ' (completed on each call) + * @return String full label with all parents, separated by ' >> ' + */ + private function get_parent_path($tab, $final_label='') { + + if(empty($final_label)) $final_label = $tab['label']; + + if(empty($tab['parent_id'])) return $final_label; + else { + if(!empty($this->cache_warehouses[$tab['parent_id']])) { + $final_label = $this->cache_warehouses[$tab['parent_id']]['label'].' >> '.$final_label; + return $this->get_parent_path($this->cache_warehouses[$tab['parent_id']], $final_label); + } + } + + return $final_label; + + } /** * Return list of warehouses @@ -178,7 +206,7 @@ class FormProduct $out.=''; } diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 203288170c8..5adff357db1 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -646,7 +646,7 @@ else // Parent entrepot print ''.$langs->trans("AddIn").''; - print $formproduct->selectWarehouses($object->fk_parent, 'fk_parent', '', 1, 0, 0, '', 0, 0, array(), 'minwidth200', array($object->id)); + print $formproduct->selectWarehouses($object->fk_parent, 'fk_parent', '', 1); print ''; // Description diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index da39522126a..032a0f3a56d 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -174,7 +174,7 @@ class Entrepot extends CommonObject { // Check if new parent is already a child of current warehouse if(!empty($this->fk_parent)) { - $TChildWarehouses = array(); + $TChildWarehouses = array($id); $TChildWarehouses = $this->get_children_warehouses($this->id, $TChildWarehouses); if(in_array($this->fk_parent, $TChildWarehouses)) { $this->error = 'ErrorCannotAddThisParentWarehouse'; From ad72a8eed1689844be2a757cbee69a37684e3c0b Mon Sep 17 00:00:00 2001 From: aspangaro Date: Fri, 21 Oct 2016 06:34:02 +0200 Subject: [PATCH 26/53] Better presentation of invoice payment page --- htdocs/compta/paiement.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index ac03853a1b1..ed133716f86 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -461,24 +461,19 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; // Third party - print '\n"; + print '\n"; // Date payment print ''; - print ''; - - $rowspan=5; + print ''; // Payment mode print '\n"; - print ''; print ''; // Bank account @@ -493,7 +488,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } else { - print ''; + print ''; } print "\n"; @@ -515,6 +510,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; + // Comments + print ''; + print ''; + print '
'.$langs->trans('Company').''.$facture->thirdparty->getNomUrl(4)."
'.$langs->trans('Company').''.$facture->thirdparty->getNomUrl(4)."
'.$langs->trans('Date').''; $datepayment = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); $datepayment= ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE)?-1:'') : $datepayment); $form->select_date($datepayment,'','','',0,"add_paiement",1,1,0,0,'','',$facture->date); - print ''.$langs->trans('Comments').'
'.$langs->trans('PaymentMode').''; $form->select_types_paiements((GETPOST('paiementcode')?GETPOST('paiementcode'):$facture->mode_reglement_code),'paiementcode','',2); print "'; - print '
  
'.$langs->trans('Comments').''; + print '
'; dol_fiche_end(); From d1cafde77d3e08c53f85db2c5636579b56fc5a72 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Fri, 21 Oct 2016 06:39:39 +0200 Subject: [PATCH 27/53] No rowspan needed --- htdocs/compta/paiement.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index ed133716f86..3f8d97976bd 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -512,8 +512,8 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Comments print ''.$langs->trans('Comments').''; - print ''; - print ''; + print ''; + print ''; print ''; From 3cf44fcd3ef767609044273ce5e7c4dc1c9e4825 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Fri, 21 Oct 2016 07:02:43 +0200 Subject: [PATCH 28/53] Fix: Missing Currency title --- htdocs/compta/paiement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 3f8d97976bd..7bfbc9ea076 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -578,7 +578,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''.$arraytitle.''; print ''.$langs->trans('Date').''; - if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('Currency').''; + print ''.$langs->trans('Currency').''; if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('MulticurrencyAmountTTC').''; if (!empty($conf->multicurrency->enabled)) print ''.$multicurrencyalreadypayedlabel.''; if (!empty($conf->multicurrency->enabled)) print ''.$multicurrencyremaindertopay.''; From b67c4ece8dc718859032eddd0d24ae4a01aa8881 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Fri, 21 Oct 2016 07:04:08 +0200 Subject: [PATCH 29/53] Fix: Missing Currency column --- htdocs/compta/paiement.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 7bfbc9ea076..97630ca4252 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -578,7 +578,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''.$arraytitle.''; print ''.$langs->trans('Date').''; - print ''.$langs->trans('Currency').''; + if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('Currency').''; if (!empty($conf->multicurrency->enabled)) print ''.$langs->trans('MulticurrencyAmountTTC').''; if (!empty($conf->multicurrency->enabled)) print ''.$multicurrencyalreadypayedlabel.''; if (!empty($conf->multicurrency->enabled)) print ''.$multicurrencyremaindertopay.''; @@ -633,7 +633,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''.dol_print_date($db->jdate($objp->df),'day')."\n"; // Currency - print ''.$objp->multicurrency_code."\n"; + if (!empty($conf->multicurrency->enabled)) print ''.$objp->multicurrency_code."\n"; // Multicurrency Price if (!empty($conf->multicurrency->enabled)) From 50a5fe6fd9551f38390ae54d4519f997b7e14ad4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Oct 2016 18:24:46 +0200 Subject: [PATCH 30/53] Work on accounting module --- htdocs/core/menus/init_menu_auguria.sql | 35 ++++++++++++++----------- htdocs/core/menus/standard/eldy.lib.php | 14 +++++----- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 058f954ffbe..507bca321c6 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -101,7 +101,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2802__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/list.php?leftmenu=product&type=0', 'List', 1, 'products', '$user->rights->produit->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->product->enabled', __HANDLER__, 'left', 2803__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassort.php?type=0', 'Stocks', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->productbatch->enabled', __HANDLER__, 'left', 2805__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/reassortlot.php?type=0', 'StocksByLotSerial', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 5, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->productbatch->enabled', __HANDLER__, 'left', 2805__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/stock/productlot_list.php', 'LotSerial', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 6, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->productbatch->enabled', __HANDLER__, 'left', 2806__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/stock/productlot_list.php', 'LotSerial', 1, 'products', '$user->rights->produit->lire && $user->rights->stock->lire', '', 2, 6, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->propal->enabled', __HANDLER__, 'left', 2804__+MAX_llx_menu__, 'products', '', 2800__+MAX_llx_menu__, '/product/stats/card.php?id=all&leftmenu=stats&type=0', 'Statistics', 1, 'main', '$user->rights->produit->lire', '', 2, 7, __ENTITY__); -- Product - Services insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->service->enabled', __HANDLER__, 'left', 2900__+MAX_llx_menu__, 'products', 'service', 3__+MAX_llx_menu__, '/product/index.php?leftmenu=service&type=1', 'Services', 0, 'products', '$user->rights->service->lire', '', 2, 1, __ENTITY__); @@ -156,10 +156,10 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled', __HANDLER__, 'left', 1401__+MAX_llx_menu__, 'commercial', '', 1400__+MAX_llx_menu__, '/contrat/card.php?&action=create&leftmenu=contracts', 'NewContract', 1, 'contracts', '$user->rights->contrat->creer', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled', __HANDLER__, 'left', 1402__+MAX_llx_menu__, 'commercial', '', 1400__+MAX_llx_menu__, '/contrat/list.php?leftmenu=contracts', 'List', 1, 'contracts', '$user->rights->contrat->lire', '', 2, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled', __HANDLER__, 'left', 1403__+MAX_llx_menu__, 'commercial', '', 1400__+MAX_llx_menu__, '/contrat/services.php?leftmenu=contracts', 'MenuServices', 1, 'contracts', '$user->rights->contrat->lire', '', 2, 2, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled&&$leftmenu=="contracts"', __HANDLER__, 'left', 1404__+MAX_llx_menu__, 'commercial', '', 1403__+MAX_llx_menu__, '/contrat/services.php?leftmenu=contracts&mode=0', 'MenuInactiveServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled&&$leftmenu=="contracts"', __HANDLER__, 'left', 1405__+MAX_llx_menu__, 'commercial', '', 1403__+MAX_llx_menu__, '/contrat/services.php?leftmenu=contracts&mode=4', 'MenuRunningServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled&&$leftmenu=="contracts"', __HANDLER__, 'left', 1406__+MAX_llx_menu__, 'commercial', '', 1403__+MAX_llx_menu__, '/contrat/services.php?leftmenu=contracts&mode=4&filter=expired', 'MenuExpiredServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 2, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled&&$leftmenu=="contracts"', __HANDLER__, 'left', 1407__+MAX_llx_menu__, 'commercial', '', 1403__+MAX_llx_menu__, '/contrat/services.php?leftmenu=contracts&mode=5', 'MenuClosedServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 3, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled && $leftmenu=="contracts"', __HANDLER__, 'left', 1404__+MAX_llx_menu__, 'commercial', '', 1403__+MAX_llx_menu__, '/contrat/services.php?leftmenu=contracts&mode=0', 'MenuInactiveServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled && $leftmenu=="contracts"', __HANDLER__, 'left', 1405__+MAX_llx_menu__, 'commercial', '', 1403__+MAX_llx_menu__, '/contrat/services.php?leftmenu=contracts&mode=4', 'MenuRunningServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 1, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled && $leftmenu=="contracts"', __HANDLER__, 'left', 1406__+MAX_llx_menu__, 'commercial', '', 1403__+MAX_llx_menu__, '/contrat/services.php?leftmenu=contracts&mode=4&filter=expired', 'MenuExpiredServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 2, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->contrat->enabled && $leftmenu=="contracts"', __HANDLER__, 'left', 1407__+MAX_llx_menu__, 'commercial', '', 1403__+MAX_llx_menu__, '/contrat/services.php?leftmenu=contracts&mode=5', 'MenuClosedServices', 2, 'contracts', '$user->rights->contrat->lire', '', 2, 3, __ENTITY__); -- Commercial - Interventions insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->ficheinter->enabled', __HANDLER__, 'left', 1500__+MAX_llx_menu__, 'commercial', 'ficheinter', 5__+MAX_llx_menu__, '/fichinter/list.php?leftmenu=ficheinter', 'Interventions', 0, 'interventions', '$user->rights->ficheinter->lire', '', 2, 8, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->ficheinter->enabled', __HANDLER__, 'left', 1501__+MAX_llx_menu__, 'commercial', '', 1500__+MAX_llx_menu__, '/fichinter/card.php?action=create&leftmenu=ficheinter', 'NewIntervention', 1, 'interventions', '$user->rights->ficheinter->creer', '', 2, 0, __ENTITY__); @@ -210,19 +210,22 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2303__+MAX_llx_menu__, 'accountancy', '', 2300__+MAX_llx_menu__, '/compta/tva/clients.php?leftmenu=tax_vat', 'ReportByCustomers', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled && empty($conf->global->TAX_DISABLE_VAT_MENUS) && $leftmenu=="tax_vat"', __HANDLER__, 'left', 2304__+MAX_llx_menu__, 'accountancy', '', 2300__+MAX_llx_menu__, '/compta/tva/quadri_detail.php?leftmenu=tax_vat', 'ReportByQuarter', 2, 'companies', '$user->rights->tax->charges->lire', '', 0, 3, __ENTITY__); -- Accounting Expert -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accounting', 6__+MAX_llx_menu__, '/accountancy/index.php?leftmenu=accounting', 'MenuAccountancy', 0, 'accountancy', '! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2400__+MAX_llx_menu__, 'accountancy', 'accounting', 6__+MAX_llx_menu__, '/accountancy/index.php?leftmenu=accountancy', 'MenuAccountancy', 0, 'accountancy', '! empty($conf->accounting->enabled) || $user->rights->accounting->bind->write || $user->rights->accounting->bind->write || $user->rights->compta->resultat->lire', '', 0, 7, __ENTITY__); -- Setup - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2451__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chartmodel', 2400__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Pcg_version', 1, 'accountancy_admin', '$user->rights->accounting->chartofaccount', '', 0, 1, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2452__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart', 2400__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Chartofaccounts', 1, 'accountancy_admin', '$user->rights->accounting->chartofaccount', '', 0, 2, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2453__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_default', 2400__+MAX_llx_menu__, '/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuDefaultAccounts', 1, 'accountancy_admin', '$user->rights->accounting->chartofaccount', '', 0, 3, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2454__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_product', 2400__+MAX_llx_menu__, '/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'ProductsBinding', 1, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 4, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2451__+MAX_llx_menu__, 'accountancy', 'accountancy_admin', 2400__+MAX_llx_menu__, '/accountancy/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Setup', 1, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 1, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2455__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chartmodel', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Pcg_version', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 10, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2456__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_chart', 2451__+MAX_llx_menu__, '/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'Chartofaccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 20, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2457__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_default', 2451__+MAX_llx_menu__, '/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuDefaultAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 30, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2458__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_vat', 2451__+MAX_llx_menu__, '/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuVatAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 40, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2459__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_tax', 2451__+MAX_llx_menu__, '/accountancy/admin/index.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuTaxAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 50, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="accountancy_admin"', __HANDLER__, 'left', 2460__+MAX_llx_menu__, 'accountancy', 'accountancy_admin_product', 2451__+MAX_llx_menu__, '/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin', 'MenuProductsAccounts', 2, 'accountancy', '$user->rights->accounting->chartofaccount', '', 0, 60, __ENTITY__); -- Binding - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', 'dispatch_customer', 2400__+MAX_llx_menu__, '/accountancy/customer/index.php?leftmenu=dispatch_customer', 'CustomersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 1, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="dispatch_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/list.php', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 2, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="dispatch_customer"', __HANDLER__, 'left', 2403__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/lines.php', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 3, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled', __HANDLER__, 'left', 2410__+MAX_llx_menu__, 'accountancy', 'ventil_supplier', 2400__+MAX_llx_menu__, '/accountancy/supplier/index.php?leftmenu=dispatch_supplier', 'SuppliersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 4, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled && $leftmenu=="dispatch_supplier"', __HANDLER__, 'left', 2411__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/list.php', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 5, __ENTITY__); - insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled && $leftmenu=="dispatch_supplier"', __HANDLER__, 'left', 2412__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/lines.php', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 6, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2401__+MAX_llx_menu__, 'accountancy', 'dispatch_customer', 2400__+MAX_llx_menu__, '/accountancy/customer/index.php?leftmenu=dispatch_customer', 'CustomersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 2, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="dispatch_customer"', __HANDLER__, 'left', 2402__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/list.php', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 3, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $leftmenu=="dispatch_customer"', __HANDLER__, 'left', 2403__+MAX_llx_menu__, 'accountancy', '', 2401__+MAX_llx_menu__, '/accountancy/customer/lines.php', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 4, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled', __HANDLER__, 'left', 2410__+MAX_llx_menu__, 'accountancy', 'ventil_supplier', 2400__+MAX_llx_menu__, '/accountancy/supplier/index.php?leftmenu=dispatch_supplier', 'SuppliersVentilation', 1, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 5, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled && $leftmenu=="dispatch_supplier"', __HANDLER__, 'left', 2411__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/list.php', 'ToDispatch', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 6, __ENTITY__); + insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled && $conf->fournisseur->enabled && $leftmenu=="dispatch_supplier"', __HANDLER__, 'left', 2412__+MAX_llx_menu__, 'accountancy', '', 2410__+MAX_llx_menu__, '/accountancy/supplier/lines.php', 'Dispatched', 2, 'accountancy', '$user->rights->accounting->bind->write', '', 0, 7, __ENTITY__); -- Journals -- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->accounting->enabled', __HANDLER__, 'left', 2420__+MAX_llx_menu__, 'accountancy', 'journal', 2400__+MAX_llx_menu__, '/accountancy/journal/index.php?leftmenu=journal', 'Journaux', 1, 'accountancy', '$user->rights->accounting->comptarapport->lire', '', 0, 7, __ENTITY__); -- General Ledger diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index b5f672d5210..a0278f2527e 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -942,13 +942,13 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/accountancy/index.php?leftmenu=accountancy",$langs->trans("MenuAccountancy"), 0, $permtoshowmenu, '', $mainmenu, 'accountancy'); // Chart of account - if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("", $langs->trans("Setup"),1,$user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1); - if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 10); - if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 20); - if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 40); - if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 30); - if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 30); - if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 50); + if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/index.php?leftmenu=accountancy_admin", $langs->trans("Setup"),1,$user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin', 1); + if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 10); + if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 20); + if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 40); + if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 30); + if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 30); + if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 50); // Binding if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&mainmenu=accountancy",$langs->trans("CustomersVentilation"),1,$user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer'); From 3219c07adc9f3bc52a4ed900781abb99e47eb6ee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 21 Oct 2016 18:45:44 +0200 Subject: [PATCH 31/53] FIX Avoid error if no data --- htdocs/compta/bank/graph.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 5f00a500c31..9db2bb35233 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -107,6 +107,8 @@ else { dol_print_error($db); } + if (empty($min)) $min = dol_now - 3600 * 24; + $log="graph.php: min=".$min." max=".$max; dol_syslog($log); From 4f713e323790da640e0451d1d76f618bfa01553c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20L=C3=A9onard?= Date: Sat, 22 Oct 2016 01:57:25 +0200 Subject: [PATCH 32/53] Add file scheme to allowed URIs schemes for links --- htdocs/core/actions_linkedfiles.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php index 6f2d4a2128f..672da011a79 100644 --- a/htdocs/core/actions_linkedfiles.inc.php +++ b/htdocs/core/actions_linkedfiles.inc.php @@ -40,7 +40,7 @@ elseif (GETPOST('linkit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) $link = GETPOST('link', 'alpha'); if ($link) { - if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://') { + if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://' && substr($link, 0, 7) != 'file://') { $link = 'http://' . $link; } dol_add_file_process($upload_dir, 0, 1, 'userfile', null, $link); @@ -124,7 +124,7 @@ elseif ($action == 'confirm_updateline' && GETPOST('save') && GETPOST('link', 'a if ($f) { $link->url = GETPOST('link', 'alpha'); - if (substr($link->url, 0, 7) != 'http://' && substr($link->url, 0, 8) != 'https://') + if (substr($link->url, 0, 7) != 'http://' && substr($link->url, 0, 8) != 'https://' && substr($link->url, 0, 7) != 'file://') { $link->url = 'http://' . $link->url; } From 06c70e5a15388ac04ef039a1fd5eab01d7a75908 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 22 Oct 2016 06:42:45 +0200 Subject: [PATCH 33/53] Better presentation for user edit card --- htdocs/user/card.php | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index fb3ad2fe3f0..d2c96ab7950 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1784,15 +1784,6 @@ else dol_fiche_head($head, 'user', $title, 0, 'user'); - $rowspan=22; - if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) $rowspan++; - if (! empty($conf->societe->enabled)) $rowspan++; - if (! empty($conf->adherent->enabled)) $rowspan++; - if (! empty($conf->skype->enabled)) $rowspan++; - if (! empty($conf->salaries->enabled) && ! empty($user->rights->salaries->read)) $rowspan = $rowspan+3; - if (! empty($conf->agenda->enabled)) $rowspan++; - if (! empty($conf->accounting->enabled)) $rowspan++; - print ''; // Ref/ID @@ -1819,12 +1810,6 @@ else print $object->lastname; } print ''; - - // Photo - print ''; - print ''; // Firstname @@ -1841,6 +1826,14 @@ else } print ''; + // Photo + print ''; + print ''; + print ''; + print ''; + // Employee print ''; print ''; } if (! empty($arrayfields['b.debit']['checked'])) @@ -664,7 +885,7 @@ if ($resql) } // Num cheque - if (! empty($arrayfields['b.num_releve']['checked'])) + if (! empty($arrayfields['b.num_chq']['checked'])) { print '\n"; if (! $i) $totalarray['nbfield']++; @@ -734,7 +955,7 @@ if ($resql) // Balance if (! empty($arrayfields['balance']['checked'])) { - if ($mode_balance_ok) + if ($mode_balance_ok) { if ($total >= 0) { @@ -751,60 +972,68 @@ if ($resql) } } - // Transaction reconciliated or edit link - if ($objp->rappro && $bankaccount->canBeConciliated() > 0) // If line not conciliated and account can be conciliated + if (! empty($arrayfields['b.num_releve']['checked'])) { - print '"; - } - else - { - print ''; + print ''; + if (! $i) $totalarray['nbfield']++; } // Action column - print ''; - if (! $i) $totalarray['nbfield']++; - + print ''; + if (! $i) $totalarray['nbfield']++; + print ""; $i++; diff --git a/htdocs/compta/bank/budget.php b/htdocs/compta/bank/budget.php index 666ad0085e1..cd6d2adb796 100644 --- a/htdocs/compta/bank/budget.php +++ b/htdocs/compta/bank/budget.php @@ -76,7 +76,7 @@ if ($result) $objp = $db->fetch_object($result); $var=!$var; print ""; - print ""; + print ""; print ''; print '"; print '"; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index dfeea54c510..ac5430c74be 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1234,7 +1234,7 @@ class Account extends CommonObject } else if ($mode == 'transactions') { - $link = ''; } else if ($mode == 'receipts') diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index 9db2bb35233..bf69fe98a3b 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -771,7 +771,7 @@ if ($account) if ($_GET["option"]!='all') { $morehtml=''.$langs->trans("ShowAllAccounts").''; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', '', $moreparam, 0, '', '', 1); } else { diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index a29e3643812..7d3073d7129 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -423,7 +423,7 @@ foreach ($accounts as $key=>$type) print ''; print ''; print ''; // Action column diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 0d307115ed9..f02b4326a31 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -271,7 +271,7 @@ if ($result) print '
'; - print $form->showphoto('userphoto',$object,100,0,$caneditfield,'photowithmargin','small'); - print '
'.$langs->trans("Photo").''; + print $form->showphoto('userphoto',$object,100,0,$caneditfield,'photowithmargin','small'); + print '
'.fieldLabel('Employee','employee',0).''; From cdb8224c1a521051d5dda24ae1138da1fe134d60 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 22 Oct 2016 07:19:55 +0200 Subject: [PATCH 34/53] Better presentation for member edit card --- htdocs/adherents/card.php | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 8e302643317..90e96b23a83 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -1048,10 +1048,6 @@ else print ''."\n"; } - $rowspan=15; - if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) $rowspan++; - if (! empty($conf->societe->enabled)) $rowspan++; - print ''; print ''; print ''; @@ -1064,7 +1060,7 @@ else print ''; // Ref - print ''; + print ''; // Login if (empty($conf->global->ADHERENT_LOGIN_NOT_REQUIRED)) @@ -1077,21 +1073,7 @@ else $morphys["mor"] = $langs->trans("Morale"); print '"; - - // Photo - print ''; + print ""; // Type print ''; print ''; + // Photo + print ''; + print ''; + // EMail print ''; From 14e78ef50bda5c588b8ced2e48e66634b78e4742 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Oct 2016 13:20:14 +0200 Subject: [PATCH 35/53] Mutualize code of 2 lists into one page. --- htdocs/compta/bank/account.php | 2 +- htdocs/compta/bank/annuel.php | 2 +- .../bank/{search.php => bankentries.php} | 355 ++++++++++++++---- htdocs/compta/bank/budget.php | 2 +- htdocs/compta/bank/class/account.class.php | 2 +- htdocs/compta/bank/graph.php | 2 +- htdocs/compta/bank/index.php | 2 +- htdocs/compta/bank/ligne.php | 2 +- htdocs/compta/bank/rappro.php | 2 +- htdocs/compta/bank/releve.php | 19 +- .../bank/{virement.php => transfer.php} | 10 +- htdocs/compta/paiement/cheque/list.php | 2 +- htdocs/core/lib/bank.lib.php | 6 +- htdocs/core/lib/functions.lib.php | 5 +- htdocs/core/menus/init_menu_auguria.sql | 4 +- htdocs/core/menus/standard/eldy.lib.php | 4 +- htdocs/fourn/facture/paiement.php | 2 +- htdocs/langs/en_US/banks.lang | 36 +- htdocs/langs/en_US/errors.lang | 4 +- htdocs/langs/en_US/install.lang | 2 +- htdocs/langs/en_US/main.lang | 2 +- htdocs/langs/en_US/members.lang | 4 +- 22 files changed, 345 insertions(+), 126 deletions(-) rename htdocs/compta/bank/{search.php => bankentries.php} (75%) rename htdocs/compta/bank/{virement.php => transfer.php} (92%) diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 9a5a19a1e09..26265316ea6 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -33,6 +33,7 @@ require('../../main.inc.php'); require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; @@ -42,7 +43,6 @@ require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->load("banks"); $langs->load("categories"); diff --git a/htdocs/compta/bank/annuel.php b/htdocs/compta/bank/annuel.php index 6115c0f6c84..9acf83db399 100644 --- a/htdocs/compta/bank/annuel.php +++ b/htdocs/compta/bank/annuel.php @@ -147,7 +147,7 @@ if (!empty($id)) { if (! preg_match('/,/', $id)) { - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); } else { diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/bankentries.php similarity index 75% rename from htdocs/compta/bank/search.php rename to htdocs/compta/bank/bankentries.php index 4b03250e76a..4f05210f411 100644 --- a/htdocs/compta/bank/search.php +++ b/htdocs/compta/bank/bankentries.php @@ -21,7 +21,7 @@ */ /** - * \file htdocs/compta/bank/search.php + * \file htdocs/compta/bank/bankentries.php * \ingroup banque * \brief List of bank transactions */ @@ -29,6 +29,7 @@ require('../../main.inc.php'); require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -48,10 +49,31 @@ $langs->load("bills"); $langs->load("categories"); $langs->load("companies"); $langs->load("margins"); +$langs->load("salaries"); +$langs->load("loan"); +$langs->load("donations"); +$langs->load("trips"); +$langs->load("members"); + +$id = GETPOST('id','int'); +$ref = GETPOST('ref','alpha'); +$action=GETPOST('action','alpha'); +$cancel=GETPOST('cancel','alpha'); +$confirm=GETPOST('confirm','alpha'); // Security check -if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,'banque'); +$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); +$fieldtype = (! empty($ref) ? 'ref' :'rowid'); +if ($fielvalue) +{ + if ($user->societe_id) $socid=$user->societe_id; + $result=restrictedArea($user,'banque',$fieldvalue,'bank_account&bank_account','','',$fieldtype); +} +else +{ + if ($user->societe_id) $socid=$user->societe_id; + $result=restrictedArea($user,'banque'); +} $search_ref=GETPOST('search_ref','alpha'); $description=GETPOST("description",'alpha'); @@ -90,11 +112,20 @@ if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid') && $a if (strtolower($sortorder) == 'desc') $mode_balance_ok = false; +$object = new Account($db); +if ($id > 0 || ! empty($ref)) +{ + $result=$object->fetch($id, $ref); + $account = $object->id; // Force the search field on id of account +} + + // Initialize technical object to manage context to save list fields -$contextpage='banktransactionlist'; +$contextpage='banktransactionlist'.(empty($object->ref)?'':'-'.$object->id); +//var_dump($contextpage); // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array($contextpage)); +$hookmanager->initHooks(array('banktransactionlist', $contextpage)); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels @@ -109,7 +140,7 @@ $arrayfields=array( 'type'=>array('label'=>$langs->trans("Type"), 'checked'=>1), 'b.num_chq'=>array('label'=>$langs->trans("Numero"), 'checked'=>1), 'bu.label'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>500), - 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1, 'position'=>1000), + 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>(($id > 0 || ! empty($ref))?0:1), 'position'=>1000), 'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600), 'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605), 'balance'=>array('label'=>$langs->trans("Balance"), 'checked'=>1, 'position'=>1000), @@ -166,6 +197,69 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } +$dateop=-1; + +if (GETPOST('save') && $id && ! $cancel && $user->rights->banque->modifier) +{ + $error = 0; + + if (price2num($_POST["addcredit"]) > 0) + { + $amount = price2num($_POST["addcredit"]); + } + else + { + $amount = - price2num($_POST["adddebit"]); + } + + $dateop = dol_mktime(12,0,0,$_POST["opmonth"],$_POST["opday"],$_POST["opyear"]); + $operation=$_POST["operation"]; + $num_chq=$_POST["num_chq"]; + $label=$_POST["label"]; + $cat1=$_POST["cat1"]; + + if (! $dateop) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Date")), null, 'errors'); + } + if (! $operation) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Type")), null, 'errors'); + } + if (! $amount) { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Amount")), null, 'errors'); + } + + if (! $error) + { + $object->fetch($id); + $insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user); + if ($insertid > 0) + { + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + else + { + $action='addline'; + } +} + +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->modifier) +{ + $accline=new AccountLine($db); + $result=$accline->fetch(GETPOST("rowid")); + $result=$accline->delete($user); +} + + /* * View @@ -193,7 +287,74 @@ $banklinestatic=new AccountLine($db); $now = dol_now(); -llxHeader('', $langs->trans("BankTransactions"), '', '', 0, 0, array(), array(), $param); + + +if ($id > 0 || ! empty($ref)) +{ + $title = $langs->trans("FinancialAccount").' - '.$langs->trans("Transactions"); + $helpurl = ""; + llxHeader('',$title,$helpurl); + + // Load bank groups + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; + $bankcateg = new BankCateg($db); + $options = array(); + + foreach ($bankcateg->fetchAll() as $bankcategory) { + $options[$bankcategory->id] = $bankcategory->label; + } + + // Onglets + $head=bank_prepare_head($object); + dol_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0,'account'); + + $linkback = ''.$langs->trans("BackToList").''; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); + + dol_fiche_end(); + + + + /* + * Buttons actions + */ + + //if ($action != 'delete') + //{ + print '
'; + + if ($action != 'addline') + { + if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) + { + if ($user->rights->banque->modifier) { + print 'id.'&page='.$page.($vline?'&vline='.$vline:'').'">'.$langs->trans("AddBankRecord").''; + } else { + print ''.$langs->trans("AddBankRecord").''; + } + } else { + print ''.$langs->trans("AddBankRecord").''; + } + } + + if ($object->canBeConciliated() > 0) { + // If not cash account and can be reconciliate + if ($user->rights->banque->consolidate) { + print ''.$langs->trans("Conciliate").''; + } else { + print ''.$langs->trans("Conciliate").''; + } + } + + print '
'; + //} + +} +else +{ + llxHeader('', $langs->trans("BankTransactions"), '', '', 0, 0, array(), array(), $param); +} $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq,"; $sql.= " b.fk_account, b.fk_type,"; @@ -261,7 +422,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql.= $db->plimit($limit+1,$offset); -dol_syslog('compta/bank/search.php::', LOG_DEBUG); +dol_syslog('compta/bank/bankentries.php', LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -273,6 +434,8 @@ if ($resql) $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + if ($id > 0) $param.='&id='.urlencode($id); + if (!empty($ref)) $param.='&ref='.urlencode($ref); if (!empty($search_ref)) $param.='&search_ref='.urlencode($search_ref); if (!empty($description)) $param.='&description='.urlencode($description); if (!empty($type)) $param.='&type='.urlencode($type); @@ -303,6 +466,15 @@ if ($resql) if ($massaction == 'presend') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); + + // Confirmation delete + if ($action == 'delete') + { + $text=$langs->trans('ConfirmDeleteTransaction'); + print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid"), $langs->trans('DeleteTransaction'), $text, 'confirm_delete', null, '', 1); + } + + // Lines of title fields print ''."\n"; if ($optioncss != '') print ''; @@ -312,8 +484,55 @@ if ($resql) print ''; print ''; print ''; + print ''; + print ''; if (! empty($_REQUEST['bid'])) print ''; + + // Form to add a transaction with no invoice + if ($user->rights->banque->modifier && $action == 'addline') + { + print load_fiche_titre($langs->trans("AddBankRecordLong"),'',''); + + print '
'.$langs->trans("Ref").''.$object->id.'
'.$langs->trans("Ref").''.$object->id.'
'.$langs->trans("Nature").''; print $form->selectarray("morphy", $morphys, isset($_POST["morphy"])?$_POST["morphy"]:$object->morphy); - print "'; - print $form->showphoto('memberphoto',$object)."\n"; - if ($caneditfieldmember) - { - if ($object->photo) print "
\n"; - print ''; - if ($object->photo) print ''; - print ''; - print ''; - print '
'.$langs->trans("Delete").'

'.$langs->trans("PhotoFile").'
'; - } - print '
'.$langs->trans("Type").''; @@ -1123,6 +1105,21 @@ else print '
'.$langs->trans("Firstname").'firstname).'">
'.$langs->trans("Photo").''; + print $form->showphoto('memberphoto',$object)."\n"; + if ($caneditfieldmember) + { + if ($object->photo) print "
\n"; + print ''; + if ($object->photo) print ''; + print ''; + print ''; + print '
'.$langs->trans("Delete").'

'.$langs->trans("PhotoFile").'
'; + } + print '
'.($conf->global->ADHERENT_MAIL_REQUIRED?'':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'':'').'email).'">
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans("Date").' '.$langs->trans("Type").''.$langs->trans("Numero").''.$langs->trans("Description").''.$langs->trans("Debit").''.$langs->trans("Credit").' 
'; + $form->select_date($dateop,'op',0,0,0,'transaction'); + print ''; + $form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == Account::TYPE_CASH ? 'LIQ' : '')),'operation','1,2',2,1); + print ''; + print ''; + print ''; + if ($options) { + print '
'.$langs->trans("Rubrique").': '; + print Form::selectarray('cat1', $options, GETPOST('cat1'), 1); + } + print '
'; + print '
'; + print ''; + print '
'; + print '
'; + } + + + $i = 0; // Title @@ -324,14 +543,16 @@ if ($resql) $morehtml.='/'.$nbtotalofpages.' '; $morehtml.=''; + $picto='title_bank'; + if ($id > 0 || ! empty($ref)) $picto=''; if (GETPOST("bid")) { $result=$bankcateg->fetch(GETPOST("bid")); - print_barre_liste($langs->trans("BankTransactionForCategory",$bankcateg->label).' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_bank.png', 0, $morehtml, '', $limit); + print_barre_liste($langs->trans("BankTransactionForCategory",$bankcateg->label).' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml, '', $limit); } else { - print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_bank.png', 0, $morehtml, '', $limit); + print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml, '', $limit); } $moreforfilter = ''; @@ -433,7 +654,7 @@ if ($resql) if (! empty($arrayfields['ba.ref']['checked'])) { print '
'; - $form->select_comptes($account,'account',0,'',1); + $form->select_comptes($account,'account',0,'',1, ($id > 0 || ! empty($ref)?' disabled="disabled"':'')); print ''.($objp->num_chq?$objp->num_chq:"")."'; - print ''; - print img_edit(); - print ''; - print "  "; - print ''.$objp->num_releve.''; - print "'; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print ''; - print img_edit(); - print ''; - } - else - { - print ''; - print img_view(); - print ''; - } - if ($bankaccount->canBeConciliated() > 0 && empty($objp->rappro)) - { - if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay)) - { - print ' '.img_warning($langs->trans("Late")); - } - } - print ' '; - if ($user->rights->banque->modifier) - { - print 'rowid.'&id='.$object->id.'&page='.$page.'">'; - print img_delete(); - print ''; - } - print ''; + // Transaction reconciliated or edit link + if ($objp->rappro && $bankaccount->canBeConciliated() > 0) // If line not conciliated and account can be conciliated + { + print ''; + print img_edit(); + print ''; + print "  "; + print ''.$objp->num_releve.''; + } + else + { + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + print img_edit(); + print ''; + } + else + { + print ''; + print img_view(); + print ''; + } + if ($bankaccount->canBeConciliated() > 0 && empty($objp->rappro)) + { + if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay)) + { + print ' '.img_warning($langs->trans("Late")); + } + } + print ' '; + if ($user->rights->banque->modifier) + { + print 'rowid.'&id='.$object->id.'&page='.$page.'">'; + print img_delete(); + print ''; + } + } + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print ''; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; - } - print ''; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
rowid\">$objp->labelrowid\">$objp->label'.$objp->nombre.''.price(abs($objp->somme))."'.price(abs(price2num($objp->somme / $objp->nombre,'MT')))."'.$acc->getLibStatut(2).''; - print ''.price($solde, 0, $langs, 0, 0, -1, $acc->currency_code).''; + print ''.price($solde, 0, $langs, 0, 0, -1, $acc->currency_code).''; print '
'; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; // Ref print '"; diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php index 8f6cd29afdb..e3ef2ea5a57 100644 --- a/htdocs/compta/bank/rappro.php +++ b/htdocs/compta/bank/rappro.php @@ -181,7 +181,7 @@ if ($resql) $var=True; $num = $db->num_rows($resql); - print load_fiche_titre($langs->trans("Reconciliation").': '.$acct->label.'', '', 'title_bank.png'); + print load_fiche_titre($langs->trans("Reconciliation").': '.$acct->label.'', '', 'title_bank.png'); print '
'; // Show last bank receipts diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index ff50b3e66e5..06c213485f8 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -126,24 +126,13 @@ if (empty($num)) $head=bank_prepare_head($object); dol_fiche_head($head,'statement',$langs->trans("FinancialAccount"),0,'account'); - print '
'.$langs->trans("Ref")."
'; - $linkback = ''.$langs->trans("BackToList").''; - - // Ref - print ''; - print ''; - - // Label - print ''; - print ''; - - print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object, 'ref', $linkback, 1, 'ref'); - print '
'.$langs->trans("Label").''.$object->label.'
'; - + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); + dol_fiche_end(); + print '
'; if ($object->canBeConciliated() > 0) { diff --git a/htdocs/compta/bank/virement.php b/htdocs/compta/bank/transfer.php similarity index 92% rename from htdocs/compta/bank/virement.php rename to htdocs/compta/bank/transfer.php index abb06d17d76..9e26d532348 100644 --- a/htdocs/compta/bank/virement.php +++ b/htdocs/compta/bank/transfer.php @@ -21,7 +21,7 @@ */ /** - * \file htdocs/compta/bank/virement.php + * \file htdocs/compta/bank/transfer.php * \ingroup banque * \brief Page de saisie d'un virement */ @@ -91,11 +91,11 @@ if ($action == 'add') $result=0; // By default, electronic transfert from bank to bank - $typefrom='PRE'; + $typefrom='VIR'; $typeto='VIR'; if ($accountto->courant == Account::TYPE_CASH || $accountfrom->courant == Account::TYPE_CASH) { - // This is transfert of change + // This is transfer of change $typefrom='LIQ'; $typeto='LIQ'; } @@ -112,7 +112,7 @@ if ($action == 'add') if (! $error) { - $mesgs = $langs->trans("TransferFromToDone","id."\">".$accountfrom->label."","id."\">".$accountto->label."",$amount,$langs->transnoentities("Currency".$conf->currency)); + $mesgs = $langs->trans("TransferFromToDone","id."\">".$accountfrom->label."","id."\">".$accountto->label."",$amount,$langs->transnoentities("Currency".$conf->currency)); setEventMessages($mesgs, null, 'mesgs'); $db->commit(); } @@ -157,7 +157,7 @@ print load_fiche_titre($langs->trans("MenuBankInternalTransfer"), '', 'title_ban print $langs->trans("TransferDesc"); print "

"; -print ""; +print ''; print ''; print ''; diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index ebfd598ee0b..df02264badc 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -191,7 +191,7 @@ if ($resql) // Bank print ''; - if ($objp->bid) print ''.img_object($langs->trans("ShowAccount"),'account').' '.$objp->label.''; + if ($objp->bid) print ''.img_object($langs->trans("ShowAccount"),'account').' '.$objp->label.''; else print ' '; print ''; diff --git a/htdocs/core/lib/bank.lib.php b/htdocs/core/lib/bank.lib.php index b5371e6fa53..74078740080 100644 --- a/htdocs/core/lib/bank.lib.php +++ b/htdocs/core/lib/bank.lib.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2016 Laurent Destailleur * Copyright (C) 2012 Regis Houssin * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2016 Juanjo Menent @@ -42,8 +42,8 @@ function bank_prepare_head(Account $object) $head[$h][2] = 'bankname'; $h++; - $head[$h][0] = DOL_URL_ROOT . "/compta/bank/account.php?id=" . $object->id; - $head[$h][1] = $langs->trans("Transactions"); + $head[$h][0] = DOL_URL_ROOT . "/compta/bank/bankentries.php?id=" . $object->id; + $head[$h][1] = $langs->trans("BankTransactions"); $head[$h][2] = 'journal'; $h++; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 691ac3a8a3c..892c6c1fc2b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -926,9 +926,10 @@ function dol_get_fiche_end($notab=0) * @param int $nodbprefix Do not include DB prefix to forge table name * @param string $morehtmlleft More html code to show before ref * @param string $morehtmlright More html code to show before navigation arrows + * @param int $onlybanner Put this to 1, if the card will contains only a banner * @return void */ -function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlright='') +function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlright='', $onlybanner=0) { global $conf, $form, $user, $langs; @@ -943,7 +944,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r if ($object->element == 'user') $modulepart='userphoto'; if ($object->element == 'product') $modulepart='product'; - print '
'; + print '
'; if ($object->element == 'product') { $width=80; $cssclass='photoref'; diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 507bca321c6..63d846171a9 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -268,9 +268,9 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled', __HANDLER__, 'left', 2600__+MAX_llx_menu__, 'accountancy', 'bank', 14__+MAX_llx_menu__, '/compta/bank/index.php?leftmenu=bank&mainmenu=bank', 'MenuBankCash', 0, 'banks', '$user->rights->banque->lire', '', 0, 1, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2601__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/card.php?action=create&leftmenu=bank', 'MenuNewFinancialAccount', 1, 'banks', '$user->rights->banque->configurer', '', 0, 0, __ENTITY__); -- insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2602__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/categ.php?leftmenu=bank', 'Rubriques', 1, 'categories', '$user->rights->banque->configurer', '', 0, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2603__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/search.php?leftmenu=bank', 'ListTransactions', 1, 'banks', '$user->rights->banque->lire', '', 0, 2, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2603__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/bankentries.php?leftmenu=bank', 'ListTransactions', 1, 'banks', '$user->rights->banque->lire', '', 0, 2, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2604__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/budget.php?leftmenu=bank', 'ListTransactionsByCategory', 1, 'banks', '$user->rights->banque->lire', '', 0, 3, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2606__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/virement.php?leftmenu=bank', 'BankTransfers', 1, 'banks', '$user->rights->banque->transfer', '', 0, 5, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->banque->enabled && ($leftmenu=="bank" || $leftmenu=="checks" || $leftmenu=="withdraw")', __HANDLER__, 'left', 2606__+MAX_llx_menu__, 'accountancy', '', 2600__+MAX_llx_menu__, '/compta/bank/transfer.php?leftmenu=bank', 'BankTransfers', 1, 'banks', '$user->rights->banque->transfer', '', 0, 5, __ENTITY__); -- Account - Categories insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 2650__+MAX_llx_menu__, 'accountancy', 'cat', 14__+MAX_llx_menu__, '/categories/index.php?leftmenu=cat&type=5', 'Categories', 0, 'categories', '$user->rights->categorie->lire', '', 2, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->categorie->enabled', __HANDLER__, 'left', 2651__+MAX_llx_menu__, 'accountancy', '', 2650__+MAX_llx_menu__, '/categories/card.php?action=create&type=5', 'NewCategory', 1, 'categories', '$user->rights->categorie->creer', '', 2, 0, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index a0278f2527e..c3373cd6fb2 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1073,10 +1073,10 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/compta/bank/card.php?action=create",$langs->trans("MenuNewFinancialAccount"),1,$user->rights->banque->configurer); $newmenu->add("/compta/bank/index.php?leftmenu=bank&mainmenu=bank",$langs->trans("List"),1,$user->rights->banque->lire, '', $mainmenu, 'bank'); - $newmenu->add("/compta/bank/search.php",$langs->trans("ListTransactions"),1,$user->rights->banque->lire); + $newmenu->add("/compta/bank/bankentries.php",$langs->trans("ListTransactions"),1,$user->rights->banque->lire); $newmenu->add("/compta/bank/budget.php",$langs->trans("ListTransactionsByCategory"),1,$user->rights->banque->lire); - $newmenu->add("/compta/bank/virement.php",$langs->trans("MenuBankInternalTransfer"),1,$user->rights->banque->transfer); + $newmenu->add("/compta/bank/transfer.php",$langs->trans("MenuBankInternalTransfer"),1,$user->rights->banque->transfer); } if (! empty($conf->categorie->enabled)) { diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 3ad6451d66b..bcf000bc3aa 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -708,7 +708,7 @@ if (empty($action)) print ''.$objp->num_paiement.''; print ''; - if ($objp->bid) print ''.img_object($langs->trans("ShowAccount"),'account').' '.dol_trunc($objp->label,24).''; + if ($objp->bid) print ''.img_object($langs->trans("ShowAccount"),'account').' '.dol_trunc($objp->label,24).''; else print ' '; print ''; diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 31cbdae740a..b603bb3d2e6 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -55,16 +55,16 @@ AccountCard=Account card DeleteAccount=Delete account ConfirmDeleteAccount=Are you sure you want to delete this account? Account=Account -BankTransactionByCategories=Bank transactions by categories -BankTransactionForCategory=Bank transactions for category %s +BankTransactionByCategories=Bank entries by categories +BankTransactionForCategory=Bank entries for category %s RemoveFromRubrique=Remove link with category -RemoveFromRubriqueConfirm=Are you sure you want to remove link between the transaction and the category? -ListBankTransactions=List of bank transactions +RemoveFromRubriqueConfirm=Are you sure you want to remove link between the entry and the category? +ListBankTransactions=List of bank entries IdTransaction=Transaction ID -BankTransactions=Bank transactions -ListTransactions=List transactions -ListTransactionsByCategory=List transaction/category -TransactionsToConciliate=Transactions to reconcile +BankTransactions=Bank entries +ListTransactions=List entries +ListTransactionsByCategory=List entries/category +TransactionsToConciliate=Entries to reconcile Conciliable=Can be reconciled Conciliate=Reconcile Conciliation=Reconciliation @@ -74,16 +74,16 @@ AccountToCredit=Account to credit AccountToDebit=Account to debit DisableConciliation=Disable reconciliation feature for this account ConciliationDisabled=Reconciliation feature disabled -LinkedToAConciliatedTransaction=Linked to a conciliated transaction +LinkedToAConciliatedTransaction=Linked to a conciliated entry StatusAccountOpened=Open StatusAccountClosed=Closed AccountIdShort=Number LineRecord=Transaction -AddBankRecord=Add transaction -AddBankRecordLong=Add transaction manually +AddBankRecord=Add entry +AddBankRecordLong=Add entry manually ConciliatedBy=Reconciled by DateConciliating=Reconcile date -BankLineConciliated=Transaction reconciled +BankLineConciliated=Entry reconciled Reconciled=Reconciled NotReconciled=Not reconciled CustomerInvoicePayment=Customer payment @@ -107,13 +107,13 @@ BankChecks=Bank checks BankChecksToReceipt=Checks awaiting deposit ShowCheckReceipt=Show check deposit receipt NumberOfCheques=Nb of check -DeleteTransaction=Delete transaction -ConfirmDeleteTransaction=Are you sure you want to delete this transaction? -ThisWillAlsoDeleteBankRecord=This will also delete generated bank transactions +DeleteTransaction=Delete entry +ConfirmDeleteTransaction=Are you sure you want to delete this entry? +ThisWillAlsoDeleteBankRecord=This will also delete generated bank entry BankMovements=Movements -PlannedTransactions=Planned transactions +PlannedTransactions=Planned entries Graph=Graphics -ExportDataset_banque_1=Bank transactions and account statement +ExportDataset_banque_1=Bank entries and account statement ExportDataset_banque_2=Deposit slip TransactionOnTheOtherAccount=Transaction on the other account PaymentNumberUpdateSucceeded=Payment number updated successfully @@ -121,7 +121,7 @@ PaymentNumberUpdateFailed=Payment number could not be updated PaymentDateUpdateSucceeded=Payment date updated successfully PaymentDateUpdateFailed=Payment date could not be updated Transactions=Transactions -BankTransactionLine=Bank transaction +BankTransactionLine=Bank entry AllAccounts=All bank/cash accounts BackToAccount=Back to account ShowAllAccounts=Show for all accounts diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 00b151620fb..a572d15cbcf 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -69,7 +69,7 @@ ErrorLDAPSetupNotComplete=Dolibarr-LDAP matching is not complete. ErrorLDAPMakeManualTest=A .ldif file has been generated in directory %s. Try to load it manually from command line to have more information on errors. ErrorCantSaveADoneUserWithZeroPercentage=Can't save an action with "statut not started" if field "done by" is also filled. ErrorRefAlreadyExists=Ref used for creation already exists. -ErrorPleaseTypeBankTransactionReportName=Please type bank receipt name where transaction is reported (Format YYYYMM or YYYYMMDD) +ErrorPleaseTypeBankTransactionReportName=Please type bank receipt name where entry is reported (Format YYYYMM or YYYYMMDD) ErrorRecordHasChildren=Failed to delete record since it has some childs. ErrorRecordIsUsedCantDelete=Can't delete record. It is already used or included into other object. ErrorModuleRequireJavascript=Javascript must not be disabled to have this feature working. To enable/disable Javascript, go to menu Home->Setup->Display. @@ -131,7 +131,7 @@ ErrorWarehouseMustDiffers=Source and target warehouses must differs ErrorBadFormat=Bad format! ErrorMemberNotLinkedToAThirpartyLinkOrCreateFirst=Error, this member is not yet linked to any third party. Link member to an existing third party or create a new third party before creating subscription with invoice. ErrorThereIsSomeDeliveries=Error, there is some deliveries linked to this shipment. Deletion refused. -ErrorCantDeletePaymentReconciliated=Can't delete a payment that had generated a bank transaction that was conciliated +ErrorCantDeletePaymentReconciliated=Can't delete a payment that had generated a bank entry that was reconciled ErrorCantDeletePaymentSharedWithPayedInvoice=Can't delete a payment shared by at least one invoice with status Payed ErrorPriceExpression1=Cannot assign to constant '%s' ErrorPriceExpression2=Cannot redefine built-in function '%s' diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index 6be0af4fd1a..336b20bff16 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -175,7 +175,7 @@ MigrationReopeningContracts=Open contract closed by error MigrationReopenThisContract=Reopen contract %s MigrationReopenedContractsNumber=%s contracts modified MigrationReopeningContractsNothingToUpdate=No closed contract to open -MigrationBankTransfertsUpdate=Update links between bank transaction and a bank transfer +MigrationBankTransfertsUpdate=Update links between bank entry and a bank transfer MigrationBankTransfertsNothingToUpdate=All links are up to date MigrationShipmentOrderMatching=Sendings receipt update MigrationDeliveryOrderMatching=Delivery receipt update diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 56639e43127..08a5ff6f8a0 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -705,7 +705,7 @@ PublicUrl=Public URL AddBox=Add box SelectElementAndClickRefresh=Select an element and click Refresh PrintFile=Print File %s -ShowTransaction=Show transaction on bank account +ShowTransaction=Show entry on bank account GoIntoSetupToChangeLogo=Go into Home - Setup - Company to change logo or go into Home - Setup - Display to hide. Deny=Deny Denied=Denied diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index d249131a507..c123fed51a5 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -127,8 +127,8 @@ NoThirdPartyAssociatedToMember=No third party associated to this member MembersAndSubscriptions= Members and Subscriptions MoreActions=Complementary action on recording MoreActionsOnSubscription=Complementary action, suggested by default when recording a subscription -MoreActionBankDirect=Create a direct transaction record on account -MoreActionBankViaInvoice=Create an invoice and payment on account +MoreActionBankDirect=Create a direct entry on bank account +MoreActionBankViaInvoice=Create an invoice, and a payment on bank account MoreActionInvoiceOnly=Create an invoice with no payment LinkToGeneratedPages=Generate visit cards LinkToGeneratedPagesDesc=This screen allows you to generate PDF files with business cards for all your members or a particular member. From 14c9cd4490628444cadc1d8a09699bcafd180d34 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Oct 2016 13:57:47 +0200 Subject: [PATCH 36/53] Fix help with new menu --- htdocs/accountancy/index.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 7c99ca35d1e..c81f3849db5 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -72,29 +72,24 @@ print "
\n"; // STEPS $step++; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy")."-".$langs->transnoentitiesnoconv("Pcg_version").''); +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChartModel", $step, ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("Pcg_version").''); print "
\n"; print "
\n"; $step++; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy")."-".$langs->transnoentitiesnoconv("Chartofaccounts").''); +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescChart", $step, ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("Chartofaccounts").''); print "
\n"; print "
\n"; $step++; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescMisc", $step, ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'')."
\n"; +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescMisc", $step, ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'')."
\n"; print "
\n"; $step++; -$textlink = ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("MenuVatAccounts").''; +$textlink = ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("MenuVatAccounts").''; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescVat", $step, $textlink); print "
\n"; print "
\n"; -$step++; -$textlink=''.$langs->transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("MenuBankCash").''; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, $textlink); -print "
\n"; -print "
\n"; if (! empty($conf->tax->enabled)) { - $textlink = ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("MenuTaxAccounts").''; + $textlink = ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("MenuTaxAccounts").''; $step++; print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescContrib", $step, $textlink); print "
\n"; @@ -115,9 +110,14 @@ if (! empty($conf->don->enabled)) print "
\n"; print "
\n"; }*/ +$step++; +$textlink=''.$langs->transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("MenuBankCash").''; +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescBank", $step, $textlink); +print "
\n"; +print "
\n"; $step++; -print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy")."-".$langs->transnoentitiesnoconv("ProductsBinding").'')."
\n"; +print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescProd", $step, ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("ProductsBinding").'')."
\n"; print "
\n"; print "
\n"; From 4eeae6e054cab56f99315f44ba9d247fd929b857 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Oct 2016 14:05:04 +0200 Subject: [PATCH 37/53] Debug accounting module --- htdocs/accountancy/admin/productaccount.php | 32 ++++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 598320bfd63..495fb2a1304 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -259,10 +259,10 @@ if ($result) print ''; print '' . $langs->trans('Options') . '' . $langs->trans('Description') . ''; print "\n"; - print ' ' . $langs->trans('OptionModeProductSell') . ''; + print ' ' . $langs->trans('OptionModeProductSell') . ''; print '' . nl2br($langs->trans('OptionModeProductSellDesc')); print "\n"; - print ' ' . $langs->trans('OptionModeProductBuy') . ''; + print ' ' . $langs->trans('OptionModeProductBuy') . ''; print '' . nl2br($langs->trans('OptionModeProductBuyDesc')) . "\n"; print "\n"; @@ -284,7 +284,7 @@ if ($result) print ''; print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); + if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); /* if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { print_liste_field_titre($langs->trans("Accountancy_code_buy")); @@ -301,7 +301,7 @@ if ($result) print ''; print ''; print ''; - print ' '; + if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print ' '; print ''; $searchpitco=$form->showFilterAndCheckAddButtons(1, 'checkforselect', 1); print $searchpitco; @@ -340,23 +340,33 @@ if ($result) print ''; print ""; - print ''; + + print ''; + // Ref produit as link $product_static->ref = $obj->ref; $product_static->id = $obj->rowid; $product_static->type = $obj->type; + $product_static->label = $obj->label; + $product_static->description = $obj->description; + print ''; if ($product_static->id) print $product_static->getNomUrl(1); else print '- '; print ''; - print '' . dol_trunc($obj->label, 24) . ''; - // TODO ADJUST DESCRIPTION SIZE - // print '' . $obj->description . ''; - // TODO: we shoul set a user defined value to adjust user square / wide screen size - $trunclengh = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 64; - print '' . nl2br(dol_trunc($obj->description, $trunclengh)) . ''; + + print ''.$obj->label.''; + + if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) + { + // TODO ADJUST DESCRIPTION SIZE + // print '' . $obj->description . ''; + // TODO: we shoul set a user defined value to adjust user square / wide screen size + $trunclengh = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 64; + print '' . nl2br(dol_trunc($obj->description, $trunclengh)) . ''; + } // Accounting account buy if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { From a057cb93c9d50bf985e694c2a90ff5f8af4b3401 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Oct 2016 14:05:04 +0200 Subject: [PATCH 38/53] Debug accounting module --- htdocs/accountancy/admin/productaccount.php | 32 ++++++++++++++------- htdocs/accountancy/customer/list.php | 7 +++-- htdocs/accountancy/supplier/list.php | 16 ++++++----- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index 598320bfd63..495fb2a1304 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -259,10 +259,10 @@ if ($result) print ''; print '' . $langs->trans('Options') . '' . $langs->trans('Description') . ''; print "\n"; - print ' ' . $langs->trans('OptionModeProductSell') . ''; + print ' ' . $langs->trans('OptionModeProductSell') . ''; print '' . nl2br($langs->trans('OptionModeProductSellDesc')); print "\n"; - print ' ' . $langs->trans('OptionModeProductBuy') . ''; + print ' ' . $langs->trans('OptionModeProductBuy') . ''; print '' . nl2br($langs->trans('OptionModeProductBuyDesc')) . "\n"; print "\n"; @@ -284,7 +284,7 @@ if ($result) print ''; print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); + if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "p.description", "", $param, '', $sortfield, $sortorder); /* if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { print_liste_field_titre($langs->trans("Accountancy_code_buy")); @@ -301,7 +301,7 @@ if ($result) print ''; print ''; print ''; - print ' '; + if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) print ' '; print ''; $searchpitco=$form->showFilterAndCheckAddButtons(1, 'checkforselect', 1); print $searchpitco; @@ -340,23 +340,33 @@ if ($result) print ''; print ""; - print ''; + + print ''; + // Ref produit as link $product_static->ref = $obj->ref; $product_static->id = $obj->rowid; $product_static->type = $obj->type; + $product_static->label = $obj->label; + $product_static->description = $obj->description; + print ''; if ($product_static->id) print $product_static->getNomUrl(1); else print '- '; print ''; - print '' . dol_trunc($obj->label, 24) . ''; - // TODO ADJUST DESCRIPTION SIZE - // print '' . $obj->description . ''; - // TODO: we shoul set a user defined value to adjust user square / wide screen size - $trunclengh = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 64; - print '' . nl2br(dol_trunc($obj->description, $trunclengh)) . ''; + + print ''.$obj->label.''; + + if (! empty($conf->global->ACCOUNTANCY_SHOW_PROD_DESC)) + { + // TODO ADJUST DESCRIPTION SIZE + // print '' . $obj->description . ''; + // TODO: we shoul set a user defined value to adjust user square / wide screen size + $trunclengh = defined('ACCOUNTING_LENGTH_DESCRIPTION') ? ACCOUNTING_LENGTH_DESCRIPTION : 64; + print '' . nl2br(dol_trunc($obj->description, $trunclengh)) . ''; + } // Accounting account buy if ($accounting_product_mode == 'ACCOUNTANCY_BUY') { diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 080f79d1fce..7c718c54bfb 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -342,12 +342,15 @@ if ($result) { print price($objp->tva_tx_line); print ''; + // Accounting account suggested print ''; - if ($objp->code_sell_l == $objp->code_sell_p) { + if ($objp->code_sell_l == $objp->code_sell_p) { // Test if there is a difference between code by default and code on product if ($objp->code_sell_l > 0) print $objp->code_sell_l; else print $langs->trans("Unknown"); } else { - print $langs->trans("Buy") . ' = ' . $objp->code_sell_l . '
' . $langs->trans("Sell") . ' = ' . $objp->code_sell_p; + print $langs->trans("Default") . ' = ' . ($objp->code_sell_l > 0 ? $objp->code_sell_l : $langs->trans("Unknown")); + print '
'; + print $langs->trans("Product") . ' = ' . ($objp->code_sell_p > 0 ? $objp->code_sell_p : $langs->trans("Unknown")); } print ''; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 2f00bd67bd6..bd0dac49096 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -174,7 +174,7 @@ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_account as aa ON p.accounta $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_system as accsys ON accsys.pcg_version = aa.fk_pcg_version"; $sql .= " WHERE f.fk_statut > 0 AND l.fk_code_ventilation <= 0"; $sql .= " AND product_type <= 2"; -$sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_sell IS NULL OR p.accountancy_code_buy ='')"; +$sql .= " AND (accsys.rowid='" . $conf->global->CHARTOFACCOUNTS . "' OR p.accountancy_code_buy IS NULL OR p.accountancy_code_buy ='')"; // Add search filter like if (strlen(trim($search_invoice))) { $sql .= " AND (f.ref like '%" . $search_invoice . "%')"; @@ -352,13 +352,15 @@ if ($result) { print price($objp->tva_tx_line); print ''; + // Accounting account suggested print ''; - // if not same kind of product_type stored in product & facturedet we display both account and let user choose - if ($objp->code_buy_l == $objp->code_buy_p) { - if ($objp->code_buy_l > 0) print $objp->code_buy_l; - else print $langs->trans("Unknown"); - } else { // This can happen if user has change type of product after creation of invoice - print 'lines=' . $objp->code_buy_l . '
product=' . $objp->code_buy_p; + if ($objp->code_buy_l == $objp->code_buy_p) { // Test if there is a difference between code by default and code on product + if ($objp->code_buy_l > 0) print $objp->code_buy_l; + else print $langs->trans("Unknown"); + } else { + print $langs->trans("Default") . ' = ' . ($objp->code_buy_l > 0 ? $objp->code_buy_l : $langs->trans("Unknown")); + print '
'; + print $langs->trans("Product") . ' = ' . ($objp->code_buy_p > 0 ? $objp->code_buy_p : $langs->trans("Unknown")); } print ''; From d002648733fc3faebc45996f8eef5d4ee4941d3a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Oct 2016 14:25:56 +0200 Subject: [PATCH 39/53] Alignement --- htdocs/accountancy/customer/lines.php | 2 +- htdocs/accountancy/supplier/lines.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 022634ce22f..d33fc82f3bc 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -273,7 +273,7 @@ if ($result) { print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index e9a6c127265..94af5c82dba 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -241,7 +241,7 @@ if ($result) { print_liste_field_titre($langs->trans("Ref"), $_SERVER["PHP_SELF"], "p.ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), $_SERVER["PHP_SELF"], "p.label", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Description"), $_SERVER["PHP_SELF"], "l.description", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre($langs->trans("Amount"), $_SERVER["PHP_SELF"], "l.total_ht", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("VATRate"), $_SERVER["PHP_SELF"], "l.tva_tx", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Account"), $_SERVER["PHP_SELF"], "aa.account_number", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("LineId"), $_SERVER["PHP_SELF"], "l.rowid", "", $param, 'align="right"', $sortfield, $sortorder); @@ -254,7 +254,7 @@ if ($result) { print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; From 6965e987f0444c65d0ad48d3a5a19ecb9b665271 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Oct 2016 14:35:45 +0200 Subject: [PATCH 40/53] Keep fpdi embedded --- build/debian/control | 2 +- build/debian/copyright | 3 --- build/debian/dolibarr.postinst | 1 - build/debian/install.forced.php.install | 2 -- build/debian/rules | 1 - 5 files changed, 1 insertion(+), 8 deletions(-) diff --git a/build/debian/control b/build/debian/control index d5c4a913713..37689ef9bcc 100755 --- a/build/debian/control +++ b/build/debian/control @@ -16,7 +16,7 @@ Depends: libapache2-mod-php5 | libapache2-mod-php5filter | php5-cgi | php5-fpm | php5-mysql | php5-mysqli, php5-curl, php5-gd, php5-ldap, # Required PHP libraries php-pear, php-mail-mime, -# php-tcpdf, libfpdi-php, +# php-tcpdf, # libfpdf-tpl-php, php-fpdf, # libphp-adodb, # libnusoap-php, diff --git a/build/debian/copyright b/build/debian/copyright index e568996551e..e3397d82992 100644 --- a/build/debian/copyright +++ b/build/debian/copyright @@ -197,9 +197,6 @@ License: GPL-2+ On Debian systems, the full text of the GNU General Public License version 2 can be found in the file `/usr/share/common-licenses/GPL-2'. -Comment: - Those files are not shipped in the binary package as we - configure Dolibarr to use the library packaged in "libfpdi-php". Files: htdocs/includes/geoip/* Copyright: 2007 MaxMind LLC diff --git a/build/debian/dolibarr.postinst b/build/debian/dolibarr.postinst index 5f61ffe2083..4b946fda433 100644 --- a/build/debian/dolibarr.postinst +++ b/build/debian/dolibarr.postinst @@ -147,7 +147,6 @@ case "$1" in # File already exist. We add params not found. #echo Add new params to overwrite path to use shared libraries/fonts #grep -q -c "dolibarr_lib_ADODB_PATH" $config || [ ! -d "/usr/share/php/adodb" ] || echo "" >> $config - #grep -q -c "dolibarr_lib_FPDI_PATH" $config || [ ! -d "/usr/share/php/fpdi" ] || echo "" >> $config ##grep -q -c "dolibarr_lib_GEOIP_PATH" $config || echo "" >> $config #grep -q -c "dolibarr_lib_NUSOAP_PATH" $config || [ ! -d "/usr/share/php/nusoap" ] || echo "" >> $config #grep -q -c "dolibarr_lib_ODTPHP_PATHTOPCLZIP" $config || [ ! -d "/usr/share/php/libphp-pclzip" ] || echo "" >> $config diff --git a/build/debian/install.forced.php.install b/build/debian/install.forced.php.install index 57ab33464bc..56eef3287a6 100644 --- a/build/debian/install.forced.php.install +++ b/build/debian/install.forced.php.install @@ -30,8 +30,6 @@ $force_install_lockinstall='444'; // - not removed from package (see rm in rules file), // - declared into dependencies (see Depends in control file) //$force_dolibarr_lib_TCPDF_PATH=''; -//$force_dolibarr_lib_FPDF_PATH='/usr/share/php/fpdf'; -//$force_dolibarr_lib_FPDI_PATH='/usr/share/php/fpdi'; //$force_dolibarr_lib_ADODB_PATH='/usr/share/php/adodb'; //$force_dolibarr_lib_GEOIP_PATH=''; //$force_dolibarr_lib_NUSOAP_PATH='/usr/share/php/nusoap'; diff --git a/build/debian/rules b/build/debian/rules index bd3a9badb09..50866c03e68 100755 --- a/build/debian/rules +++ b/build/debian/rules @@ -79,7 +79,6 @@ override_dh_install: # clean from all PHP embedded libraries (we use package dependencies instead) # rm -fr htdocs/includes/adodbtime -# rm -fr htdocs/includes/fpdfi # rm -fr htdocs/includes/geoip # rm -fr htdocs/includes/nusoap # rm -fr htdocs/includes/odtphp/zip/pclzip From dd9095531aedba1f3c971bf7f384dff79dda6533 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Oct 2016 15:03:00 +0200 Subject: [PATCH 41/53] Fix for debian package --- htdocs/api/admin/index.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/htdocs/api/admin/index.php b/htdocs/api/admin/index.php index 08209b03668..d3efef9dadc 100644 --- a/htdocs/api/admin/index.php +++ b/htdocs/api/admin/index.php @@ -27,6 +27,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $langs->load("admin"); @@ -111,9 +112,15 @@ print '
'; // Explorer print ''.$langs->trans("ApiExporerIs").':
'; -$url=DOL_MAIN_URL_ROOT.'/api/index.php/explorer'; -print img_picto('','object_globe.png').' '.$url."
\n"; - +if (dol_is_dir(DOL_DOCUMENT_ROOT.'/includes/restler/framework/Luracast/Restler/explorer')) +{ + $url=DOL_MAIN_URL_ROOT.'/api/index.php/explorer'; + print img_picto('','object_globe.png').' '.$url."
\n"; +} +else +{ + print $langs->trans("NotAvailableWithThisDistribution"); +} llxFooter(); $db->close(); From 11609eab719e8924a0859aa58cccf287864eb1d3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Oct 2016 15:03:13 +0200 Subject: [PATCH 42/53] Update doc --- build/debian/README.howto | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build/debian/README.howto b/build/debian/README.howto index 6f57894a960..04aa4cfdeb7 100644 --- a/build/debian/README.howto +++ b/build/debian/README.howto @@ -291,13 +291,17 @@ If script fails with error Bad certificate, you can set "export PERL_LWP_SSL_VER * Edit orig.tar.gz file to remove - debian - htdocs/includes/ckeditor +- htdocs/includes/jszip +- htdocs/includes/jquery/plugins/datatables +- htdocs/includes/mike42 - htdocs/includes/phpexcel or htdocs/includes/phpoffice -- htdocs/includes/tcpdf or htdocs/includes/tecnickom +- htdocs/includes/restler/framework/Luracast/Restler/explorer +- htdocs/includes/tcpdf or htdocs/includes/tecnickcom And rename file into dolibarr-x.y.z+dfsgw.tgz (x.y.z = version, w start from 1 and is increased for each new git-import-orig already done) -* Staying into git root directory, run +* Staying into projet gitted root directory, run > git-import-orig -vv ../dolibarr-x.y.z+dfsgw.tgz --debian-branch=[master|jessie] --upstream-branch=[upstream|upstream-3.5.x] and enter version when requested with format x.y.z+dfsgw From abc471575aa7287313ba87e35ae1092a4bdb5f0f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Oct 2016 17:00:19 +0200 Subject: [PATCH 43/53] Fix sql error --- build/debian/README.howto | 11 ++++++++--- htdocs/install/mysql/migration/4.0.0-5.0.0.sql | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/build/debian/README.howto b/build/debian/README.howto index 04aa4cfdeb7..86b2acababb 100644 --- a/build/debian/README.howto +++ b/build/debian/README.howto @@ -154,8 +154,10 @@ tag 729538 -moreinfo ##### Testing a package into unstable env Check you have a mysql server available from another interface than "localhost". -Comment line in /etc/mysql/my.cnf if required and restart mysql -#bind-address = 127.0.0.1 +Set line in /etc/mysql/my.cnf if required and restart mysql + +[mysqld] +bind-address = * Create a chroot called "unstable-amd64-sbuild". Chroot env is stored into /srv/chroot directory. @@ -170,6 +172,8 @@ Puis pour se connecter et préparer l'environnement > schroot -c name_of_chroot > cat /etc/debian_chroot to check which debian branch we are into > vi /usr/sbin/policy-rc.d and replace return code 101 (not allowed) into 0 (ok) +> apt-get update +> apt-get upgrade > apt-get install links mysql-client To test a package @@ -185,7 +189,7 @@ To test a package If there is a problem launching apache, because port is already used, change it into your chroot install with > vi /etc/apache2/ports.conf Then restart. -Then you can call/test dolibarr with http://localhost:port/dolibarr/ (It can be also called from host). +Then you can call/test dolibarr with http://localhost:port/dolibarr/ . It can be also called FROM HOST (port must be a not used port on host). @@ -295,6 +299,7 @@ If script fails with error Bad certificate, you can set "export PERL_LWP_SSL_VER - htdocs/includes/jquery/plugins/datatables - htdocs/includes/mike42 - htdocs/includes/phpexcel or htdocs/includes/phpoffice +- htdocs/includes/swiftmailer - htdocs/includes/restler/framework/Luracast/Restler/explorer - htdocs/includes/tcpdf or htdocs/includes/tecnickcom And rename file into diff --git a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql index cf34086f066..9bd984bba1b 100644 --- a/htdocs/install/mysql/migration/4.0.0-5.0.0.sql +++ b/htdocs/install/mysql/migration/4.0.0-5.0.0.sql @@ -139,7 +139,7 @@ ALTER TABLE llx_accounting_bookkeeping ADD COLUMN tms timestamp; ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (account_number, entity, fk_pcg_version); -ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint +ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint; ALTER TABLE llx_facturedet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; @@ -149,4 +149,4 @@ ALTER TABLE llx_commande_fournisseurdet ADD COLUMN vat_src_code varchar(10) DEFA ALTER TABLE llx_propaldet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; ALTER TABLE llx_supplier_proposaldet ADD COLUMN vat_src_code varchar(10) DEFAULT '' AFTER tva_tx; - \ No newline at end of file + From 35601775e0464e6373840a397289f36051a7085a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Oct 2016 17:05:47 +0200 Subject: [PATCH 44/53] By default we open a new tab on external url link --- htdocs/compta/bank/card.php | 8 +------- htdocs/core/class/commonobject.class.php | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index a56d69138c1..a608a71bf7d 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -580,7 +580,7 @@ else $linkback = ''.$langs->trans("BackToList").''; - + $morehtmlref=''; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); @@ -649,12 +649,6 @@ else print ''.$langs->trans("BalanceMinimalDesired").''; print ''.$object->min_desired.''; - print ''.$langs->trans("Web").''; - if ($object->url) print ''; - print $object->url; - if ($object->url) print ''; - print "\n"; - // Accountancy code print ''.$langs->trans("AccountancyCode").''; print ''; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index a82a4c9e537..e2c6d67074a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -522,7 +522,7 @@ abstract class CommonObject } if (! empty($this->url)) { - $out.=dol_print_url($this->url,'',0,1); + $out.=dol_print_url($this->url,'_goout',0,1); $outdone++; } if (! empty($conf->skype->enabled)) From 8fa44e93636aae941a5ad1ed7e16661bc4310bcc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Oct 2016 17:56:12 +0200 Subject: [PATCH 45/53] Fix balance calculation --- htdocs/compta/bank/bankentries.php | 50 ++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index 4f05210f411..e3cce210963 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -99,12 +99,12 @@ if ($page == -1) { $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortorder) $sortorder='DESC'; -if (! $sortfield) $sortfield='b.dateo'; +if (! $sortorder) $sortorder='ASC'; +if (! $sortfield) $sortfield='b.datev'; $mode_balance_ok=false; //if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid')) // TODO Manage balance when account not selected -if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid') && $account > 0) +if (($sortfield == 'b.datev' || $sortfield == 'b.datev, b.dateo, b.rowid') && ($id > 0 || ! empty($ref))) { $sortfield = 'b.datev, b.dateo, b.rowid'; $mode_balance_ok = true; @@ -178,13 +178,15 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $type=""; $debit=""; $credit=""; - $account=""; $bid=""; $search_ref=""; $search_req_nb=''; $search_thirdparty=''; $search_num_releve=''; $thirdparty=''; + + $account=""; + if ($id > 0 || ! empty($ref)) $account=$object->id; } if (empty($reshook)) @@ -413,13 +415,38 @@ $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); $nbtotalofrecords = 0; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST) || ! empty($arrayfields['balance']['checked'])) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); $nbtotalofpages = ceil($nbtotalofrecords/$limit); } +if (($id > 0 || ! empty($ref)) && GETPOST("page",'int') === '') +{ + // We open a list of transaction of a dedicated account and no page was set by defaut + // We force on last page. + $page = ($nbtotalofpages - 1); + $offset = $limit * $page; + if ($page < 0) $page = 0; +} + +// Calculate balance start +$balance = 0; // For balance +if (! empty($arrayfields['balance']['checked'])) +{ + //Loop on each record + $sign = 1; + $i = 0; + while ($i < $offset) + { + $objp = $db->fetch_object($result); + $balance = price2num($balance + ($sign * $objp->amount),'MT'); + $i++; + } +} + + $sql.= $db->plimit($limit+1,$offset); dol_syslog('compta/bank/bankentries.php', LOG_DEBUG); @@ -555,6 +582,10 @@ if ($resql) print_barre_liste($langs->trans("BankTransactions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, $picto, 0, $morehtml, '', $limit); } + // We can add page now to param + if ($page != '') $param.='&page='.urlencode($page); + + $moreforfilter = ''; $moreforfilter.='
'; @@ -688,7 +719,6 @@ if ($resql) print "\n"; // Loop on each record - $total = 0; // For balance $sign = 1; $totalarray=array(); @@ -696,7 +726,7 @@ if ($resql) { $objp = $db->fetch_object($resql); - $total = price2num($total + ($sign * $objp->amount),'MT'); + $balance = price2num($balance + ($sign * $objp->amount),'MT'); if (empty($cachebankaccount[$objp->bankid])) { @@ -957,13 +987,13 @@ if ($resql) { if ($mode_balance_ok) { - if ($total >= 0) + if ($balance >= 0) { - print ' '.price($total).''; + print ' '.price($balance).''; } else { - print ' '.price($total).''; + print ' '.price($balance).''; } } else From 9ab8f767774362078f78a60565db8654a073ac3e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Oct 2016 18:40:21 +0200 Subject: [PATCH 46/53] Fix insert supplier invoice line --- htdocs/fourn/class/fournisseur.facture.class.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index ea91765b94a..3d61698d5dd 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1277,7 +1277,13 @@ class FactureFournisseur extends CommonInvoice if (empty($txtva)) $txtva=0; if (empty($txlocaltax1)) $txlocaltax1=0; if (empty($txlocaltax2)) $txlocaltax2=0; - + // Clean vat code + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\((.*)\)/', '', $txtva); + } + $remise_percent=price2num($remise_percent); $qty=price2num($qty); $pu=price2num($pu); @@ -1312,6 +1318,7 @@ class FactureFournisseur extends CommonInvoice $this->line->desc=$desc; $this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative $this->line->tva_tx=$txtva; + $this->line->vat_src_code=$vat_src_code; $this->line->localtax1_tx=$txlocaltax1; $this->line->localtax2_tx=$txlocaltax2; $this->line->fk_product=$fk_product; @@ -2571,7 +2578,7 @@ class SupplierInvoiceLine extends CommonObjectLine // Insertion dans base de la ligne $sql = 'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element; $sql.= ' (fk_facture_fourn, fk_parent_line, label, description, qty,'; - $sql.= ' tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; + $sql.= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; $sql.= ' fk_product, product_type, remise_percent, pu_ht, pu_ttc,'; $sql.= ' date_start, date_end, fk_code_ventilation, rang, special_code,'; $sql.= ' info_bits, total_ht, tva, total_ttc, total_localtax1, total_localtax2, fk_unit'; @@ -2582,6 +2589,7 @@ class SupplierInvoiceLine extends CommonObjectLine $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; $sql.= " '".$this->db->escape($this->desc)."',"; $sql.= " ".price2num($this->qty).","; + $sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->vat_src_code."'").","; $sql.= " ".price2num($this->tva_tx).","; $sql.= " ".price2num($this->localtax1_tx).","; $sql.= " ".price2num($this->localtax2_tx).","; From b8c9e952810092572127fb2a7a4b129cc9caec1f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Oct 2016 19:14:31 +0200 Subject: [PATCH 47/53] Fix translation --- htdocs/langs/en_US/multicurrency.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/multicurrency.lang b/htdocs/langs/en_US/multicurrency.lang index fc90fe3d78d..805356a2e46 100644 --- a/htdocs/langs/en_US/multicurrency.lang +++ b/htdocs/langs/en_US/multicurrency.lang @@ -4,7 +4,7 @@ ErrorAddRateFail=Error in added rate ErrorAddCurrencyFail=Error in added currency ErrorDeleteCurrencyFail=Error delete fail multicurrency_syncronize_error=Error in synchronization -multicurrency_useOriginTx=When an object is created from another, keep the original rate of source object (otherwise use the new rate entered) +multicurrency_useOriginTx=When an object is created from another, keep the original rate of source object (otherwise use the new known rate) CurrencyLayerAccount=CurrencyLayer API CurrencyLayerAccount_help_to_synchronize=You sould create an account on their website to use this functionnality
Get your API key
If you use a free account you can't change the currency source (USD by default)
But if your main currency isn't USD you can use the alternate currency source to force you main currency

You are limited at 1000 synchronizations per month multicurrency_appId=API key From 534202ad45342227fab0e74558b82dcee681e3a0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Oct 2016 23:13:03 +0200 Subject: [PATCH 48/53] NEW Can make reconcile directly from bank entry list --- htdocs/compta/bank/bankentries.php | 414 +++++++++++++++------ htdocs/compta/bank/class/account.class.php | 14 +- htdocs/compta/bank/rappro.php | 2 +- htdocs/compta/bank/releve.php | 19 +- htdocs/langs/en_US/banks.lang | 1 + htdocs/langs/en_US/errors.lang | 3 +- htdocs/langs/en_US/main.lang | 2 +- 7 files changed, 330 insertions(+), 125 deletions(-) diff --git a/htdocs/compta/bank/bankentries.php b/htdocs/compta/bank/bankentries.php index e3cce210963..b07e919849a 100644 --- a/htdocs/compta/bank/bankentries.php +++ b/htdocs/compta/bank/bankentries.php @@ -84,9 +84,13 @@ $account=GETPOST("account",'int'); $bid=GETPOST("bid","int"); $search_dt_start = dol_mktime(0, 0, 0, GETPOST('search_start_dtmonth', 'int'), GETPOST('search_start_dtday', 'int'), GETPOST('search_start_dtyear', 'int')); $search_dt_end = dol_mktime(0, 0, 0, GETPOST('search_end_dtmonth', 'int'), GETPOST('search_end_dtday', 'int'), GETPOST('search_end_dtyear', 'int')); +$search_dv_start = dol_mktime(0, 0, 0, GETPOST('search_start_dvmonth', 'int'), GETPOST('search_start_dvday', 'int'), GETPOST('search_start_dvyear', 'int')); +$search_dv_end = dol_mktime(0, 0, 0, GETPOST('search_end_dvmonth', 'int'), GETPOST('search_end_dvday', 'int'), GETPOST('search_end_dvyear', 'int')); $search_thirdparty=GETPOST("thirdparty",'alpha'); $search_req_nb=GETPOST("req_nb",'alpha'); $search_num_releve=GETPOST("search_num_releve",'alpha'); +$num_releve=GETPOST("num_releve"); +$cat=GETPOST("cat"); $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; @@ -159,7 +163,7 @@ if (is_array($extrafields->attribute_label) && count($extrafields->attribute_lab /* * Actions - */ + */ if (GETPOST('cancel')) { $action='list'; $massaction=''; } if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } @@ -174,7 +178,9 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP { $search_dt_start=''; $search_dt_end=''; - $description=""; + $search_dv_start=''; + $search_dv_end=''; + $description=""; $type=""; $debit=""; $credit=""; @@ -199,6 +205,57 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } +// Conciliation +if (GETPOST('confirm_reconcile') && $user->rights->banque->consolidate) +{ + $error=0; + + // Definition, nettoyage parametres + $num_releve=trim(GETPOST("num_releve")); + + if ($num_releve) + { + $bankline=new AccountLine($db); + if (isset($_POST['rowid']) && is_array($_POST['rowid'])) + { + foreach($_POST['rowid'] as $row) + { + if ($row > 0) + { + $result=$bankline->fetch($row); + $bankline->num_releve=$num_releve; //$_POST["num_releve"]; + $result=$bankline->update_conciliation($user, GETPOST("cat")); + if ($result < 0) + { + setEventMessages($bankline->error, $bankline->errors, 'errors'); + $error++; + break; + } + } + } + } + else + { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("NoRecordSelected"), null, 'errors'); + } + } + else + { + $error++; + $langs->load("errors"); + setEventMessages($langs->trans("ErrorPleaseTypeBankTransactionReportName"), null, 'errors'); + } + + if (! $error) + { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); // To avoid to submit twice and allow back + exit; + } +} + + $dateop=-1; if (GETPOST('save') && $id && ! $cancel && $user->rights->banque->modifier) @@ -290,6 +347,36 @@ $banklinestatic=new AccountLine($db); $now = dol_now(); +// Must be before button action +$param=''; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +if ($id > 0) $param.='&id='.urlencode($id); +if (!empty($ref)) $param.='&ref='.urlencode($ref); +if (!empty($search_ref)) $param.='&search_ref='.urlencode($search_ref); +if (!empty($description)) $param.='&description='.urlencode($description); +if (!empty($type)) $param.='&type='.urlencode($type); +if (!empty($debit)) $param.='&debit='.$debit; +if (!empty($credit)) $param.='&credit='.$credit; +if (!empty($account)) $param.='&account='.$account; +if (!empty($search_num_releve)) $param.='&search_num_releve='.urlencode($search_num_releve); +if (!empty($bid)) $param.='&bid='.$bid; +if (dol_strlen($search_dt_start) > 0) $param .= '&search_start_dtmonth=' . GETPOST('search_start_dtmonth', 'int') . '&search_start_dtday=' . GETPOST('search_start_dtday', 'int') . '&search_start_dtyear=' . GETPOST('search_start_dtyear', 'int'); +if (dol_strlen($search_dt_end) > 0) $param .= '&search_end_dtmonth=' . GETPOST('search_end_dtmonth', 'int') . '&search_end_dtday=' . GETPOST('search_end_dtday', 'int') . '&search_end_dtyear=' . GETPOST('search_end_dtyear', 'int'); +if (dol_strlen($search_dv_start) > 0) $param .= '&search_start_dvmonth=' . GETPOST('search_start_dvmonth', 'int') . '&search_start_dvday=' . GETPOST('search_start_dvday', 'int') . '&search_start_dvyear=' . GETPOST('search_start_dvyear', 'int'); +if (dol_strlen($search_dv_end) > 0) $param .= '&search_end_dvmonth=' . GETPOST('search_end_dvmonth', 'int') . '&search_end_dvday=' . GETPOST('search_end_dvday', 'int') . '&search_end_dvyear=' . GETPOST('search_end_dvyear', 'int'); +if ($search_req_nb) $param.='&req_nb='.urlencode($search_req_nb); +if (GETPOST("thirdparty")) $param.='&thirdparty='.urlencode(GETPOST("thirdparty")); +if ($optioncss != '') $param.='&optioncss='.$optioncss; +// Add $param from extra fields +foreach ($search_array_options as $key => $val) +{ + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); +} + + if ($id > 0 || ! empty($ref)) { @@ -306,7 +393,8 @@ if ($id > 0 || ! empty($ref)) $options[$bankcategory->id] = $bankcategory->label; } - // Onglets + // Bank card + $head=bank_prepare_head($object); dol_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0,'account'); @@ -321,9 +409,8 @@ if ($id > 0 || ! empty($ref)) /* * Buttons actions */ - - //if ($action != 'delete') - //{ + if ($action != 'addline' && $action != 'reconcile') + { print '
'; if ($action != 'addline') @@ -331,7 +418,7 @@ if ($id > 0 || ! empty($ref)) if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) { if ($user->rights->banque->modifier) { - print 'id.'&page='.$page.($vline?'&vline='.$vline:'').'">'.$langs->trans("AddBankRecord").''; + print ''.$langs->trans("AddBankRecord").''; } else { print ''.$langs->trans("AddBankRecord").''; } @@ -339,19 +426,17 @@ if ($id > 0 || ! empty($ref)) print ''.$langs->trans("AddBankRecord").''; } } - if ($object->canBeConciliated() > 0) { // If not cash account and can be reconciliate if ($user->rights->banque->consolidate) { - print ''.$langs->trans("Conciliate").''; + print ''.$langs->trans("Conciliate").''; } else { print ''.$langs->trans("Conciliate").''; } } print '
'; - //} - + } } else { @@ -378,17 +463,20 @@ $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid"; $sql.= " WHERE b.fk_account = ba.rowid"; $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; -if ($search_ref) $sql.=natural_search("b.rowid", $search_ref); if ($account > 0) $sql.=" AND b.fk_account = ".$account; +// Search period criteria +if (dol_strlen($search_dt_start)>0) $sql .= " AND b.dateo >= '" . $db->idate($search_dt_start) . "'"; +if (dol_strlen($search_dt_end)>0) $sql .= " AND b.dateo <= '" . $db->idate($search_dt_end) . "'"; +// Search period criteria +if (dol_strlen($search_dv_start)>0) $sql .= " AND b.datev >= '" . $db->idate($search_dv_start) . "'"; +if (dol_strlen($search_dv_end)>0) $sql .= " AND b.datev <= '" . $db->idate($search_dv_end) . "'"; +if ($search_ref) $sql.=natural_search("b.rowid", $search_ref); if ($search_req_nb) $sql.= natural_search("b.num_chq", $search_req_nb); if ($search_num_releve) $sql.= natural_search("b.num_releve", $search_num_releve); if ($search_thirdparty) $sql.= natural_search("s.nom", $search_thirdparty); if ($description) $sql.= natural_search("b.label", $description); // Warning some text are just translation keys, not translated strings if ($bid) $sql.= " AND b.rowid=l.lineid AND l.fk_categ=".$bid; if (! empty($type)) $sql.= " AND b.fk_type = '".$db->escape($type)."' "; -// Search period criteria -if (dol_strlen($search_dt_start)>0) $sql .= " AND b.dateo >= '" . $db->idate($search_dt_start) . "'"; -if (dol_strlen($search_dt_end)>0) $sql .= " AND b.dateo <= '" . $db->idate($search_dt_end) . "'"; // Search criteria amount $debit = price2num(str_replace('-','',$debit)); $credit = price2num(str_replace('-','',$credit)); @@ -415,7 +503,8 @@ $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); $nbtotalofrecords = 0; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST) || ! empty($arrayfields['balance']['checked'])) +$nbtotalofpages = 0; +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); @@ -431,21 +520,12 @@ if (($id > 0 || ! empty($ref)) && GETPOST("page",'int') === '') if ($page < 0) $page = 0; } -// Calculate balance start -$balance = 0; // For balance -if (! empty($arrayfields['balance']['checked'])) -{ - //Loop on each record - $sign = 1; - $i = 0; - while ($i < $offset) - { - $objp = $db->fetch_object($result); - $balance = price2num($balance + ($sign * $objp->amount),'MT'); - $i++; - } -} - +if (! empty($search_ref)) $mode_balance_ok=false; +if (! empty($req_nb)) $mode_balance_ok=false; +if (! empty($type)) $mode_balance_ok=false; +if (! empty($debit)) $mode_balance_ok=false; +if (! empty($credit)) $mode_balance_ok=false; +if (! empty($thirdparty)) $mode_balance_ok=false; $sql.= $db->plimit($limit+1,$offset); @@ -458,32 +538,6 @@ if ($resql) $arrayofselected=is_array($toselect)?$toselect:array(); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($id > 0) $param.='&id='.urlencode($id); - if (!empty($ref)) $param.='&ref='.urlencode($ref); - if (!empty($search_ref)) $param.='&search_ref='.urlencode($search_ref); - if (!empty($description)) $param.='&description='.urlencode($description); - if (!empty($type)) $param.='&type='.urlencode($type); - if (!empty($debit)) $param.='&debit='.$debit; - if (!empty($credit)) $param.='&credit='.$credit; - if (!empty($account)) $param.='&account='.$account; - if (!empty($search_num_releve)) $param.='&search_num_releve='.urlencode($search_num_releve); - if (!empty($bid)) $param.='&bid='.$bid; - if (dol_strlen($search_dt_start) > 0) $param .= '&search_start_dtmonth=' . GETPOST('search_start_dtmonth', 'int') . '&search_start_dtday=' . GETPOST('search_start_dtday', 'int') . '&search_start_dtyear=' . GETPOST('search_start_dtyear', 'int'); - if (dol_strlen($search_dt_end) > 0) $param .= '&search_end_dtmonth=' . GETPOST('search_end_dtmonth', 'int') . '&search_end_dtday=' . GETPOST('search_end_dtday', 'int') . '&search_end_dtyear=' . GETPOST('search_end_dtyear', 'int'); - if ($search_req_nb) $param.='&req_nb='.urlencode($search_req_nb); - if (GETPOST("thirdparty")) $param.='&thirdparty='.urlencode(GETPOST("thirdparty")); - if ($optioncss != '') $param.='&optioncss='.$optioncss; - // Add $param from extra fields - foreach ($search_array_options as $key => $val) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); - } - // List of mass actions available $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), @@ -507,7 +561,7 @@ if ($resql) if ($optioncss != '') print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -515,7 +569,62 @@ if ($resql) print ''; if (! empty($_REQUEST['bid'])) print ''; - + // Form to reconcile + if ($user->rights->banque->consolidate && $action == 'reconcile') + { +// print ''; +// print ''; +// print '
'; + print '
'; + print ''.$langs->trans("InputReceiptNumber").': '; + print ''; // The only default value is value we just entered + print '
'; + if ($options) { + print $langs->trans("EventualyAddCategory").': '; + print Form::selectarray('cat', $options, GETPOST('cat'), 1); + } + print '
'.$langs->trans("ThenCheckLinesAndConciliate").' '; + print ''; + print ' '.$langs->trans("or").' '; + print ''; + + // Show last bank statements + $nbmax=15; // We accept to show last 15 receipts (so we can have more than one year) + $liste=""; + $sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank"; + $sql.= " WHERE fk_account=".$id." AND num_releve IS NOT NULL"; + $sql.= $db->order("num_releve","DESC"); + $sql.= $db->plimit($nbmax+1); + print '

'; + print $langs->trans("LastAccountStatements").' : '; + $resqlr=$db->query($sql); + if ($resqlr) + { + $numr=$db->num_rows($resqlr); + $i=0; + $last_ok=0; + while (($i < $numr) && ($i < $nbmax)) + { + $objr = $db->fetch_object($resqlr); + if (! $last_ok) { + $last_releve = $objr->num_releve; + $last_ok=1; + } + $i++; + $liste=''.$objr->num_releve.'   '.$liste; + } + if ($numr >= $nbmax) $liste="...   ".$liste; + print $liste; + if ($numr <= 0) print ''.$langs->trans("None").''; + } + else + { + dol_print_error($db); + } + print '

'; +// print '
'; + } + // Form to add a transaction with no invoice if ($user->rights->banque->modifier && $action == 'addline') { @@ -533,9 +642,9 @@ if ($resql) print ' '; print ''; - print ''; + print ''; print ''; - $form->select_date($dateop,'op',0,0,0,'transaction'); + $form->select_date(empty($dateop)?-1:$dateop,'op',0,0,0,'transaction'); print ''; print ''; $form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == Account::TYPE_CASH ? 'LIQ' : '')),'operation','1,2',2,1); @@ -548,8 +657,8 @@ if ($resql) print Form::selectarray('cat1', $options, GETPOST('cat1'), 1); } print ''; - print ''; - print ''; + print ''; + print ''; print ''; print '
'; print ''; @@ -559,6 +668,26 @@ if ($resql) } + /// ajax adjust value date + print ' + + + '; $i = 0; @@ -589,11 +718,19 @@ if ($resql) $moreforfilter = ''; $moreforfilter.='
'; - $moreforfilter .= $langs->trans('Period') . ' ('.$langs->trans('DateOperationShort').') : '; - $moreforfilter .= '
'.$langs->trans('DateStart') . ' '; + $moreforfilter .= $langs->trans('DateOperationShort').' : '; + $moreforfilter .= '
'.$langs->trans('From') . ' '; $moreforfilter .= $form->select_date($search_dt_start, 'search_start_dt', 0, 0, 1, "search_form", 1, 0, 1).'
'; $moreforfilter .= ' - '; - $moreforfilter .= '
'.$langs->trans('DateEnd') . ' ' . $form->select_date($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 1).'
'; + $moreforfilter .= '
'.$langs->trans('to') . ' ' . $form->select_date($search_dt_end, 'search_end_dt', 0, 0, 1, "search_form", 1, 0, 1).'
'; + $moreforfilter .= '
'; + + $moreforfilter.='
'; + $moreforfilter .= $langs->trans('DateValueShort').' : '; + $moreforfilter .= '
'.$langs->trans('From') . ' '; + $moreforfilter .= $form->select_date($search_dv_start, 'search_start_dv', 0, 0, 1, "search_form", 1, 0, 1).'
'; + $moreforfilter .= ' - '; + $moreforfilter .= '
'.$langs->trans('to') . ' ' . $form->select_date($search_dv_end, 'search_end_dv', 0, 0, 1, "search_form", 1, 0, 1).'
'; $moreforfilter .= '
'; $parameters=array(); @@ -643,6 +780,7 @@ if ($resql) $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + print_liste_field_titre('', $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); print "\n"; @@ -650,7 +788,7 @@ if ($resql) if (! empty($arrayfields['b.rowid']['checked'])) { print ''; - print ''; + print ''; print ''; } if (! empty($arrayfields['description']['checked'])) @@ -712,13 +850,18 @@ if ($resql) // Numero statement print ''; } - print ''; + print ''; + print ''; + print ''; $searchpitco=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1); print $searchpitco; print ''; print "\n"; - // Loop on each record + $balance = 0; // For balance + $balancecalculated = false; + + // Loop on each record $sign = 1; $totalarray=array(); @@ -726,6 +869,35 @@ if ($resql) { $objp = $db->fetch_object($resql); + // If we are in a situation where we need/can show balance, we calculate the start of balance + if (! $balancecalculated && ! empty($arrayfields['balance']['checked']) && $mode_balance_ok) + { + //Loop on each record + $sign = 1; + $i = 0; + $sqlforbalance='SELECT SUM(b.amount) as balance'; + $sqlforbalance.= " FROM "; + $sqlforbalance.= " ".MAIN_DB_PREFIX."bank_account as ba,"; + $sqlforbalance.= " ".MAIN_DB_PREFIX."bank as b"; + $sqlforbalance.= " WHERE b.fk_account = ba.rowid"; + $sqlforbalance.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; + $sqlforbalance.= " AND b.fk_account = ".$account; + $sqlforbalance.= " AND b.datev < '" . $db->idate($db->jdate($objp->dv)) . "'"; + $resqlforbalance = $db->query($sqlforbalance); + //print $sqlforbalance; + if ($resqlforbalance) + { + $objforbalance = $db->fetch_object($resqlforbalance); + if ($objforbalance) + { + $balance = $objforbalance->balance; + } + } + else dol_print_error($db); + + $balancecalculated=true; + } + $balance = price2num($balance + ($sign * $objp->amount),'MT'); if (empty($cachebankaccount[$objp->bankid])) @@ -899,8 +1071,17 @@ if ($resql) // Date value if (! empty($arrayfields['b.datev']['checked'])) { - print ''.dol_print_date($db->jdate($objp->dv),"day")."\n"; - if (! $i) $totalarray['nbfield']++; + print ''; + print ''.dol_print_date($db->jdate($objp->dv),"day").""; + print ' '; + print ''; + print ''; + print img_edit_remove() . " "; + print ''; + print img_edit_add() .""; + print ''; + print "\n"; + if (! $i) $totalarray['nbfield']++; } // Payment type @@ -1006,52 +1187,61 @@ if ($resql) { print ''; // Transaction reconciliated or edit link - if ($objp->rappro && $bankaccount->canBeConciliated() > 0) // If line not conciliated and account can be conciliated + if ($bankaccount->canBeConciliated() > 0) { - print ''; - print img_edit(); - print ''; - print "  "; - print ''.$objp->num_releve.''; - } - else - { - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print ''; - print img_edit(); - print ''; - } - else - { - print ''; - print img_view(); - print ''; - } - if ($bankaccount->canBeConciliated() > 0 && empty($objp->rappro)) - { - if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay)) - { - print ' '.img_warning($langs->trans("Late")); - } - } - print ' '; - if ($user->rights->banque->modifier) - { - print 'rowid.'&id='.$object->id.'&page='.$page.'">'; - print img_delete(); - print ''; - } - } - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; + if ($objp->rappro) // If line not conciliated and account can be conciliated + { + print ''.$objp->num_releve.''; + } + else if ($action == 'reconcile') + { + print 'rowid])?' checked':'').'>'; + } } print ''; if (! $i) $totalarray['nbfield']++; } + + // Action edit/delete + print ''; + // Transaction reconciliated or edit link + if ($objp->rappro && $bankaccount->canBeConciliated() > 0) // If line not conciliated and account can be conciliated + { + print ''; + print img_edit(); + print ''; + } + else + { + if ($user->rights->banque->modifier || $user->rights->banque->consolidate) + { + print ''; + print img_edit(); + print ''; + } + else + { + print ''; + print img_view(); + print ''; + } + if ($bankaccount->canBeConciliated() > 0 && empty($objp->rappro)) + { + if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay)) + { + print ' '.img_warning($langs->trans("ReconciliationLate")); + } + } + print ' '; + if ($user->rights->banque->modifier) + { + print 'rowid.'&id='.$object->id.'&page='.$page.'">'; + print img_delete(); + print ''; + } + } + print ''; + if (! $i) $totalarray['nbfield']++; // Action column print ''; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index ac5430c74be..f786158ccbe 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -1535,7 +1535,7 @@ class AccountLine extends CommonObject var $fk_user_rappro; var $fk_type; var $rappro; // Is it conciliated - var $num_releve; // If conciliated, what is bank receipt + var $num_releve; // If conciliated, what is bank statement var $num_chq; // Num of cheque var $bank_chq; // Bank of cheque var $fk_bordereau; // Id of cheque receipt @@ -1805,8 +1805,20 @@ class AccountLine extends CommonObject */ function update_conciliation(User $user, $cat) { + global $conf; + $this->db->begin(); + // Check statement field + if (! empty($conf->global->BANK_STATEMENT_REGEX_RULE)) + { + if (! preg_match('/'.$conf->global->BANK_STATEMENT_REGEX_RULE.'/', $this->num_releve)) + { + $this->errors[]=$langs->trans("ErrorBankStatementNameMustFollowRegex", $conf->global->BANK_STATEMENT_REGEX_RULE); + return -1; + } + } + $sql = "UPDATE ".MAIN_DB_PREFIX."bank SET"; $sql.= " rappro = 1"; $sql.= ", num_releve = '".$this->num_releve."'"; diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php index e3ef2ea5a57..f266c0a7723 100644 --- a/htdocs/compta/bank/rappro.php +++ b/htdocs/compta/bank/rappro.php @@ -184,7 +184,7 @@ if ($resql) print load_fiche_titre($langs->trans("Reconciliation").': '.$acct->label.'', '', 'title_bank.png'); print '
'; - // Show last bank receipts + // Show last bank statements $nbmax=15; // We accept to show last 15 receipts (so we can have more than one year) $liste=""; $sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank"; diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 06c213485f8..0acaecb875e 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -21,7 +21,7 @@ /** * \file htdocs/compta/bank/releve.php * \ingroup banque - * \brief Page to show a bank receipt report + * \brief Page to show a bank statement report */ require('../../main.inc.php'); @@ -275,7 +275,7 @@ else $mesprevnext.=''; @@ -286,7 +286,7 @@ else print ''; print ""; - print ''; + print '
'; print ''; print ''; print ''; @@ -330,12 +330,12 @@ else $result = $db->query($sql); if ($result) { - $var=True; + $var=False; $numrows = $db->num_rows($result); $i = 0; // Ligne Solde debut releve - print ""; + print ""; print "\n"; while ($i < $numrows) @@ -351,13 +351,14 @@ else // Date de valeur print '\n"; - + print ''; + // Type and num if ($objp->fk_type == 'SOLD') { $type_label=' '; diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index b603bb3d2e6..d4fe1334d20 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -68,6 +68,7 @@ TransactionsToConciliate=Entries to reconcile Conciliable=Can be reconciled Conciliate=Reconcile Conciliation=Reconciliation +ReconciliationLate=Reconciliation late IncludeClosedAccount=Include closed accounts OnlyOpenedAccount=Only open accounts AccountToCredit=Account to credit diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index a572d15cbcf..1ccb3d5e458 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -69,7 +69,7 @@ ErrorLDAPSetupNotComplete=Dolibarr-LDAP matching is not complete. ErrorLDAPMakeManualTest=A .ldif file has been generated in directory %s. Try to load it manually from command line to have more information on errors. ErrorCantSaveADoneUserWithZeroPercentage=Can't save an action with "statut not started" if field "done by" is also filled. ErrorRefAlreadyExists=Ref used for creation already exists. -ErrorPleaseTypeBankTransactionReportName=Please type bank receipt name where entry is reported (Format YYYYMM or YYYYMMDD) +ErrorPleaseTypeBankTransactionReportName=Please type bank statement name where entry is reported (Format YYYYMM or YYYYMMDD) ErrorRecordHasChildren=Failed to delete record since it has some childs. ErrorRecordIsUsedCantDelete=Can't delete record. It is already used or included into other object. ErrorModuleRequireJavascript=Javascript must not be disabled to have this feature working. To enable/disable Javascript, go to menu Home->Setup->Display. @@ -177,6 +177,7 @@ ErrorStockIsNotEnoughToAddProductOnProposal=Stock is not enougth for product %s ErrorFailedToLoadLoginFileForMode=Failed to get the login file for mode '%s'. ErrorModuleNotFound=File of module was not found. ErrorFieldAccountNotDefinedForBankLine=Value for Accounting account not defined for source bank line %s +ErrorBankStatementNameMustFollowRegex=Error, bank statement name must follow the following syntax rule %s # Warnings WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user. diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 08a5ff6f8a0..2c8d19a50c3 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -721,7 +721,7 @@ DeleteLine=Delete line ConfirmDeleteLine=Are you sure you want to delete this line? NoPDFAvailableForDocGenAmongChecked=No PDF were available for the document generation among checked records TooManyRecordForMassAction=Too many record selected for mass action. The action is restricted to a list of %s records. -NoRecordSelected=No record were selected +NoRecordSelected=No record selected MassFilesArea=Area for files built by mass actions ShowTempMassFilesArea=Show area of files built by mass actions RelatedObjects=Related Objects From 939afa9569329613b5fc8cedceae990a3fae0ebd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Oct 2016 23:23:59 +0200 Subject: [PATCH 49/53] NEW Can make reconcile directly from bank entry list --- htdocs/compta/bank/account.php | 978 --------------------- htdocs/compta/bank/rappro.php | 468 ---------- htdocs/compta/bank/releve.php | 2 +- htdocs/core/menus/standard/auguria.lib.php | 2 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- 5 files changed, 3 insertions(+), 1449 deletions(-) delete mode 100644 htdocs/compta/bank/account.php delete mode 100644 htdocs/compta/bank/rappro.php diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php deleted file mode 100644 index 26265316ea6..00000000000 --- a/htdocs/compta/bank/account.php +++ /dev/null @@ -1,978 +0,0 @@ - - * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2004 Christophe Combelles - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2010-2011 Juanjo Menent - * Copyright (C) 2012-2016 Marcos García - * Copyright (C) 2011-2015 Alexandre Spangaro - * Copyright (C) 2015 Florian Henry - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/compta/bank/account.php - * \ingroup banque - * \brief List of details of bank transactions for an account - */ - -require('../../main.inc.php'); -require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php'; -require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; -require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; -require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; - -$langs->load("banks"); -$langs->load("categories"); -$langs->load("bills"); -$langs->load("companies"); -$langs->load("salaries"); -$langs->load("loan"); -$langs->load("donations"); -$langs->load("trips"); -$langs->load("members"); - -$id = (GETPOST('id','int') ? GETPOST('id','int') : GETPOST('account','int')); -$ref = GETPOST('ref','alpha'); -$action=GETPOST('action','alpha'); -$confirm=GETPOST('confirm','alpha'); - -// Security check -$fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref :'')); -$fieldtype = (! empty($ref) ? 'ref' :'rowid'); -if ($user->societe_id) $socid=$user->societe_id; -$result=restrictedArea($user,'banque',$fieldvalue,'bank_account&bank_account','','',$fieldtype); - -$paiementtype=GETPOST('paiementtype','alpha',3); -$req_nb=GETPOST("req_nb",'',3); -$thirdparty=GETPOST("thirdparty",'',3); -$req_desc=GETPOST("req_desc",'',3); -$req_debit=GETPOST("req_debit",'',3); -$req_credit=GETPOST("req_credit",'',3); - -$req_stdtmonth=GETPOST('req_stdtmonth', 'int'); -$req_stdtday=GETPOST('req_stdtday', 'int'); -$req_stdtyear=GETPOST('req_stdtyear', 'int'); -$req_stdt = dol_mktime(0, 0, 0, $req_stdtmonth, $req_stdtday, $req_stdtyear); -$req_enddtmonth=GETPOST('req_enddtmonth', 'int'); -$req_enddtday=GETPOST('req_enddtday', 'int'); -$req_enddtyear=GETPOST('req_enddtyear', 'int'); -$req_enddt = dol_mktime(23, 59, 59, $req_enddtmonth, $req_enddtday, $req_enddtyear); - -$search_reconciled = GETPOST('search_reconciled'); - -$vline=GETPOST("vline"); -$page=GETPOST('page','int'); -$negpage=GETPOST('negpage','int'); -if ($negpage) -{ - $page=GETPOST("nbpage") - $negpage; - if ($page > GETPOST("nbpage")) $page = GETPOST("nbpage"); -} - -$sortfield = "b.datev, b.datec, b.rowid"; - -$object = new Account($db); - - - -/* - * Action - */ - -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers -{ - $paiementtype=""; - $req_nb=""; - $thirdparty=""; - $req_desc=""; - $req_debit=""; - $req_credit=""; - $req_stdtmonth=""; - $req_stdtday=""; - $req_stdtyear=""; - $req_stdt = ""; - $req_enddtmonth=""; - $req_enddtday=""; - $req_enddtyear=""; - $req_enddt = ""; - $search_reconciled = ''; -} - -$dateop=-1; - -if ($action == 'add' && $id && ! isset($_POST["cancel"]) && $user->rights->banque->modifier) -{ - $error = 0; - - if (price2num($_POST["credit"]) > 0) - { - $amount = price2num($_POST["credit"]); - } - else - { - $amount = - price2num($_POST["debit"]); - } - - $dateop = dol_mktime(12,0,0,$_POST["opmonth"],$_POST["opday"],$_POST["opyear"]); - $operation=$_POST["operation"]; - $num_chq=$_POST["num_chq"]; - $label=$_POST["label"]; - $cat1=$_POST["cat1"]; - - if (! $dateop) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Date")), null, 'errors'); - } - if (! $operation) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Type")), null, 'errors'); - } - if (! $amount) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->trans("Amount")), null, 'errors'); - } - - if (! $error) - { - $object->fetch($id); - $insertid = $object->addline($dateop, $operation, $label, $amount, $num_chq, $cat1, $user); - if ($insertid > 0) - { - setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id."&action=addline"); - exit; - } - else - { - setEventMessages($object->error, $object->errors, 'errors'); - } - } - else - { - $action='addline'; - } -} -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->banque->modifier) -{ - $accline=new AccountLine($db); - $result=$accline->fetch(GETPOST("rowid")); - $result=$accline->delete(); -} - - -/* - * View - */ -$title = $langs->trans("FinancialAccount").' - '.$langs->trans("Transactions"); -$helpurl = ""; -llxHeader('',$title,$helpurl); - -$societestatic=new Societe($db); -$userstatic=new User($db); -$chargestatic=new ChargeSociales($db); -$loanstatic=new Loan($db); -$memberstatic=new Adherent($db); -$paymentstatic=new Paiement($db); -$paymentsupplierstatic=new PaiementFourn($db); -$paymentvatstatic=new TVA($db); -$paymentsalstatic=new PaymentSalary($db); -$donstatic=new Don($db); -$expensereportstatic=new ExpenseReport($db); -$bankstatic=new Account($db); -$banklinestatic=new AccountLine($db); - -$form = new Form($db); - -if ($id > 0 || ! empty($ref)) -{ - if ($vline) - { - $viewline = $vline; - } - else - { - $viewline = empty($conf->global->MAIN_SIZE_LISTE_LIMIT)?20:$conf->global->MAIN_SIZE_LISTE_LIMIT; - } - - $result=$object->fetch($id, $ref); - - // Load bank groups - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; - $bankcateg = new BankCateg($db); - $options = array(); - - foreach ($bankcateg->fetchAll() as $bankcategory) { - $options[$bankcategory->id] = $bankcategory->label; - } - - // Definition de sql_rech et param - $param=''; - $sql_rech=''; - $mode_search = 0; - if ($req_nb) - { - $sql_rech.= " AND b.num_chq LIKE '%".$db->escape($req_nb)."%'"; - $param.='&req_nb='.urlencode($req_nb); - $mode_search = 1; - } - if ($req_desc) - { - $sql_rech.= " AND b.label LIKE '%".$db->escape($req_desc)."%'"; - $param.='&req_desc='.urlencode($req_desc); - $mode_search = 1; - } - if ($req_debit != '') - { - $sql_rech.=" AND b.amount = -".price2num($req_debit); - $param.='&req_debit='.urlencode($req_debit); - $mode_search = 1; - } - if ($req_credit != '') - { - $sql_rech.=" AND b.amount = ".price2num($req_credit); - $param.='&req_credit='.urlencode($req_credit); - $mode_search = 1; - } - if ($thirdparty) - { - $sql_rech.=" AND s.nom LIKE '%".$db->escape($thirdparty)."%'"; - $param.='&thirdparty='.urlencode($thirdparty); - $mode_search = 1; - } - if ($paiementtype) - { - $sql_rech.=" AND b.fk_type = '".$db->escape($paiementtype)."'"; - $param.='&paiementtype='.urlencode($paiementtype); - $mode_search = 1; - } - - if ($req_stdt && $req_enddt) - { - $sql_rech.=" AND (b.datev BETWEEN '".$db->escape($db->idate($req_stdt))."' AND '".$db->escape($db->idate($req_enddt))."')"; - $param.='&req_stdtmonth='.$req_stdtmonth.'&req_stdtyear='.$req_stdtyear.'&req_stdtday='.$req_stdtday; - $param.='&req_enddtmonth='.$req_enddtmonth.'&req_enddtday='.$req_enddtday.'&req_enddtyear='.$req_enddtyear; - $mode_search = 1; - } - elseif ($req_stdt) - { - $sql_rech.=" AND b.datev >= '".$db->escape($db->idate($req_stdt))."'"; - $param.='&req_stdtmonth='.$req_stdtmonth.'&req_stdtyear='.$req_stdtyear.'&req_stdtday='.$req_stdtday; - $mode_search = 1; - } - elseif ($req_enddt) - { - $sql_rech.=" AND b.datev <= '".$db->escape($db->idate($req_enddt))."'"; - $param.='&req_enddtmonth='.$req_enddtmonth.'&req_enddtday='.$req_enddtday.'&req_enddtyear='.$req_enddtyear; - $mode_search = 1; - } - - if ($search_reconciled == 'reconciled') $sql_rech.=" AND num_releve IS NOT NULL"; - if ($search_reconciled == 'notreconciled') $sql_rech.=" AND num_releve IS NULL"; - - $sql = "SELECT count(*) as total"; - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= ", ".MAIN_DB_PREFIX."bank as b"; - if ($mode_search) - { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu ON bu.fk_bank = b.rowid AND bu.type='company'"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu.url_id = s.rowid"; - } - $sql.= " WHERE b.fk_account = ".$object->id; - $sql.= " AND b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; - $sql.= $sql_rech; - - dol_syslog("account.php count transactions -", LOG_DEBUG); - $result=$db->query($sql); - if ($result) - { - $obj = $db->fetch_object($result); - $nbline = $obj->total; - $total_lines = $nbline; - - $db->free($result); - } - else - { - dol_print_error($db); - } - - //Total pages - $totalPages = ceil($total_lines/$viewline); - - if ($totalPages == 0) { - $page = 0; - } else { - - if ($page > 0) { - $limitsql = ($totalPages - $page) * $viewline; - if ($limitsql < $viewline) { - $limitsql = $viewline; - } - $nbline = $limitsql; - } else { - $page = 0; - $limitsql = $nbline; - } - } - - //print $limitsql.'-'.$page.'-'.$viewline; - - // Onglets - $head=bank_prepare_head($object); - dol_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0,'account'); - - $linkback = ''.$langs->trans("BackToList").''; - - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); - - dol_fiche_end(); - - - - /* - * Buttons actions - */ - - if ($action != 'delete') - { - print '
'; - - if ($action != 'addline') - { - if (empty($conf->global->BANK_DISABLE_DIRECT_INPUT)) - { - if ($user->rights->banque->modifier) { - print 'id.'&page='.$page.($vline?'&vline='.$vline:'').'">'.$langs->trans("AddBankRecord").''; - } else { - print ''.$langs->trans("AddBankRecord").''; - } - } else { - print ''.$langs->trans("AddBankRecord").''; - } - } - - if ($object->canBeConciliated() > 0) { - // If not cash account and can be reconciliate - if ($user->rights->banque->consolidate) { - print ''.$langs->trans("Conciliate").''; - } else { - print ''.$langs->trans("Conciliate").''; - } - } - - print '
'; - } - - print '
'; - - /** - * Search form - */ - $param.='&account='.$object->id.'&vline='.$vline; - - // Confirmation delete - if ($action == 'delete') - { - $text=$langs->trans('ConfirmDeleteTransaction'); - print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid"),$langs->trans('DeleteTransaction'),$text,'confirm_delete'); - - } - - // Define transaction list navigation string - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - $navig ='
'; - if ($limitsql > $viewline) $navig.=''.img_previous().''; - $navig.= ' "; // ' Page '; - $navig.=''; - $navig.='/'.$totalPages.' '; - if ($total_lines > $limitsql ) - { - $navig.= ''.img_next().''; - } - $navig.='
'; - - - //var_dump($navig); - - if ($action != 'addline' && $action != 'delete') - { - print '
'.$navig.'
'; - } - - // Form to add a transaction with no invoice - if ($user->rights->banque->modifier && $action == 'addline') - { - print load_fiche_titre($langs->trans("AddBankRecordLong"),'',''); - - print '
'.$langs->trans("DateOperationShort").''.$langs->trans("DateValueShort").'
id."\"> 
id."\"> ".$langs->trans("InitialBankBalance")." :".price($total)." 
'; - print ''; - print img_previous().' '; print dol_print_date($db->jdate($objp->dv),"day") .' '; + print ''; + print img_edit_remove() . " "; print ''; - print img_next().''; + print img_edit_add() .""; print "
'; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
'.$langs->trans("Date").' '.$langs->trans("Type").''.$langs->trans("Numero").''.$langs->trans("Description").''.$langs->trans("Debit").''.$langs->trans("Credit").' 
'; - $form->select_date($dateop,'op',0,0,0,'transaction'); - print ''; - $form->select_types_paiements((GETPOST('operation')?GETPOST('operation'):($object->courant == Account::TYPE_CASH ? 'LIQ' : '')),'operation','1,2',2,1); - print ''; - print ''; - print ''; - if ($options) { - print '
'.$langs->trans("Rubrique").': '; - print Form::selectarray('cat1', $options, GETPOST('cat1'), 1); - } - print '
'; - print '
'; - print ''; - print '
'; - print ''; - print '
'; - } - - - /* - * Show list of bank transactions - */ - - print '
'; - print ''; - print ''; - print ''; - - print ''; - - // Ligne de titre tableau des ecritures - print ''; - print ''; - print_liste_field_titre($langs->trans("Value"), '', 'b.datev, b.datec, b.rowid','',$param,'',$sortfield,$sortorder); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - $period_filter .= $langs->trans('From').' '.$form->select_date($req_stdt,'req_stdt',0,0,1,null,1,0,1); - $period_filter .= ' '; - $period_filter .= $langs->trans('to').' '.$form->select_date($req_enddt,'req_enddt',0,0,1,null,1,0,1); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - - /* - * Another solution - * create temporary table solde type=heap select amount from llx_bank limit 100 ; - * select sum(amount) from solde ; - */ - - $sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,"; - $sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_bordereau,"; - $sql.= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel"; - if ($mode_search) - { - $sql.= ", s.rowid as socid, s.nom as thirdparty"; - } - /* - if ($mode_search && ! empty($conf->adherent->enabled)) - { - - } - if ($mode_search && ! empty($conf->tax->enabled)) - { - - } - */ - $sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba"; - $sql.= ", ".MAIN_DB_PREFIX."bank as b"; - if ($mode_search) - { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu1.url_id = s.rowid"; - } - if ($mode_search && ! empty($conf->tax->enabled)) - { - // VAT - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='payment_vat'"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."tva as t ON bu2.url_id = t.rowid"; - - // Salary payment - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment_salary'"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."payment_salary as sal ON bu3.url_id = sal.rowid"; - } - if ($mode_search && ! empty($conf->adherent->enabled)) - { - // TODO Mettre jointure sur adherent pour recherche sur un adherent - //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='company'"; - //$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON bu3.url_id = s.rowid"; - } - $sql.= " WHERE b.fk_account=".$object->id; - $sql.= " AND b.fk_account = ba.rowid"; - $sql.= " AND ba.entity IN (".getEntity('bank_account', 1).")"; - $sql.= $sql_rech; - $sql.= $db->order($sortfield, "ASC"); // We add date of creation to have correct order when everything is done the same day - $sql.= $db->plimit($limitsql, 0); - - dol_syslog("account.php get transactions -", LOG_DEBUG); - $result = $db->query($sql); - if ($result) - { - $now=dol_now(); - $nows=dol_print_date($now,'%Y%m%d'); - - //$form->load_cache_types_paiements(); - //$form->cache_types_paiements - - $var=true; - - $num = $db->num_rows($result); - $i = 0; $total = 0; $sep = -1; $total_deb=0; $total_cred=0; - - while ($i < $num) - { - $objp = $db->fetch_object($result); - $total = price2num($total + $objp->amount,'MT'); - if ($i >= ($viewline * (($totalPages-$page)-1))) - { - $var=!$var; - - // Is it a transaction in future ? - $dos=dol_print_date($db->jdate($objp->do),'%Y%m%d'); - //print "dos=".$dos." nows=".$nows; - if ($dos < $nows) $sep=0; // 0 means there was at least one line before current date - if ($dos > $nows && ! $sep) // We have found a line in future and we already found on line before current date - { - $sep = 1 ; - print ''; - print ''; - print ""; - print ''; - } - - print ''; - - print '\n"; - - print '\n"; - - // Payment type - print '\n"; - - // Num - print '\n"; - - // Description - print ''; - - // Add third party column - print ''; - - // Amount - if ($objp->amount < 0) - { - print ''."\n"; - $total_deb +=$objp->amount; - } - else - { - print ''."\n"; - $total_cred +=$objp->amount; - } - - // Balance - if (! $mode_search) - { - if ($total >= 0) - { - print ''; - } - else - { - print ''; - } - } - else - { - print ''; - } - - // Transaction reconciliated or edit link - if ($objp->rappro && $object->canBeConciliated() > 0) // If line not conciliated and account can be conciliated - { - print '"; - } - else - { - print ''; - } - - print ''; - - print ""; - } - - $i++; - } - - // Show total - if ($page == 0 && ! $mode_search) - { - //Real account situation - print ''; - print ''; - print ''; - print ''; - print ''; - } else { - // Only total according row displays - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - } - $db->free($result); - } - else - { - dol_print_error($db); - } - - print "
'.$langs->trans("Date").''.$langs->trans("Type").''.$langs->trans("Numero").''.$langs->trans("Description").''.$langs->trans("ThirdParty").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("BankBalance").''; - if ($object->canBeConciliated() > 0) { - print $langs->trans("AccountStatementShort"); - } else { - print ' '; - } - print '
'.$period_filter.''; - //$filtertype=array('TIP'=>'TIP','PRE'=>'PRE',...) - $filtertype=''; - $form->select_types_paiements($paiementtype,'paiementtype',$filtertype,2,1,1,8); - print ' '; - $array=array('reconciled'=>$langs->trans("Reconciled"), 'notreconciled'=>$langs->trans("NotReconciled")); - print $form->selectarray('search_reconciled', $array, $search_reconciled, 1); - print ''; - $searchpitco=$form->showFilterAndCheckAddButtons(0); - print $searchpitco; - print '
'; - print $langs->trans("CurrentBalance"); - print ''.price($total - $objp->amount).' 
'.dol_print_date($db->jdate($objp->do),"day")."'.dol_print_date($db->jdate($objp->dv),"day"); - print "'; - $label=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$objp->fk_type; - - if ($objp->fk_type == 'SOLD') $label=' '; - if ($objp->fk_type == 'CHQ' && $objp->fk_bordereau > 0) - { - dol_include_once('/compta/paiement/cheque/class/remisecheque.class.php'); - $bordereaustatic = new RemiseCheque($db); - $bordereaustatic->id = $objp->fk_bordereau; - $label .= ' '.$bordereaustatic->getNomUrl(2); - } - print $label; - print "'.($objp->num_chq?$objp->num_chq:"")."'; - // Show generic description - if (preg_match('/^\((.*)\)$/i',$objp->label,$reg)) - { - // Generic description because between (). We show it after translating. - print $langs->trans($reg[1]); - } - else - { - print dol_trunc($objp->label,60); - } - - // Add links after description - $links = $object->get_url($objp->rowid); - foreach($links as $key=>$val) - { - if ($links[$key]['type']=='payment') - { - $paymentstatic->id=$links[$key]['url_id']; - $paymentstatic->ref=$links[$key]['url_id']; - print ' '.$paymentstatic->getNomUrl(2); - } - elseif ($links[$key]['type']=='payment_supplier') - { - $paymentsupplierstatic->id=$links[$key]['url_id']; - $paymentsupplierstatic->ref=$links[$key]['url_id']; - print ' '.$paymentsupplierstatic->getNomUrl(2); - } - elseif ($links[$key]['type']=='payment_sc') - { - print ''; - print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; - //print $langs->trans("SocialContributionPayment"); - print ''; - } - elseif ($links[$key]['type']=='payment_vat') - { - $paymentvatstatic->id=$links[$key]['url_id']; - $paymentvatstatic->ref=$links[$key]['url_id']; - print ' '.$paymentvatstatic->getNomUrl(2); - } - elseif ($links[$key]['type']=='payment_salary') - { - $paymentsalstatic->id=$links[$key]['url_id']; - $paymentsalstatic->ref=$links[$key]['url_id']; - print ' '.$paymentsalstatic->getNomUrl(2); - } - elseif ($links[$key]['type']=='payment_loan') - { - print ''; - print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; - print ''; - } - elseif ($links[$key]['type']=='payment_donation') - { - print ''; - print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; - print ''; - } - elseif ($links[$key]['type']=='payment_expensereport') - { - print ''; - print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; - print ''; - } - elseif ($links[$key]['type']=='banktransfert') - { - // Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail. - if ($objp->amount > 0) - { - $banklinestatic->fetch($links[$key]['url_id']); - $bankstatic->id=$banklinestatic->fk_account; - $bankstatic->label=$banklinestatic->bank_account_ref; - print ' ('.$langs->trans("TransferFrom").' '; - print $bankstatic->getNomUrl(1,'transactions'); - print ' '.$langs->trans("toward").' '; - $bankstatic->id=$objp->bankid; - $bankstatic->label=$objp->bankref; - print $bankstatic->getNomUrl(1,''); - print ')'; - } - else - { - $bankstatic->id=$objp->bankid; - $bankstatic->label=$objp->bankref; - print ' ('.$langs->trans("TransferFrom").' '; - print $bankstatic->getNomUrl(1,''); - print ' '.$langs->trans("toward").' '; - $banklinestatic->fetch($links[$key]['url_id']); - $bankstatic->id=$banklinestatic->fk_account; - $bankstatic->label=$banklinestatic->bank_account_ref; - print $bankstatic->getNomUrl(1,'transactions'); - print ')'; - } - //var_dump($links); - } - elseif ($links[$key]['type']=='company') - { - - } - elseif ($links[$key]['type']=='user') - { - - } - elseif ($links[$key]['type']=='member') - { - - } - elseif ($links[$key]['type']=='sc') - { - - } - else - { - // Show link with label $links[$key]['label'] - if (! empty($objp->label) && ! empty($links[$key]['label'])) print ' - '; - print ''; - if (preg_match('/^\((.*)\)$/i',$links[$key]['label'],$reg)) - { - // Label generique car entre parentheses. On l'affiche en le traduisant - if ($reg[1]=='paiement') $reg[1]='Payment'; - print ' '.$langs->trans($reg[1]); - } - else - { - print ' '.$links[$key]['label']; - } - print ''; - } - } - print ''; - foreach($links as $key=>$val) - { - if ($links[$key]['type']=='company') - { - $societestatic->id=$links[$key]['url_id']; - $societestatic->name=$links[$key]['label']; - print $societestatic->getNomUrl(1,'',16); - } - else if ($links[$key]['type']=='user') - { - $userstatic->id=$links[$key]['url_id']; - $userstatic->lastname=$links[$key]['label']; - print $userstatic->getNomUrl(1,''); - } - else if ($links[$key]['type']=='sc') - { - // sc=old value - $chargestatic->id=$links[$key]['url_id']; - if (preg_match('/^\((.*)\)$/i',$links[$key]['label'],$reg)) - { - if ($reg[1]=='socialcontribution') $reg[1]='SocialContribution'; - $chargestatic->lib=$langs->trans($reg[1]); - } - else - { - $chargestatic->lib=$links[$key]['label']; - } - $chargestatic->ref=$chargestatic->lib; - print $chargestatic->getNomUrl(1,16); - } - else if ($links[$key]['type']=='loan') - { - $loanstatic->id=$links[$key]['url_id']; - if (preg_match('/^\((.*)\)$/i',$links[$key]['label'],$reg)) - { - if ($reg[1]=='loan') $reg[1]='Loan'; - $loanstatic->label=$langs->trans($reg[1]); - } - else - { - $loanstatic->label=$links[$key]['label']; - } - $loanstatic->ref=$links[$key]['url_id']; - print $loanstatic->getLinkUrl(1,16); - } - else if ($links[$key]['type']=='member') - { - $memberstatic->id=$links[$key]['url_id']; - $memberstatic->ref=$links[$key]['label']; - print $memberstatic->getNomUrl(1,16,'card'); - } - } - print ''.price($objp->amount * -1).'   '.price($objp->amount).' '.price($total).' '.price($total).'-'; - print ''; - print img_edit(); - print ''; - print "  "; - print ''.$objp->num_releve.''; - print "'; - if ($user->rights->banque->modifier || $user->rights->banque->consolidate) - { - print ''; - print img_edit(); - print ''; - } - else - { - print ''; - print img_view(); - print ''; - } - if ($object->canBeConciliated() > 0 && empty($objp->rappro)) - { - if ($db->jdate($objp->dv) < ($now - $conf->bank->rappro->warning_delay)) - { - print ' '.img_warning($langs->trans("Late")); - } - } - print ' '; - if ($user->rights->banque->modifier) - { - print 'rowid.'&id='.$object->id.'&page='.$page.'">'; - print img_delete(); - print ''; - } - print '
'; - if ($sep > 0) print ' '; // If we had at least one line in future - else print $langs->trans("CurrentBalance"); - print ' '.$object->currency_code.''.price($total).'  
'; - if ($sep > 0) print ' '; // If we had at least one line in future - else print $langs->trans("Total"); - print ' '.$object->currency_code.''.price($total_deb*-1).''.price($total_cred).''.price($total_cred-($total_deb*-1)).'  
"; - - print "
\n"; - - print '
'; -} -else -{ - print $langs->trans("ErrorBankAccountNotFound"); -} - -llxFooter(); - -$db->close(); diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php deleted file mode 100644 index f266c0a7723..00000000000 --- a/htdocs/compta/bank/rappro.php +++ /dev/null @@ -1,468 +0,0 @@ - - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2010 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2016 Marcos García - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/compta/bank/rappro.php - * \ingroup banque - * \brief Page to reconciliate bank transactions - */ - -require('../../main.inc.php'); -require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; -require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/paiement/cheque/class/remisecheque.class.php'; - -$langs->load("banks"); -$langs->load("categories"); -$langs->load("bills"); - -if (! $user->rights->banque->consolidate) accessforbidden(); - -$action=GETPOST('action', 'alpha'); -$id=GETPOST('account', 'int'); - -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="dateo"; - - -/* - * Actions - */ - -// Conciliation -if ($action == 'rappro' && $user->rights->banque->consolidate) -{ - $error=0; - - // Definition, nettoyage parametres - $num_releve=trim($_POST["num_releve"]); - - if ($num_releve) - { - $bankline=new AccountLine($db); - - if (isset($_POST['rowid']) && is_array($_POST['rowid'])) - { - foreach($_POST['rowid'] as $row) - { - if($row > 0) - { - $result=$bankline->fetch($row); - $bankline->num_releve=$num_releve; //$_POST["num_releve"]; - $result=$bankline->update_conciliation($user,$_POST["cat"]); - if ($result < 0) - { - setEventMessages($bankline->error, $bankline->errors, 'errors'); - $error++; - break; - } - } - } - } - } - else - { - $error++; - $langs->load("errors"); - setEventMessages($langs->trans("ErrorPleaseTypeBankTransactionReportName"), null, 'errors'); - } - - if (! $error) - { - header('Location: '.DOL_URL_ROOT.'/compta/bank/rappro.php?account='.$id); // To avoid to submit twice and allow back - exit; - } -} - -/* - * Action suppression ecriture - */ -if ($action == 'del') -{ - $bankline=new AccountLine($db); - - if ($bankline->fetch($_GET["rowid"]) > 0) { - $result = $bankline->delete($user); - if ($result < 0) { - dol_print_error($db, $bankline->error); - } - } else { - setEventMessage($langs->trans('ErrorRecordNotFound'), 'errors'); - } -} - -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; -$bankcateg = new BankCateg($db); -$options = array(); - -foreach ($bankcateg->fetchAll() as $bankcategory) { - $options[$bankcategory->id] = $bankcategory->label; -} - -/* - * View - */ - -$form=new Form($db); - -llxHeader(); - -$societestatic=new Societe($db); -$chargestatic=new ChargeSociales($db); -$memberstatic=new Adherent($db); -$paymentstatic=new Paiement($db); -$paymentsupplierstatic=new PaiementFourn($db); -$paymentvatstatic=new TVA($db); -$remisestatic = new RemiseCheque($db); - -$acct = new Account($db); -$acct->fetch($id); - -$now=dol_now(); - -$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type as type"; -$sql.= ", b.fk_bordereau"; -$sql.= ", bc.ref"; -$sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bordereau_cheque as bc ON bc.rowid=b.fk_bordereau'; -$sql.= " WHERE rappro=0 AND fk_account=".$acct->id; -$sql.= " ORDER BY $sortfield $sortorder"; -$sql.= " LIMIT 1000"; // Limit to avoid page overload - -/// ajax adjust value date -print ' - - -'; - -$resql = $db->query($sql); -if ($resql) -{ - $var=True; - $num = $db->num_rows($resql); - - print load_fiche_titre($langs->trans("Reconciliation").': '.$acct->label.'', '', 'title_bank.png'); - print '
'; - - // Show last bank statements - $nbmax=15; // We accept to show last 15 receipts (so we can have more than one year) - $liste=""; - $sql = "SELECT DISTINCT num_releve FROM ".MAIN_DB_PREFIX."bank"; - $sql.= " WHERE fk_account=".$acct->id." AND num_releve IS NOT NULL"; - $sql.= $db->order("num_releve","DESC"); - $sql.= $db->plimit($nbmax+1); - print $langs->trans("LastAccountStatements").' : '; - $resqlr=$db->query($sql); - if ($resqlr) - { - $numr=$db->num_rows($resqlr); - $i=0; - $last_ok=0; - while (($i < $numr) && ($i < $nbmax)) - { - $objr = $db->fetch_object($resqlr); - if (! $last_ok) { - $last_releve = $objr->num_releve; - $last_ok=1; - } - $i++; - $liste=''.$objr->num_releve.'   '.$liste; - } - if ($numr >= $nbmax) $liste="...   ".$liste; - print $liste; - if ($numr > 0) print '

'; - else print ''.$langs->trans("None").'

'; - } - else - { - dol_print_error($db); - } - - - print '
'; - print ''; - print ''; - print ''; - - print ''.$langs->trans("InputReceiptNumber").': '; - print ''; // The only default value is value we just entered - print '
'; - if ($options) { - print $langs->trans("EventualyAddCategory").': '; - print Form::selectarray('cat', $options, GETPOST('cat'), 1); - print '
'; - } - print '
'.$langs->trans("ThenCheckLinesAndConciliate").' "'.$langs->trans("Conciliate").'"
'; - - print '
'; - - $paramlist=''; - $paramlist.="&account=".$acct->id; - - print ''; - print ''."\n"; - print_liste_field_titre($langs->trans("DateOperationShort"),$_SERVER["PHP_SELF"],"b.dateo","",$paramlist,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateValueShort"),$_SERVER["PHP_SELF"],"b.datev","",$paramlist,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Type"),$_SERVER["PHP_SELF"],"b.fk_type","",$paramlist,'align="left"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Description"),$_SERVER["PHP_SELF"],"b.label","",$paramlist,'align="left"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Debit"),$_SERVER["PHP_SELF"],"b.amount","",$paramlist,' width="60 align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Credit"),$_SERVER["PHP_SELF"],"b.amount","",$paramlist,' width="60 align="right"',$sortfield,$sortorder); - print_liste_field_titre('',$_SERVER["PHP_SELF"],"","",$paramlist,' width="80 align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ToConciliate"),$_SERVER["PHP_SELF"],"","",$paramlist,' align="center" width="80" ',$sortfield,$sortorder); - print "\n"; - - - $i = 0; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - - $var=!$var; - print "\n"; -// print ''; -// print ''; - -// print "rowid."\">"; - - // Date op - print ''; - - // Date value - if (! $objp->rappro && ($user->rights->banque->modifier || $user->rights->banque->consolidate)) - { - print ''; - } - else - { - print ''; - } - - // Type + Number - $label=($langs->trans("PaymentType".$objp->type)!="PaymentType".$objp->type)?$langs->trans("PaymentType".$objp->type):$objp->type; // $objp->type is a code - if ($label=='SOLD') $label=''; - $link=''; - if ($objp->fk_bordereau>0) { - $remisestatic->id = $objp->fk_bordereau; - $remisestatic->ref = $objp->number; - $link = ' '.$remisestatic->getNomUrl(1); - } - print ''; - - // Description - print ''; - - if ($objp->amount < 0) - { - print "\n"; - } - else - { - print "\n"; - } - - if ($objp->rappro) - { - // If line already reconciliated, we show receipt - print ""; - } - else - { - // If not already reconciliated - if ($user->rights->banque->modifier) - { - print '"; - } - else - { - print ""; - } - } - - - // Show checkbox for conciliation - if ($db->jdate($objp->do) <= $now) - { - - print '"; - } - else - { - print ''; - } - - print "\n"; - - $i++; - } - $db->free($resql); - - print "
'.dol_print_date($db->jdate($objp->do),"day").''."\n"; - print ''.dol_print_date($db->jdate($objp->dv),"day").""; - print ' '; - print ''; - print ''; - print img_edit_remove() . " "; - print ''; - print img_edit_add() .""; - print ''; - print ''; - print dol_print_date($db->jdate($objp->dv),"day"); - print ''.$label.($objp->num_chq?' '.$objp->num_chq:'').$link.''; - $reg=array(); - preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parentheses on tente recherche de traduction - if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]); - else print $objp->label; - print ''; - - /* - * Ajout les liens (societe, company...) - */ - $newline=1; - $links = $acct->get_url($objp->rowid); - foreach($links as $key=>$val) - { - if ($newline == 0) print ' - '; - else if ($newline == 1) print '
'; - if ($links[$key]['type']=='payment') { - $paymentstatic->id=$links[$key]['url_id']; - print ' '.$paymentstatic->getNomUrl(2); - $newline=0; - } - elseif ($links[$key]['type']=='payment_supplier') { - $paymentsupplierstatic->id=$links[$key]['url_id']; - $paymentsupplierstatic->ref=$links[$key]['label']; - print ' '.$paymentsupplierstatic->getNomUrl(1); - $newline=0; - } - elseif ($links[$key]['type']=='company') { - $societestatic->id=$links[$key]['url_id']; - $societestatic->name=$links[$key]['label']; - print $societestatic->getNomUrl(1,'',24); - $newline=0; - } - else if ($links[$key]['type']=='sc') { - $chargestatic->id=$links[$key]['url_id']; - $chargestatic->ref=$links[$key]['url_id']; - $chargestatic->lib=$langs->trans("SocialContribution"); - print ' '.$chargestatic->getNomUrl(1); - } - else if ($links[$key]['type']=='payment_sc') - { - // We don't show anything because there is 1 payment for 1 social contribution and we already show link to social contribution - /*print ''; - print img_object($langs->trans('ShowPayment'),'payment').' '; - print $langs->trans("SocialContributionPayment"); - print '';*/ - $newline=2; - } - else if ($links[$key]['type']=='payment_vat') - { - $paymentvatstatic->id=$links[$key]['url_id']; - $paymentvatstatic->ref=$links[$key]['url_id']; - $paymentvatstatic->ref=$langs->trans("VATPayment"); - print ' '.$paymentvatstatic->getNomUrl(1); - } - else if ($links[$key]['type']=='banktransfert') { - print ''; - print img_object($langs->trans('ShowTransaction'),'payment').' '; - print $langs->trans("TransactionOnTheOtherAccount"); - print ''; - } - else if ($links[$key]['type']=='member') { - print ''; - print img_object($langs->trans('ShowMember'),'user').' '; - print $links[$key]['label']; - print ''; - } - else { - //print ' - '; - print ''; - if (preg_match('/^\((.*)\)$/i',$links[$key]['label'],$reg)) - { - // Label generique car entre parentheses. On l'affiche en le traduisant - if ($reg[1]=='paiement') $reg[1]='Payment'; - print $langs->trans($reg[1]); - } - else - { - print $links[$key]['label']; - } - print ''; - $newline=0; - } - } - print '
".price($objp->amount * -1)."  ".price($objp->amount)."num_releve&account=$acct->id\">$objp->num_releve'; - - print ''; - print img_edit(); - print '  '; - - $now=dol_now(); - if ($db->jdate($objp->do) <= $now) { - print ''; - print img_delete(); - print ''; - } - else { - print " "; // We prevents the deletion because reconciliation can not be achieved until the date has elapsed and that writing appears well on the account. - } - print " '; - print 'rowid])?' checked':'').'>'; - print "'; - print $langs->trans("FutureTransaction"); - print '

\n"; - - print '

'; - - print "
\n"; - -} -else -{ - dol_print_error($db); -} - - -llxFooter(); - -$db->close(); diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 0acaecb875e..8c694a949a3 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -138,7 +138,7 @@ if (empty($num)) if ($object->canBeConciliated() > 0) { // If not cash account and can be reconciliate if ($user->rights->banque->consolidate) { - print ''.$langs->trans("Conciliate").''; + print ''.$langs->trans("Conciliate").''; } else { print ''.$langs->trans("Conciliate").''; } diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php index 4f93f9757ae..1b0ff489eba 100644 --- a/htdocs/core/menus/standard/auguria.lib.php +++ b/htdocs/core/menus/standard/auguria.lib.php @@ -307,7 +307,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM $newmenu->add('/compta/bank/card.php?id='.$objp->rowid,$objp->label,1,$user->rights->banque->lire); if ($objp->rappro && $objp->courant != Account::TYPE_CASH && empty($objp->clos)) // If not cash account and not closed and can be reconciliate { - $newmenu->add('/compta/bank/rappro.php?account='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate); + $newmenu->add('/compta/bank/bankentries.php?id='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate); } $i++; } diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index c3373cd6fb2..782eb95d3d1 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -1396,7 +1396,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add('/compta/bank/card.php?id='.$objp->rowid,$objp->label,1,$user->rights->banque->lire); if ($objp->rappro && $objp->courant != Account::TYPE_CASH && empty($objp->clos)) // If not cash account and not closed and can be reconciliate { - $newmenu->add('/compta/bank/rappro.php?account='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate); + $newmenu->add('/compta/bank/bankentries.php?id='.$objp->rowid,$langs->trans("Conciliate"),2,$user->rights->banque->consolidate); } $i++; } From edd8b8ce92994fea7d21e80efaeddff299fb1e57 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Oct 2016 23:44:03 +0200 Subject: [PATCH 50/53] FIX Sort list of file on ecm module --- htdocs/ecm/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 96c9e81d852..928b151618a 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -468,8 +468,8 @@ else print ''; print ''; } -$url=((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&module='.$module:'').($section?'&section='.$section:''))); -print ''; +$relativeurl=((! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS))?'#':($_SERVER["PHP_SELF"].'?action=refreshmanual'.($module?'&module='.$module:'').($section?'&section='.$section:''))); +print ''; print ''; print ''; From ab3cdfa16df0ebcc892343050287a129cac41b29 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Oct 2016 00:33:39 +0200 Subject: [PATCH 51/53] Clean code --- htdocs/accountancy/index.php | 10 +++++----- htdocs/core/menus/standard/eldy.lib.php | 22 +++++++++++++++++++--- htdocs/langs/en_US/accountancy.lang | 7 ++++--- htdocs/langs/en_US/companies.lang | 2 +- htdocs/langs/en_US/loan.lang | 12 ++++++------ 5 files changed, 35 insertions(+), 18 deletions(-) diff --git a/htdocs/accountancy/index.php b/htdocs/accountancy/index.php index 99e3e54596b..17b610b095e 100644 --- a/htdocs/accountancy/index.php +++ b/htdocs/accountancy/index.php @@ -103,19 +103,19 @@ if (! empty($conf->tax->enabled)) // htdocs/admin/salaries.php print "
\n"; print "
\n"; -} -if (! empty($conf->loan->enabled)) +}*/ +if (! empty($conf->loan->enabled)) // TODO Move this in the default account page because this is only one accounting account per purpose, not several. { $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescLoan", $step, ''.$langs->transnoentitiesnoconv("Home").'-'.$langs->transnoentitiesnoconv("Setup").'-'.$langs->transnoentitiesnoconv("Modules")."-".$langs->transnoentitiesnoconv("Loans").''); - // htdocs/admin/loan.php + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescLoan", $step, ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuLoanAccounts").''); print "
\n"; print "
\n"; } +/* if (! empty($conf->don->enabled)) { $step++; - print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDonation", $step, ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").''); + print img_picto('', 'puce').' '.$langs->trans("AccountancyAreaDescDonation", $step, ''.$langs->transnoentitiesnoconv("Financial").'-'.$langs->transnoentitiesnoconv("Accountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDonationAccounts").''); print "
\n"; print "
\n"; }*/ diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 782eb95d3d1..7b5e5d98d9d 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -946,10 +946,26 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/accountmodel.php?id=31&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Pcg_version"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chartmodel', 10); if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("Chartofaccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_chart', 20); if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/defaultaccounts.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDefaultAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 40); - if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 30); - if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 30); + if (! empty($conf->facture->enabled) || ! empty($conf->fournisseur->enabled)) + { + if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=10&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuVatAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 30); + } + if (! empty($conf->tax->enabled)) + { + if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/dict.php?id=7&from=accountancy&search_country_id=".$mysoc->country_id."&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuTaxAccounts"),2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_default', 30); + } + if (! empty($conf->loan->enabled)) + { + if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/admin/loan.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuLoanAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_loan', 45); + } + /* not required yet, already supported by default account + if (! empty($conf->don->enabled)) + { + if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/don/admin/donation.php?from=accountancy&mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuDonationAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_donation', 47); + }*/ if (preg_match('/accountancy_admin/',$leftmenu)) $newmenu->add("/accountancy/admin/productaccount.php?mainmenu=accountancy&leftmenu=accountancy_admin", $langs->trans("MenuProductsAccounts"), 2, $user->rights->accounting->chartofaccount, '', $mainmenu, 'accountancy_admin_product', 50); - + + // Binding if (preg_match('/accountancy/',$leftmenu)) $newmenu->add("/accountancy/customer/index.php?leftmenu=accountancy_dispatch_customer&mainmenu=accountancy",$langs->trans("CustomersVentilation"),1,$user->rights->accounting->bind->write, '', $mainmenu, 'dispatch_customer'); if (preg_match('/accountancy_dispatch_customer/',$leftmenu)) $newmenu->add("/accountancy/customer/list.php?mainmenu=accountancy&leftmenu=accountancy_dispatch_customer",$langs->trans("ToBind"),2,$user->rights->accounting->bind->write); diff --git a/htdocs/langs/en_US/accountancy.lang b/htdocs/langs/en_US/accountancy.lang index 8fd2d38026c..6a679b53939 100644 --- a/htdocs/langs/en_US/accountancy.lang +++ b/htdocs/langs/en_US/accountancy.lang @@ -49,6 +49,7 @@ AccountAccountingSuggest=Accounting account suggest MenuDefaultAccounts=Default accounts MenuVatAccounts=Vat accounts MenuTaxAccounts=Tax accounts +MenuLoanAccounts=Loan accounts MenuProductsAccounts=Product accounts ProductsBinding=Products accounts Ventilation=Binding to accounts @@ -94,9 +95,9 @@ ACCOUNTING_MISCELLANEOUS_JOURNAL=Miscellaneous journal ACCOUNTING_EXPENSEREPORT_JOURNAL=Expense report journal ACCOUNTING_SOCIAL_JOURNAL=Social journal -ACCOUNTING_ACCOUNT_TRANSFER_CASH=Account of transfer -ACCOUNTING_ACCOUNT_SUSPENSE=Account of wait -DONATION_ACCOUNTINGACCOUNT=Account to register donations +ACCOUNTING_ACCOUNT_TRANSFER_CASH=Accounting account of transfer +ACCOUNTING_ACCOUNT_SUSPENSE=Accounting account of wait +DONATION_ACCOUNTINGACCOUNT=Accounting account to register donations ACCOUNTING_PRODUCT_BUY_ACCOUNT=Accounting account by default for bought products (used if not defined in the product sheet) ACCOUNTING_PRODUCT_SOLD_ACCOUNT=Accounting account by default for the sold products (used if not defined in the product sheet) diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 3872a36a2ae..e77b53db26f 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -271,7 +271,7 @@ DefaultContact=Default contact/address AddThirdParty=Create third party DeleteACompany=Delete a company PersonalInformations=Personal data -AccountancyCode=Accountancy code +AccountancyCode=Accounting account CustomerCode=Customer code SupplierCode=Supplier code CustomerCodeShort=Customer code diff --git a/htdocs/langs/en_US/loan.lang b/htdocs/langs/en_US/loan.lang index 8c70dfc6fd2..de0a6fd0295 100644 --- a/htdocs/langs/en_US/loan.lang +++ b/htdocs/langs/en_US/loan.lang @@ -10,9 +10,9 @@ LoanCapital=Capital Insurance=Insurance Interest=Interest Nbterms=Number of terms -LoanAccountancyCapitalCode=Accountancy code capital -LoanAccountancyInsuranceCode=Accountancy code insurance -LoanAccountancyInterestCode=Accountancy code interest +LoanAccountancyCapitalCode=Accounting account capital +LoanAccountancyInsuranceCode=Accounting account insurance +LoanAccountancyInterestCode=Accounting account interest ConfirmDeleteLoan=Confirm deleting this loan LoanDeleted=Loan Deleted Successfully ConfirmPayLoan=Confirm classify paid this loan @@ -45,6 +45,6 @@ GoToPrincipal=%s will go towards PRINCIPAL YouWillSpend=You will spend %s in year %s # Admin ConfigLoan=Configuration of the module loan -LOAN_ACCOUNTING_ACCOUNT_CAPITAL=Accountancy code capital by default -LOAN_ACCOUNTING_ACCOUNT_INTEREST=Accountancy code interest by default -LOAN_ACCOUNTING_ACCOUNT_INSURANCE=Accountancy code insurance by default +LOAN_ACCOUNTING_ACCOUNT_CAPITAL=Accounting account capital by default +LOAN_ACCOUNTING_ACCOUNT_INTEREST=Accounting account interest by default +LOAN_ACCOUNTING_ACCOUNT_INSURANCE=Accounting account insurance by default From b284bdd953d26abf3f351e2fcdacd16bea7dfd43 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Oct 2016 02:02:30 +0200 Subject: [PATCH 52/53] NEW #5896 More complete data on event sent by email (name in title, emails list in details) --- htdocs/core/actions_sendmails.inc.php | 14 +++++----- htdocs/core/class/CMailFile.class.php | 36 +++++++++++++++++++------- htdocs/societe/class/societe.class.php | 2 +- test/phpunit/CMailFileTest.php | 17 +++++++++++- 4 files changed, 51 insertions(+), 18 deletions(-) diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 297fe373c04..9ec3bfcb3b7 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -171,7 +171,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // Recipient was provided from combo list if ($_POST['receiver'] == 'thirdparty') // Id of third party { - $sendto = $thirdparty->email; + $sendto = $thirdparty->name.' <'.$thirdparty->email.'>'; $sendtoid = 0; } else // Id du contact @@ -189,7 +189,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // Recipient was provided from combo list if ($_POST['receivercc'] == 'thirdparty') // Id of third party { - $sendtocc = $thirdparty->email; + $sendtocc = $thirdparty->name.' <'.$thirdparty->email.'>'; } else // Id du contact { @@ -199,6 +199,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if (dol_strlen($sendto)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $langs->load("commercial"); $fromtype = GETPOST('fromtype'); @@ -235,11 +237,12 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO if ($action == 'send' || $action == 'relance') { if (dol_strlen($_POST['subject'])) $subject = $_POST['subject']; - $actionmsg2=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; + $actionmsg2=$langs->transnoentities('MailSentBy').' '.CMailFile::getValidAddress($from,4,0,1).' '.$langs->transnoentities('To').' '.CMailFile::getValidAddress($sendto,4,0,1); if ($message) { - $actionmsg=$langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; - if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg=$langs->transnoentities('MailFrom').': '.dol_escape_htmltag($from); + $actionmsg=dol_concatdesc($actionmsg, $langs->transnoentities('MailTo').': '.dol_escape_htmltag($sendto)); + if ($sendtocc) $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . dol_escape_htmltag($sendtocc)); $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); $actionmsg = dol_concatdesc($actionmsg, $message); @@ -300,7 +303,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } // Send mail - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,$sendtobcc,$deliveryreceipt,-1,'','',$trackid); if ($mailfile->error) { diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 03f7e39bde8..317b84e0b29 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -690,7 +690,7 @@ class CMailFile * @param string $stringtoencode String to encode * @return string string encoded */ - function encodetorfc2822($stringtoencode) + static function encodetorfc2822($stringtoencode) { global $conf; return '=?'.$conf->file->character_set_client.'?B?'.base64_encode($stringtoencode).'?='; @@ -1220,15 +1220,17 @@ class CMailFile /** * Return a formatted address string for SMTP protocol * - * @param string $address Example: 'John Doe , Alan Smith ' or 'john@doe.com, alan@smith.com' - * @param int $format 0=auto, 1=emails with <>, 2=emails without <>, 3=auto + label between " - * @param int $encode 1=Encode name to RFC2822 - * @return string If format 0: '' or 'John Doe ' or '=?UTF-8?B?Sm9obiBEb2U=?= ' - * If format 1: '' - * If format 2: 'john@doe.com' - * If format 3: '' or '"John Doe" ' or '"=?UTF-8?B?Sm9obiBEb2U=?=" ' + * @param string $address Example: 'John Doe , Alan Smith ' or 'john@doe.com, alan@smith.com' + * @param int $format 0=auto, 1=emails with <>, 2=emails without <>, 3=auto + label between " + * @param int $encode 0=No encode name, 1=Encode name to RFC2822 + * @param int $maxnumberofemail 0=No limit. Otherwise, maximum number of emails returned ($address may contains several email separated with ','). Add '...' if there is more. + * @return string If format 0: '' or 'John Doe ' or '=?UTF-8?B?Sm9obiBEb2U=?= ' + * If format 1: '' + * If format 2: 'john@doe.com' + * If format 3: '' or '"John Doe" ' or '"=?UTF-8?B?Sm9obiBEb2U=?=" ' + * If format 4: 'John Doe' or 'john@doe.com' if no label exists */ - function getValidAddress($address,$format,$encode='') + static function getValidAddress($address,$format,$encode=0,$maxnumberofemail=0) { global $conf; @@ -1237,6 +1239,7 @@ class CMailFile $arrayaddress=explode(',',$address); // Boucle sur chaque composant de l'adresse + $i=0; foreach($arrayaddress as $val) { if (preg_match('/^(.*)<(.*)>$/i',trim($val),$regs)) @@ -1252,7 +1255,13 @@ class CMailFile if ($email) { + $i++; + $newemail=''; + if ($format == 4) + { + $newemail = $name?$name:$email; + } if ($format == 2) { $newemail=$email; @@ -1265,10 +1274,17 @@ class CMailFile { if (! empty($conf->global->MAIN_MAIL_NO_FULL_EMAIL)) $newemail='<'.$email.'>'; elseif (! $name) $newemail='<'.$email.'>'; - else $newemail=($format==3?'"':'').($encode?$this->encodetorfc2822($name):$name).($format==3?'"':'').' <'.$email.'>'; + else $newemail=($format==3?'"':'').($encode?self::encodetorfc2822($name):$name).($format==3?'"':'').' <'.$email.'>'; } $ret=($ret ? $ret.',' : '').$newemail; + + // Stop if we have too much records + if ($maxnumberofemail && $i >= $maxnumberofemail) + { + if (count($arrayaddress) > $maxnumberofemail) $ret.='...'; + break; + } } } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1d8ac3ff98a..c2c75c44e66 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2185,7 +2185,7 @@ class Societe extends CommonObject * * @param int $rowid id of contact * @param string $mode 'email' or 'mobile' - * @return string email of contact + * @return string Email of contact with format: "Full name " */ function contact_get_property($rowid,$mode) { diff --git a/test/phpunit/CMailFileTest.php b/test/phpunit/CMailFileTest.php index 092d2e1f41c..06f24ba45e0 100755 --- a/test/phpunit/CMailFileTest.php +++ b/test/phpunit/CMailFileTest.php @@ -177,7 +177,22 @@ class CMailFileTest extends PHPUnit_Framework_TestCase $result=$localobject->getValidAddress($src,3,1); print __METHOD__." result=".$result."\n"; $this->assertEquals($result,'"=?UTF-8?B?Sm9obiBEb2U=?=" '); - + + $src='John Doe '; + $result=$localobject->getValidAddress($src,4); + print __METHOD__." result=".$result."\n"; + $this->assertEquals($result,'John Doe'); + + $src='John Doe , John Doe2 , John Doe3 '; + $result=$localobject->getValidAddress($src,4); + print __METHOD__." result=".$result."\n"; + $this->assertEquals($result,'John Doe,John Doe2,John Doe3'); + + $src='John Doe , John Doe2 , John Doe3 '; + $result=$localobject->getValidAddress($src,4,0,2); + print __METHOD__." result=".$result."\n"; + $this->assertEquals($result,'John Doe,John Doe2...'); + return $result; } From 33a7b7037d40fa1ed91eb8c3efffe8872ff0ab24 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 24 Oct 2016 03:23:40 +0200 Subject: [PATCH 53/53] Save information of vat code into database --- htdocs/comm/propal/card.php | 38 ++++----- htdocs/commande/card.php | 38 ++++----- htdocs/compta/facture.php | 80 ++++++++++--------- htdocs/compta/facture/class/facture.class.php | 19 +++-- htdocs/compta/paiement.php | 4 +- .../fourn/class/fournisseur.facture.class.php | 15 ++-- htdocs/theme/eldy/style.css.php | 3 +- htdocs/theme/md/style.css.php | 3 +- 8 files changed, 110 insertions(+), 90 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 038b42e7c13..68b59f528bd 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2083,8 +2083,26 @@ if ($action == 'create') print ''; + if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) + { + // Multicurrency Amount HT + print ''; + print ''; + print ''; + + // Multicurrency Amount VAT + print ''; + print ''; + print ''; + + // Multicurrency Amount TTC + print ''; + print ''; + print ''; + } + // Amount HT - print ''; + print ''; print ''; print ''; @@ -2112,24 +2130,6 @@ if ($action == 'create') print ''; print ''; - if (!empty($conf->multicurrency->enabled)) - { - // Multicurrency Amount HT - print ''; - print ''; - print ''; - - // Multicurrency Amount VAT - print ''; - print ''; - print ''; - - // Multicurrency Amount TTC - print ''; - print ''; - print ''; - } - // Statut //print ''; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index b79ea443a3e..6730bf99750 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -2301,8 +2301,26 @@ if ($action == 'create' && $user->rights->commande->creer) print '
' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . $langs->trans('AmountHT') . '
' . $langs->trans('AmountHT') . '' . price($object->total_ht, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . price($object->total_ttc, '', $langs, 0, - 1, - 1, $conf->currency) . '
' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . $langs->trans('Status') . '' . $object->getLibStatut(4) . '
'; + if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) + { + // Multicurrency Amount HT + print ''; + print ''; + print ''; + + // Multicurrency Amount VAT + print ''; + print ''; + print ''; + + // Multicurrency Amount TTC + print ''; + print ''; + print ''; + } + // Total HT - print ''; + print ''; print ''; // Total VAT @@ -2323,24 +2341,6 @@ if ($action == 'create' && $user->rights->commande->creer) // Total TTC print ''; - if (!empty($conf->multicurrency->enabled)) - { - // Multicurrency Amount HT - print ''; - print ''; - print ''; - - // Multicurrency Amount VAT - print ''; - print ''; - print ''; - - // Multicurrency Amount TTC - print ''; - print ''; - print ''; - } - // Statut //print ''; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 8f2088a2bab..2f4f887f652 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1054,9 +1054,10 @@ if (empty($reshook)) $langs->trans('Deposit'), $amountdeposit, // subprice 1, // quantity - $lines[$i]->tva_tx, 0, // localtax1_tx + $lines[$i]->tva_tx, // vat rate + 0, // localtax1_tx 0, // localtax2_tx - 0, // fk_product + (empty($conf->global->INVOICE_PRODUCTID_DEPOSIT)?0:$conf->global->INVOICE_PRODUCTID_DEPOSIT), // fk_product 0, // remise_percent 0, // date_start 0, // date_end @@ -3099,7 +3100,7 @@ else if ($id > 0 || ! empty($ref)) print ''; } - // Conditions de reglement + // Payment term print '
' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . $langs->trans('AmountHT') . '
' . $langs->trans('AmountHT') . '' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . '
' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) . '
' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . $langs->trans('Status') . '' . $object->getLibStatut(4) . '
'; print ''; // Multicurrency rate - print ''; - print ''; + //if ($object->multicurrency_code != $conf->currency) + //{ + print ''; + print ''; + //} } // Bank Account @@ -3307,9 +3311,29 @@ else if ($id > 0 || ! empty($ref)) print '
'; print $langs->trans('PaymentConditionsShort'); @@ -3184,21 +3185,24 @@ else if ($id > 0 || ! empty($ref)) print '
'; - print ''; - if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon)) - print ''; - print '
'; - print fieldLabel('CurrencyRate','multicurrency_tx'); - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; - print '
'; - if ($action == 'editmulticurrencyrate') { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); - } else { - $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); - } - print '
'; + print ''; + if ($action != 'editmulticurrencyrate' && ! empty($object->brouillon)) + print ''; + print '
'; + print fieldLabel('CurrencyRate','multicurrency_tx'); + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . '
'; + print '
'; + if ($action == 'editmulticurrencyrate') { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'multicurrency_tx', $object->multicurrency_code); + } else { + $form->form_multicurrency_rate($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->multicurrency_tx, 'none', $object->multicurrency_code); + } + print '
'; + if (!empty($conf->multicurrency->enabled) && ($object->multicurrency_code != $conf->currency)) + { + // Multicurrency Amount HT + print ''; + print ''; + print ''; + + // Multicurrency Amount VAT + print ''; + print ''; + print ''; + + // Multicurrency Amount TTC + print ''; + print ''; + print ''; + } + // Amount - print ''; + print ''; print ''; + + // Vat print ''; print ''; @@ -3355,24 +3379,6 @@ else if ($id > 0 || ! empty($ref)) // Total with tax print ''; - if (!empty($conf->multicurrency->enabled)) - { - // Multicurrency Amount HT - print ''; - print ''; - print ''; - - // Multicurrency Amount VAT - print ''; - print ''; - print ''; - - // Multicurrency Amount TTC - print ''; - print ''; - print ''; - } - print '
' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . $langs->trans('AmountHT') . '
' . $langs->trans('AmountHT') . '' . price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency) . '
' . $langs->trans('AmountVAT') . '' . price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency) . '
' . $langs->trans('AmountTTC') . '' . price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency) . '
' . fieldLabel('MulticurrencyAmountHT','multicurrency_total_ht') . '' . price($object->multicurrency_total_ht, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountVAT','multicurrency_total_tva') . '' . price($object->multicurrency_total_tva, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
' . fieldLabel('MulticurrencyAmountTTC','multicurrency_total_ttc') . '' . price($object->multicurrency_total_ttc, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)) . '
'; // List of payments diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index fafb4ce51fe..1e3d59b7e65 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2311,7 +2311,7 @@ class Facture extends CommonInvoice * @param string $desc Description of line * @param double $pu_ht Unit price without tax (> 0 even for credit note) * @param double $qty Quantity - * @param double $txtva Force vat rate, -1 for auto + * @param double $txtva Force Vat rate, -1 for auto * @param double $txlocaltax1 Local tax 1 rate (deprecated) * @param double $txlocaltax2 Local tax 2 rate (deprecated) * @param int $fk_product Id of predefined product/service @@ -2363,6 +2363,16 @@ class Facture extends CommonInvoice if (empty($fk_prev_id)) $fk_prev_id = 'null'; if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100; + $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc); + + // Clean vat code + $vat_src_code=''; + if (preg_match('/\((.*)\)/', $txtva, $reg)) + { + $vat_src_code = $reg[1]; + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. + } + $remise_percent=price2num($remise_percent); $qty=price2num($qty); $pu_ht=price2num($pu_ht); @@ -2408,9 +2418,6 @@ class Facture extends CommonInvoice // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva. - $localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty, $mysoc); - $txtva = preg_replace('/\s*\(.*\)/','',$txtva); // Remove code into vatrate. - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $product_type, $mysoc, $localtaxes_type, $situation_percent, $this->multicurrency_tx); $total_ht = $tabprice[0]; @@ -2445,6 +2452,7 @@ class Facture extends CommonInvoice $this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative $this->line->subprice= ($this->type==self::TYPE_CREDIT_NOTE?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise + $this->line->vat_src_code=$vat_src_code; $this->line->tva_tx=$txtva; $this->line->localtax1_tx=$txlocaltax1; $this->line->localtax2_tx=$txlocaltax2; @@ -4315,7 +4323,7 @@ class FactureLigne extends CommonInvoiceLine // Insertion dans base de la ligne $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet'; $sql.= ' (fk_facture, fk_parent_line, label, description, qty,'; - $sql.= ' tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; + $sql.= ' vat_src_code, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; $sql.= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,'; $sql.= ' date_start, date_end, fk_code_ventilation, '; $sql.= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,'; @@ -4329,6 +4337,7 @@ class FactureLigne extends CommonInvoiceLine $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; $sql.= " '".$this->db->escape($this->desc)."',"; $sql.= " ".price2num($this->qty).","; + $sql.= " ".(empty($this->vat_src_code)?"''":"'".$this->vat_src_code."'").","; $sql.= " ".price2num($this->tva_tx).","; $sql.= " ".price2num($this->localtax1_tx).","; $sql.= " ".price2num($this->localtax2_tx).","; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 97630ca4252..a1f50959aa4 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -461,7 +461,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; // Third party - print '\n"; + print '\n"; // Date payment print ''; print ''; + print ''; print '
'.$langs->trans('Company').''.$facture->thirdparty->getNomUrl(4)."
'.$langs->trans('Company').''.$facture->thirdparty->getNomUrl(4)."
'.$langs->trans('Date').''; @@ -513,7 +513,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Comments print '
'.$langs->trans('Comments').''; - print '
'; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index c9634a1d687..9bb8af69a35 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1241,7 +1241,7 @@ class FactureFournisseur extends CommonInvoice * * @param string $desc Description de la ligne * @param double $pu Prix unitaire (HT ou TTC selon price_base_type, > 0 even for credit note) - * @param double $txtva Taux de tva force, sinon -1 + * @param double $txtva Force Vat rate to use, -1 for auto. * @param double $txlocaltax1 LocalTax1 Rate * @param double $txlocaltax2 LocalTax2 Rate * @param double $qty Quantite @@ -1277,13 +1277,17 @@ class FactureFournisseur extends CommonInvoice if (empty($txtva)) $txtva=0; if (empty($txlocaltax1)) $txlocaltax1=0; if (empty($txlocaltax2)) $txlocaltax2=0; + + $localtaxes_type=getLocalTaxesFromRate($txtva, 0, $mysoc, $this->thirdparty); + // Clean vat code + $vat_src_code=''; if (preg_match('/\((.*)\)/', $txtva, $reg)) { $vat_src_code = $reg[1]; - $txtva = preg_replace('/\((.*)\)/', '', $txtva); + $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate. } - + $remise_percent=price2num($remise_percent); $qty=price2num($qty); $pu=price2num($pu); @@ -1291,8 +1295,6 @@ class FactureFournisseur extends CommonInvoice $txlocaltax1=price2num($txlocaltax1); $txlocaltax2=price2num($txlocaltax2); - $localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc, $this->thirdparty); - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type, 100, $this->multicurrency_tx); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; @@ -1317,8 +1319,9 @@ class FactureFournisseur extends CommonInvoice //$this->line->label=$label; // deprecated $this->line->desc=$desc; $this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative - $this->line->tva_tx=$txtva; + $this->line->vat_src_code=$vat_src_code; + $this->line->tva_tx=$txtva; $this->line->localtax1_tx=$txlocaltax1; $this->line->localtax2_tx=$txlocaltax2; $this->line->fk_product=$fk_product; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 454e6e62347..e176ebcaaee 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -624,8 +624,9 @@ div.myavailability { .maxwidth500 { max-width: 500px; } .minheight20 { min-height: 20px; } .minheight40 { min-height: 40px; } -.titlefield { width: 25%; } .titlefieldcreate { width: 20%; } +.titlefield { width: 25%; } +.titlefieldmiddle { width: 50%; } /* Force values for small screen */ @media only screen and (max-width: 1400px) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 05ba40e86d2..ef751d882f7 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -618,8 +618,9 @@ div.myavailability { .maxwidth500 { max-width: 500px; } .minheight20 { min-height: 20px; } .minheight40 { min-height: 40px; } -.titlefield { width: 25%; } .titlefieldcreate { width: 20%; } +.titlefield { width: 25%; } +.titlefieldmiddle { width: 50%; } /* Force values for small screen */ @media only screen and (max-width: 1400px)