From 83107746ad77b89f83e6ba9a33825ff9e9c3b911 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 19 Aug 2016 16:18:17 +0200 Subject: [PATCH 1/4] Fix no way to fix the ref of recurring invoice when an error was done into typing. --- htdocs/compta/facture/fiche-rec.php | 214 +++----------------------- htdocs/core/class/html.form.class.php | 10 +- 2 files changed, 29 insertions(+), 195 deletions(-) diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 198b08cb451..6145766e1e4 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Juanjo Menent @@ -266,6 +266,16 @@ elseif ($action == 'classin' && $user->rights->facture->creer) $object->setProject(GETPOST('projectid', 'int')); } // Set bank account +elseif ($action == 'setref' && $user->rights->facture->creer) +{ + $result=$object->setValueFrom('titre', GETPOST('ref', 'alpha')); + if ($result > 0) + { + $object->titre = GETPOST('ref', 'alpha'); + $object->ref = $object->titre; + } +} +// Set bank account elseif ($action == 'setbankaccount' && $user->rights->facture->creer) { $result=$object->setBankAccount(GETPOST('fk_account', 'int')); @@ -840,15 +850,15 @@ if ($action == 'create') $object->fetch_thirdparty(); + // Title + print ''.$langs->trans("Title").''; + print ''; + print ''; + // Third party print ''.$langs->trans("Customer").''.$object->thirdparty->getNomUrl(1,'customer').''; print ''; - // Title - print ''.$langs->trans("Title").''; - print ''; - print ''; - // Note public print ''.$langs->trans("NotePublic").''; print ''; @@ -950,176 +960,7 @@ if ($action == 'create') } print "\n"; - - /* - print ''; - print ''; if ($flag_price_may_change) @@ -1178,20 +1019,13 @@ else $linkback = '' . $langs->trans("BackToList") . ''; // Ref - print ''; - print ''; + print ''; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 2929044a858..cebb623823a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5580,15 +5580,15 @@ class Form * @param string $paramid Name of parameter to use to name the id into the URL next/previous link * @param string $morehtml More html content to output just before the nav bar * @param int $shownav Show Condition (navigation is shown if value is 1) - * @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field) - * @param string $fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous + * @param string $fieldid Name of field id into database to use for select next and previous (we make the select max and min on this field) + * @param string $fieldref Name of field ref of object (object->ref) to show or 'none' to not show ref. * @param string $morehtmlref More html to show after ref * @param string $moreparam More param to add in nav link url. * @param int $nodbprefix Do not include DB prefix to forge table name * @param string $morehtmlleft More html code to show before ref * @param string $morehtmlstatus More html code to show under navigation arrows (status place) * @param string $morehtmlright More html code to show after ref - * @return string Portion HTML avec ref + boutons nav + * @return string Portion HTML with ref + navigation buttons */ function showrefnav($object,$paramid,$morehtml='',$shownav=1,$fieldid='rowid',$fieldref='ref',$morehtmlref='',$moreparam='',$nodbprefix=0,$morehtmlleft='',$morehtmlstatus='',$morehtmlright='') { @@ -5613,7 +5613,7 @@ class Form $ret.='
'; - // For thirdparty and contact, the ref is the id, so we show something else + // For thirdparty, contact, user, member, the ref is the id, so we show something else if ($object->element == 'societe') { $ret.=dol_htmlentities($object->name); @@ -5622,7 +5622,7 @@ class Form { $ret.=dol_htmlentities($object->getFullName($langs)); } - else $ret.=dol_htmlentities($object->$fieldref); + else if ($fieldref != 'none') $ret.=dol_htmlentities($object->$fieldref); if ($morehtmlref) { $ret.=' '.$morehtmlref; From f06545a3fe30abc517e7ad5f2faf4cd5706933ca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 19 Aug 2016 17:22:53 +0200 Subject: [PATCH 2/4] Fix cancel button ignored --- htdocs/compta/facture/fiche-rec.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 6145766e1e4..de76577e78b 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -128,6 +128,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once +if (GETPOST('cancel')) $action=''; + // Create predefined invoice if ($action == 'add') { From 1fc571504021019de1703acd3a4931c75018ceaa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 20 Aug 2016 00:30:09 +0200 Subject: [PATCH 3/4] Fix date of contract not used --- htdocs/contrat/class/contrat.class.php | 1 + htdocs/core/modules/contract/doc/pdf_strato.modules.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index fd92db95dfc..69e969c56d9 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2127,6 +2127,7 @@ class Contrat extends CommonObject $this->ref_supplier = 'SPECIMENSUPP'; $this->socid = 1; $this->statut= 0; + $this->date_creation = (dol_now() - 3600 * 24 * 7); $this->date_contrat = dol_now(); $this->commercial_signature_id = 1; $this->commercial_suivi_id = 1; diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index a2828fb466a..a25c9918408 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -554,7 +554,7 @@ class pdf_strato extends ModelePDFContract $posy+=4; $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date_creation,"day",false,$outputlangs,true), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date_contrat,"day",false,$outputlangs,true), '', 'R'); if ($object->thirdparty->code_client) { From 0839a9fa4f99e5e587d369b3bc54156829402684 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 20 Aug 2016 00:54:49 +0200 Subject: [PATCH 4/4] Code comment --- htdocs/core/lib/geturl.lib.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index 2785a0aeafc..7731c7473e5 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -59,6 +59,9 @@ function getURLContent($url,$postorget='GET',$param='',$followlocation=1,$addhea if (count($addheaders)) curl_setopt($ch, CURLOPT_HTTPHEADER, $addheaders); curl_setopt($ch, CURLINFO_HEADER_OUT, true); // To be able to retrieve request header and log it + // TLSv1 by default or change to TLSv1.2 in module configuration + //curl_setopt($ch, CURLOPT_SSLVERSION, (empty($conf->global->MAIN_CURL_SSLVERSION)?1:$conf->global->MAIN_CURL_SSLVERSION)); + //turning off the server and peer verification(TrustManager Concept). curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
'; - - $sql = 'SELECT l.fk_product, l.product_type, l.label as custom_label, l.description, l.qty, l.rowid, l.tva_tx,'; - $sql.= ' l.fk_remise_except,'; - $sql.= ' l.remise_percent, l.subprice, l.info_bits,'; - $sql.= ' l.total_ht, l.total_tva as total_vat, l.total_ttc,'; - $sql.= ' l.date_start,'; - $sql.= ' l.date_end,'; - $sql.= ' l.product_type,'; - $sql.= ' l.fk_unit,'; - $sql.= ' p.ref, p.fk_product_type, p.label as product_label,'; - $sql.= ' p.description as product_desc'; - $sql.= " FROM ".MAIN_DB_PREFIX."facturedet as l"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid"; - $sql.= " WHERE l.fk_facture = ".$object->id; - $sql.= " ORDER BY l.rowid"; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; $total = 0; - - echo ''; - if ($num) - { - print ''; - print ''; - print ''; - print ''; - if ($conf->global->PRODUCT_USE_UNITS) { - print ''; - } - print ''; - print ''; - print ''; - print ''; - print ''; - if (empty($conf->global->PRODUIT_MULTIPRICES)) print ''; - print "\n"; - } - $var=true; - while ($i < $num) - { - $objp = $db->fetch_object($result); - - if ($objp->fk_product > 0) - { - $product = New Product($db); - $product->fetch($objp->fk_product); - } - - $var=!$var; - print ""; - - // Show product and description - $type=(isset($objp->product_type)?$objp->product_type:$objp->fk_product_type); - $product_static->fk_unit=$objp->fk_unit; - - if ($objp->fk_product > 0) - { - print ''; - } - else - { - print '\n"; - } - - // Vat rate - print ''; - - // Qty - print ''; - - if ($conf->global->PRODUCT_USE_UNITS) { - print ''; - } - - // Percent - if ($objp->remise_percent > 0) - { - print '\n"; - } - else - { - print ''; - } - - // Total HT - print '\n"; - - // Total VAT - print '\n"; - - // Total TTC - print '\n"; - - // Total Unit price - print '\n"; - - // Current price of product - if (empty($conf->global->PRODUIT_MULTIPRICES)) - { - if ($objp->fk_product > 0) - { - $flag_price_may_change++; - $prodprice=$product_static->price; // price HT - print '\n"; - } - else - { - print ''; - } - } - - print ""; - - $i++; - } - - $db->free($result); - - } - else - { - print $db->error(); - } - print "
'.$langs->trans("Description").''.$langs->trans("VAT").''.$langs->trans("Qty").''.$langs->trans("Unit").''.$langs->trans("ReductionShort").''.$langs->trans("TotalHT").''.$langs->trans("TotalVAT").''.$langs->trans("TotalTTC").''.$langs->trans("PriceUHT").''.$langs->trans("CurrentProductPrice").'
'; - - print ''; // ancre pour retourner sur la ligne - - // Show product and description - $product_static->fetch($objp->fk_product); // We need all information later - $text=$product_static->getNomUrl(1); - $text.= ' - '.(! empty($objp->custom_label)?$objp->custom_label:$objp->product_label); - $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description)); - print $form->textwithtooltip($text,$description,3,'','',$i); - - // Show range - print_date_range($db->jdate($objp->date_start), $db->jdate($objp->date_end)); - - // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) - print (! empty($objp->description) && $objp->description!=$objp->product_label)?'
'.dol_htmlentitiesbr($objp->description):''; - - print '
'; - print ''; // ancre pour retourner sur la ligne - - if ($type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); - - if (! empty($objp->custom_label)) { - - $text.= ' '.$objp->custom_label.''; - print $form->textwithtooltip($text,dol_htmlentitiesbr($objp->description),3,'','',$i); - - } else { - - print $text.' '.nl2br($objp->description); - } - - // Show range - print_date_range($db->jdate($objp->date_start), $db->jdate($objp->date_end)); - - print "'.vatrate($objp->tva_tx).'%'.$objp->qty.''.$product_static->getLabelOfUnit().''.$objp->remise_percent." % '.price($objp->total_ht)."'.price($objp->total_vat)."'.price($objp->total_ttc)."'.price($objp->subprice)."'.price($prodprice)." 
"; - */ - + print '
' . $langs->trans('Ref') . ''; - $morehtmlref = ''; - /* - require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; - $discount = new DiscountAbsolute($db); - $result = $discount->fetch(0, $object->id); - if ($result > 0) { - $morehtmlref = ' (' . $langs->trans("CreditNoteConvertedIntoDiscount", $discount->getNomUrl(1, 'discount')) . ')'; - } - if ($result < 0) { - dol_print_error('', $discount->error); - }*/ - print $form->showrefnav($object, 'ref', $linkback, 1, 'titre', 'titre', $morehtmlref); + print '
'; + //print $langs->trans('Ref'); + print $form->editfieldkey($langs->trans("Ref"), 'ref', $object->ref, $object, $user->rights->facture->creer); + print ''; + $morehtmlref = $form->editfieldval($langs->trans("Ref"), 'ref', $object->ref, $object, $user->rights->facture->creer, 'string'); + print $form->showrefnav($object, 'ref', $linkback, 1, 'titre', 'none', $morehtmlref); print '