diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 4b734a5e7d9..d7f9384399f 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -785,7 +785,8 @@ if ($resql) Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"), Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"), Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), - Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), + Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), + Facture::TYPE_SITUATION=>$langs->trans("InvoiceSituation"), ); //$listtype[Facture::TYPE_PROFORMA]=$langs->trans("InvoiceProForma"); // A proformat invoice is not an invoice but must be an order. print $form->selectarray('search_type', $listtype, $search_type, 1, 0, 0, '', 0, 0, 0, 'ASC', 'maxwidth100'); diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 7c5b99e2945..729700093e6 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -1114,5 +1114,31 @@ class Paiement extends CommonObject }*/ return ''; } + + /** + * Load the third party of object, from id into this->thirdparty + * + * @param int $force_thirdparty_id Force thirdparty id + * @return int <0 if KO, >0 if OK + */ + function fetch_thirdparty($force_thirdparty_id=0) + { + require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; + + if (empty($force_thirdparty_id)) + { + $billsarray = $this->getBillsArray(); // From payment, the fk_soc isn't available, we should load the first invoice to get him + if (!empty($billsarray)) + { + $supplier_invoice = new FactureFournisseur($this->db); + if ($supplier_invoice->fetch($billsarray[0]) > 0) + { + $force_thirdparty_id = $supplier_invoice->fk_soc; + } + } + } + + return parent::fetch_thirdparty($force_thirdparty_id); + } } diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php index da8ef616a4f..eb66ae21a4f 100644 --- a/htdocs/contact/document.php +++ b/htdocs/contact/document.php @@ -58,9 +58,7 @@ $result = restrictedArea($user, 'contact', $id, 'socpeople&societe', '', '', 'ro $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { - $page = 0; -} +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -108,7 +106,7 @@ if ($object->id) } $linkback = ''.$langs->trans("BackToList").''; - + $morehtmlref='
| '.$langs->trans("UserTitle").' | '; print $object->getCivilityLabel(); @@ -160,7 +158,7 @@ if ($object->id) print ''; dol_fiche_end(); - + $modulepart = 'contact'; $permission = $user->rights->societe->contact->creer; $permtoedit = $user->rights->societe->contact->creer; diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index b01637d7b08..dd756830f41 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -477,3 +477,42 @@ function measuring_units_string($unit,$measuring_style='') return $measuring_units[$unit]; } + +/** + * Transform a given unit into the square of that unit, if known + * + * @param int $unit Unit key (-3,-2,-1,0,98,99...) + * @return int Squared unit key (-6,-4,-2,0,98,99...) + * @see formproduct->load_measuring_units + */ +function measuring_units_squared($unit) +{ + $measuring_units=array(); + $measuring_units[0] = 0; // m -> m3 + $measuring_units[-1] = -2; // dm-> dm2 + $measuring_units[-2] = -4; // cm -> cm2 + $measuring_units[-3] = -6; // mm -> mm2 + $measuring_units[98] = 98; // foot -> foot2 + $measuring_units[99] = 99; // inch -> inch2 + return $measuring_units[$unit]; +} + + +/** + * Transform a given unit into the cube of that unit, if known + * + * @param int $unit Unit key (-3,-2,-1,0,98,99...) + * @return int Cubed unit key (-9,-6,-3,0,88,89...) + * @see formproduct->load_measuring_units + */ +function measuring_units_cubed($unit) +{ + $measuring_units=array(); + $measuring_units[0] = 0; // m -> m2 + $measuring_units[-1] = -3; // dm-> dm3 + $measuring_units[-2] = -6; // cm -> cm3 + $measuring_units[-3] = -9; // mm -> mm3 + $measuring_units[98] = 88; // foot -> foot3 + $measuring_units[99] = 89; // inch -> inch3 + return $measuring_units[$unit]; +} diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 6fbfb4b1bf4..7d0772f272c 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -723,12 +723,12 @@ class pdf_standard extends ModelePDFSuppliersPayments if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $thirdparty = $object->contact; } else { - $thirdparty = $mysoc; + $thirdparty = $object->thirdparty; } $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,((!empty($object->contact))?$object->contact:null),$usecontact,'target',$object); + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$thirdparty,((!empty($object->contact))?$object->contact:null),$usecontact,'target',$object); // Show recipient $widthrecbox=90; diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 7a709bbce94..c2c98b9f00d 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -734,4 +734,30 @@ class PaiementFourn extends Paiement return $way; } + + /** + * Load the third party of object, from id into this->thirdparty + * + * @param int $force_thirdparty_id Force thirdparty id + * @return int <0 if KO, >0 if OK + */ + function fetch_thirdparty($force_thirdparty_id=0) + { + require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; + + if (empty($force_thirdparty_id)) + { + $billsarray = $this->getBillsArray(); // From payment, the fk_soc isn't available, we should load the first supplier invoice to get him + if (!empty($billsarray)) + { + $supplier_invoice = new FactureFournisseur($this->db); + if ($supplier_invoice->fetch($billsarray[0]) > 0) + { + $force_thirdparty_id = $supplier_invoice->fk_soc; + } + } + } + + return parent::fetch_thirdparty($force_thirdparty_id); + } } diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index b1a8c0c08c1..20f9a3674cf 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -171,16 +171,15 @@ if (($action == 'create' || $action == 'add') && ! $error) { if ($ret < 0) $error++; if ($_POST['origin'] && $_POST['originid']) { - $object->linked_objects = $orders_id; + $linked_orders_ids=array(); + foreach ( $orders_id as $origin => $origin_id ) { + $origin_id = (! empty($origin_id) ? $origin_id : $orders_id[$ii]); + $linked_orders_ids[]=$origin_id; + } + $object->linked_objects = array(GETPOST('origin')=>$linked_orders_ids); $id = $object->create($user); if ($id > 0) { - foreach ( $orders_id as $origin => $origin_id ) { - $origin_id = (! empty($origin_id) ? $origin_id : $orders_id[$ii]); - - $object->add_object_linked(GETPOST('origin'), $origin_id); - } - while ( $ii < $nn ) { $objectsrc = new CommandeFournisseur($db); dol_syslog("Try to find source object origin=" . $object->origin . " originid=" . $object->origin_id . " to add lines"); diff --git a/htdocs/product/admin/product_tools.php b/htdocs/product/admin/product_tools.php index f19f672a25e..c9323f75823 100644 --- a/htdocs/product/admin/product_tools.php +++ b/htdocs/product/admin/product_tools.php @@ -73,7 +73,7 @@ if ($action == 'convert') { $vat_src_code_old = $reg[1]; $oldvatrateclean = preg_replace('/\s*\(.*\)/', '', $oldvatrate); // Remove code into vatrate. - } + } else $oldvatrateclean=$oldvatrate; // Clean vat code new $vat_src_code_new=''; @@ -81,7 +81,7 @@ if ($action == 'convert') { $vat_src_code_new = $reg[1]; $newvatrateclean = preg_replace('/\s*\(.*\)/', '', $newvatrate); // Remove code into vatrate. - } + } else $newvatrateclean=$newvatrate; // If country to edit is my country, so we change customer prices if ($country_id == $mysoc->country_id) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ed5813c2998..0b40f815816 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -745,12 +745,12 @@ class Product extends CommonObject if (empty($this->surface) && !empty($this->length) && !empty($this->width) && $this->length_units == $this->width_units) { $this->surface = $this->length * $this->width; - $this->surface_units = $this->length_units + $this->width_units; + $this->surface_units = measuring_units_squared($this->length_units); } if (empty($this->volume) && !empty($this->surface_units) && !empty($this->height) && $this->length_units == $this->height_units) { $this->volume = $this->surface * $this->height; - $this->volume_units = $this->surface_units + $this->height_units; + $this->volume_units = measuring_units_cubed($this->height_units); } $this->surface = price2num($this->surface); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 8322fec244e..84cf070b39d 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -821,7 +821,7 @@ else if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire) { $htmltext=$product_fourn->display_price_product_fournisseur(1, 1, 0, 1); - print $form->textwithpicto(price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"),$htmltext); + print $form->textwithpicto(price($product_fourn->fourn_unitprice * (1 - $product_fourn->fourn_remise_percent/100) + $product_fourn->fourn_unitcharges - $product_fourn->fourn_remise).' '.$langs->trans("HT"),$htmltext); } else print price($product_fourn->fourn_unitprice).' '.$langs->trans("HT"); } | ||