diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index c410e507b96..221f224e043 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -748,6 +748,15 @@ class Facture extends CommonInvoice // Charge facture source $facture=new Facture($this->db); + + $this->fetch_optionals(); + if(!empty($this->array_options)){ + $facture->array_options = $this->array_options; + } + + foreach($this->lines as &$line){ + $line->fetch_optionals();//fetch extrafields + } $facture->fk_facture_source = $this->fk_facture_source; $facture->type = $this->type; diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index c421ec6124c..092ae36fe28 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -568,7 +568,7 @@ class pdf_crabe extends ModelePDFFactures if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva $prev_progress = $object->lines[$i]->get_prev_progress($object->id); - if ($prev_progress > 0) // Compute progress from previous situation + if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation { if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent; diff --git a/htdocs/public/cron/cron_run_jobs.php b/htdocs/public/cron/cron_run_jobs.php index 3ca058acb8a..725aea8825d 100644 --- a/htdocs/public/cron/cron_run_jobs.php +++ b/htdocs/public/cron/cron_run_jobs.php @@ -1,7 +1,8 @@ - * Copyright (C) 2013-2015 Laurent Destailleur +/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr + * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013-2015 Laurent Destailleur + * Copyright (C) 2017 Regis Houssin * * 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 @@ -30,6 +31,11 @@ if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); if (! defined('NOLOGIN')) define('NOLOGIN','1'); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); +// For MultiCompany module. +// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php +$entity=(! empty($_GET['entity']) ? (int) $_GET['entity'] : (! empty($_POST['entity']) ? (int) $_POST['entity'] : 1)); +if (is_numeric($entity)) define("DOLENTITY", $entity); + // librarie core // Dolibarr environment $res = @include("../../main.inc.php"); // From htdocs directory diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index f6eb4c58935..fd08ccf1b6a 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -186,7 +186,7 @@ class ProductCombination { $nb = 0; $sql = "SELECT count(rowid) as nb FROM ".MAIN_DB_PREFIX."product_attribute_combination WHERE fk_product_parent = ".(int) $fk_product_parent." AND entity IN (".getEntity('product').")"; - + $resql = $this->db->query($sql); if ($resql) { $obj = $this->db->fetch_object($resql); @@ -195,7 +195,7 @@ class ProductCombination return $nb; } - + /** * Creates a product attribute combination * @@ -249,9 +249,10 @@ class ProductCombination /** * Deletes a product combination * + * @param User $user * @return int <0 KO >0 OK */ - public function delete() + public function delete(User $user) { $this->db->begin(); diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 76a091ad8a2..0ec1bf07b68 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -101,8 +101,8 @@ if ($_POST) { if (!$features) { setEventMessage($langs->trans('ErrorFieldsRequired'), 'errors'); - } - else + } + else { $weight_impact = price2num($weight_impact); $price_impact = price2num($price_impact); @@ -149,8 +149,8 @@ if ($_POST) { $db->rollback(); } - } - elseif (! empty($massaction)) + } + elseif (! empty($massaction)) { $bulkaction = $massaction; $error = 0; @@ -203,7 +203,7 @@ if ($_POST) { setEventMessage($langs->trans('RecordSaved')); } - } + } elseif ($valueid > 0) { if ($prodcomb->fetch($valueid) < 0) { @@ -234,7 +234,7 @@ if ($action === 'confirm_deletecombination') { $db->begin(); - if ($prodcomb->delete() > 0 && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete() > 0) { + if ($prodcomb->delete($user) > 0 && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete($user) > 0) { $db->commit(); setEventMessage($langs->trans('RecordSaved')); header('Location: '.dol_buildpath('/variants/combinations.php?id='.$object->id, 2)); @@ -288,26 +288,26 @@ if ($action === 'confirm_deletecombination') { $form = new Form($db); -if (! empty($id) || ! empty($ref)) +if (! empty($id) || ! empty($ref)) { llxHeader("", "", $langs->trans("CardProduct".$object->type)); $showbarcode=empty($conf->barcode->enabled)?0:1; if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode=0; - + $head=product_prepare_head($object); $titre=$langs->trans("CardProduct".$object->type); $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'combinations', $titre, 0, $picto); - + $linkback = ''.$langs->trans("BackToList").''; $object->next_prev_filter=" fk_product_type = ".$object->type; - + dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', '', '', '', 0, '', '', 1); - + dol_fiche_end(); - + // Create or edit a varian if ($action == 'add' || ($action == 'edit')) { @@ -343,7 +343,7 @@ if (! empty($id) || ! empty($ref)) info: [] }; - fetch($pc2v->fk_prod_attr_val); ?> @@ -355,8 +355,8 @@ if (! empty($id) || ! empty($ref)) label: 'value ?>' } }; - restoreAttributes = function() { @@ -369,7 +369,7 @@ if (! empty($id) || ! empty($ref)) }); }; - + jQuery(document).ready(function() { jQuery("select#attribute").change(function () { console.log("Change of field variant attribute"); @@ -404,18 +404,18 @@ if (! empty($id) || ! empty($ref)) }); }); - - '."\n"; print ''."\n"; print ''."\n"; - + print dol_fiche_head(); - + ?> - + @@ -445,7 +445,7 @@ if (! empty($id) || ! empty($ref))

- @@ -495,12 +495,12 @@ if (! empty($id) || ! empty($ref))   - + '; } - else + else { if ($action === 'delete') { @@ -538,7 +538,7 @@ if (! empty($id) || ! empty($ref)) $comb2val = new ProductCombination2ValuePair($db); - if ($productCombinations) + if ($productCombinations) { ?> @@ -563,36 +563,36 @@ if (! empty($id) || ! empty($ref)) }); - '; - + print '
'; if ($productCombinations) { print ''.$langs->trans('PropagateVariant').''; } - + print ''.$langs->trans('NewProductCombination').''; // NewVariant - + // Too much bugged page. /* print ''.$langs->trans('ProductCombinationGenerator').''; */ - + print '
'; - + print ''; - - - + + + $arrayofselected=is_array($toselect)?$toselect:array(); - - + + // List of variants print ''; - - + + // List of mass actions available /* $arrayofmassactions = array( @@ -603,7 +603,7 @@ if (! empty($id) || ! empty($ref)) if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); */ - + $aaa=''; if (count($productCombinations)) { @@ -620,11 +620,11 @@ if (! empty($id) || ! empty($ref)) $aaa .= ''; } $massactionbutton = $aaa; - + $title = $langs->trans("ProductCombinations"); - + print_barre_liste($title, 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $aaa, 0); - + print '
'; ?>
@@ -636,7 +636,7 @@ if (! empty($id) || ! empty($ref)) - '; $searchpicto=$form->showCheckAddButtons('checkforselect', 1); print $searchpicto; @@ -644,23 +644,23 @@ if (! empty($id) || ! empty($ref)) ?> fetch($currcomb->fk_product_child); + $prodstatic->fetch($currcomb->fk_product_child); ?> - '; if ($productCombinations || $massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { @@ -690,7 +690,7 @@ if (! empty($id) || ! empty($ref)) } else { - print ''; + print ''; } ?>
trans('OnSell') ?> trans('OnBuy') ?>
getNomUrl(1) ?> fetchByFkCombination($currcomb->id); $iMax = count($productCombination2ValuePairs); - + for ($i = 0; $i < $iMax; $i++) { echo dol_htmlentities($productCombination2ValuePairs[$i]); - + if ($i !== ($iMax - 1)) { echo ', '; } @@ -674,7 +674,7 @@ if (! empty($id) || ! empty($ref))
'.$langs->trans("None").'
'.$langs->trans("None").'