diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 06b8cecf7f3..f2cb8c440c2 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -890,7 +890,10 @@ if ($rowid > 0) { if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).''; if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { $prodtmp = new Product($db); - $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); + $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); + if ($result < 0) { + setEventMessage($prodtmp->error, 'errors'); + } print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product } print '
'; @@ -912,7 +915,10 @@ if ($rowid > 0) { if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).''; if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) { $prodtmp = new Product($db); - $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); + $result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS); + if ($result < 0) { + setEventMessage($prodtmp->error, 'errors'); + } print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product } print '
'; diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index ce734aadeb5..69fef80fd6b 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -419,8 +419,10 @@ class Documents extends DolibarrApi $object = new Product($this->db); $result = $object->fetch($id, $ref); - if (!$result) { + if ($result==0) { throw new RestException(404, 'Product not found'); + } elseif ($result<0) { + throw new RestException(500, 'Error while fetching object: '.$object->error); } $upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref); @@ -630,7 +632,7 @@ class Documents extends DolibarrApi } elseif ($result < 0) { - throw new RestException(500, 'Error while fetching object.'); + throw new RestException(500, 'Error while fetching object: '.$object->error); } } diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index f6dea256f6a..1ac908f361a 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -57,9 +57,11 @@ $thirdpartytmp = new Societe($db); if (GETPOST('submitproduct') && GETPOST('submitproduct')) { $action = ''; // We reset because we don't want to build doc - if (GETPOST('productid') > 0) - { - $producttmp->fetch(GETPOST('productid')); + if (GETPOST('productid') > 0) { + $result = $producttmp->fetch(GETPOST('productid')); + if ($result < 0) { + setEventMessage($producttmp->error, 'errors'); + } $forbarcode = $producttmp->barcode; $fk_barcode_type = $producttmp->barcode_type; diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 4a1c4e2f179..f6fe33aa932 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1004,7 +1004,11 @@ class BOM extends CommonObject foreach ($this->lines as &$line) { $tmpproduct = new Product($this->db); - $tmpproduct->fetch($line->fk_product); + $result= $tmpproduct->fetch($line->fk_product); + if ($result < 0) { + $this->error=$tmpproduct->error; + return -1; + } $line->unit_cost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp); if (empty($line->unit_cost)) { if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0) diff --git a/htdocs/bom/tpl/linkedobjectblock.tpl.php b/htdocs/bom/tpl/linkedobjectblock.tpl.php index d6b8ebf9a7c..45340577228 100644 --- a/htdocs/bom/tpl/linkedobjectblock.tpl.php +++ b/htdocs/bom/tpl/linkedobjectblock.tpl.php @@ -52,8 +52,15 @@ foreach ($linkedObjectBlock as $key => $objectlink) } echo ''; echo ''.$objectlink->getNomUrl(1).''; - $product_static->fetch($objectlink->fk_product); - echo ''.$product_static->getNomUrl(1).''; + + echo ''; + $result=$product_static->fetch($objectlink->fk_product); + if ($result<0) { + setEventMessage($product_static->error, 'errors'); + } elseif ($result>0) { + $product_static->getNomUrl(1); + } + print ''; echo ''.dol_print_date($objectlink->date_creation, 'day').''; echo ''; if ($user->rights->commande->lire) { diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 6f665a381df..0c0f084a230 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -971,7 +971,7 @@ if ($id > 0 || !empty($ref)) { // Discount print ''; - print ''; + print ''; print ''; // Save price diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 80301dcdc43..7e8796e44f6 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1724,6 +1724,9 @@ if ($action == 'create') $mode_reglement_id = GETPOST("mode_reglement_id"); } + $note_public = $object->getDefaultCreateValueFor('note_public', ((! empty($origin) && ! empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM))?$objectsrc->note_public:null)); + $note_private = $object->getDefaultCreateValueFor('note_private', ((! empty($origin) && ! empty($originid) && is_object($objectsrc) && !empty($conf->global->FACTUREFOURN_REUSE_NOTES_ON_CREATE_FROM))?$objectsrc->note_private:null)); + print '
'; print ''; print ''; @@ -2048,8 +2051,6 @@ if ($action == 'create') // Public note print ''.$langs->trans('NotePublic').''; print ''; - $note_public = $object->getDefaultCreateValueFor('note_public'); - if (empty($note_public))$note_public = $objectsrc->note_public; $doleditor = new DolEditor('note_public', (GETPOSTISSET('note_public') ?GETPOST('note_public', 'none') : $note_public), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); print ''; @@ -2059,9 +2060,6 @@ if ($action == 'create') // Private note print ''.$langs->trans('NotePrivate').''; print ''; - $note_private = $object->getDefaultCreateValueFor('note_private'); - if (empty($note_private))$note_private = $objectsrc->note_private; - $doleditor = new DolEditor('note_private', (GETPOSTISSET('note_private') ?GETPOST('note_private', 'none') : $note_private), '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%'); print $doleditor->Create(1); print ''; diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index c7d7dd95cb7..b755a388f5b 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -117,3 +117,5 @@ HideCategoryImages=Hide Category Images HideProductImages=Hide Product Images NumberOfLinesToShow=Number of lines of images to show DefineTablePlan=Define tables plan +GiftReceiptButton=Gift receipt button +GiftReceipt=Gift receipt diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 67e6e9e70f3..0327456615c 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2082,35 +2082,45 @@ if ($result > 0) $tmpcode = ''; if (!empty($modCodeProduct->code_auto)) $tmpcode = $modCodeProduct->getNextValue($object, $object->type); -// Define confirmation messages -$formquestionclone = array( - 'text' => $langs->trans("ConfirmClone"), - array('type' => 'text', 'name' => 'clone_ref', 'label' => $langs->trans("NewRefForClone"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf").' '.$object->ref : $tmpcode, 'size'=>24), - array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneContentProduct"), 'value' => 1), - array('type' => 'checkbox', 'name' => 'clone_categories', 'label' => $langs->trans("CloneCategoriesProduct"), 'value' => 1), -); -if (!empty($conf->global->PRODUIT_MULTIPRICES)) { - $formquestionclone[] = array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("CustomerPrices").')', 'value' => 0); -} -if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) -{ - $formquestionclone[] = array('type' => 'checkbox', 'name' => 'clone_composition', 'label' => $langs->trans('CloneCompositionProduct'), 'value' => 1); -} +$formconfirm=''; // Confirm delete product if (($action == 'delete' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) // Always output when not jmobile nor js { - print $form->formconfirm("card.php?id=".$object->id, $langs->trans("DeleteProduct"), $langs->trans("ConfirmDeleteProduct"), "confirm_delete", '', 0, "action-delete"); + $formconfirm = $form->formconfirm("card.php?id=".$object->id, $langs->trans("DeleteProduct"), $langs->trans("ConfirmDeleteProduct"), "confirm_delete", '', 0, "action-delete"); } // Clone confirmation if (($action == 'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile))) // Output when action = clone if jmobile or no js || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) // Always output when not jmobile nor js { - print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneProduct', $object->ref), 'confirm_clone', $formquestionclone, 'yes', 'action-clone', 350, 600); + // Define confirmation messages + $formquestionclone = array( + 'text' => $langs->trans("ConfirmClone"), + array('type' => 'text', 'name' => 'clone_ref', 'label' => $langs->trans("NewRefForClone"), 'value' => empty($tmpcode) ? $langs->trans("CopyOf").' '.$object->ref : $tmpcode, 'size'=>24), + array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneContentProduct"), 'value' => 1), + array('type' => 'checkbox', 'name' => 'clone_categories', 'label' => $langs->trans("CloneCategoriesProduct"), 'value' => 1), + ); + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { + $formquestionclone[] = array('type' => 'checkbox', 'name' => 'clone_prices', 'label' => $langs->trans("ClonePricesProduct").' ('.$langs->trans("CustomerPrices").')', 'value' => 0); + } + if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) + { + $formquestionclone[] = array('type' => 'checkbox', 'name' => 'clone_composition', 'label' => $langs->trans('CloneCompositionProduct'), 'value' => 1); + } + + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneProduct', $object->ref), 'confirm_clone', $formquestionclone, 'yes', 'action-clone', 350, 600); } +// Call Hook formConfirm +$parameters = array('formConfirm' => $formconfirm, 'object' => $object); +$reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook +if (empty($reshook)) $formconfirm .= $hookmanager->resPrint; +elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint; + +// Print form confirm +print $formconfirm; /* ************************************************************************** */ /* */ diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 07450eef805..33733a8901d 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2209,7 +2209,7 @@ class Product extends CommonObject } }*/ } else { - dol_print_error($this->db); + $this->error=$this->db->lasterror; return -1; } } @@ -2254,12 +2254,12 @@ class Product extends CommonObject } $this->prices_by_qty_list[0] = $resultat; } else { - dol_print_error($this->db); - return -1; + $this->error=$this->db->lasterror; + return -1; } } } else { - dol_print_error($this->db); + $this->error=$this->db->lasterror; return -1; } } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES) && empty($ignore_price_load)) // prices per customer and quantity @@ -2313,12 +2313,12 @@ class Product extends CommonObject } $this->prices_by_qty_list[$i] = $resultat; } else { - dol_print_error($this->db); + $this->error=$this->db->lasterror; return -1; } } } else { - dol_print_error($this->db); + $this->error=$this->db->lasterror; return -1; } } @@ -2345,7 +2345,7 @@ class Product extends CommonObject return 0; } } else { - dol_print_error($this->db); + $this->error=$this->db->lasterror; return -1; } } diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 3151df07507..15ee5c2e52b 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -654,8 +654,8 @@ if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $n $urlsource .= str_replace('&', '&', $param); $filedir = $diroutputmassaction; - $genallowed = $user->rights->mymodule->read; - $delallowed = $user->rights->mymodule->create; + $genallowed = $user->rights->stock->lire; + $delallowed = $user->rights->stock->creer; print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 535d4e68967..1efe6287c66 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -490,6 +490,66 @@ class Thirdparties extends DolibarrApi } $this->company->oldcopy = clone $this->company; return $this->company->delete($id); + } + + /** + * Set new price level for the given thirdparty + * + * @param int $id ID of thirdparty + * @param int $priceLevel Price level to apply to thirdparty + * @return object Thirdparty data without useless information + * + * @url PUT {id}/setpricelevel + * + * @throws RestException 400 Price level out of bounds + * @throws RestException 401 Access not allowed for your login + * @throws RestException 404 Thirdparty not found + * @throws RestException 500 Error fetching/setting price level + * @throws RestException 501 Request needs modules "Thirdparties" and "Products" and setting Multiprices activated + */ + public function setThirdpartyPriceLevel($id, $priceLevel) + { + global $conf; + + if (empty($conf->societe->enabled)) { + throw new RestException(501, 'Module "Thirdparties" needed for this request'); + } + + if (empty($conf->product->enabled)) { + throw new RestException(501, 'Module "Products" needed for this request'); + } + + if (empty($conf->global->PRODUIT_MULTIPRICES)) { + throw new RestException(501, 'Multiprices features activation needed for this request'); + } + + if ($priceLevel < 1 || $priceLevel > $conf->global->PRODUIT_MULTIPRICES_LIMIT) { + throw new RestException(400, 'Price level must be between 1 and ' . $conf->global->PRODUIT_MULTIPRICES_LIMIT); + } + + if (empty(DolibarrApiAccess::$user->rights->societe->creer)) { + throw new RestException(401, 'Access to thirdparty ' . $id . ' not allowed for login '. DolibarrApiAccess::$user->login); + } + + $result = $this->company->fetch($id); + if ($result < 0) { + throw new RestException(404, 'Thirdparty ' . $id . ' not found'); + } + + if (empty($result)) { + throw new RestException(500, 'Error fetching thirdparty ' . $id, array_merge(array($this->company->error), $this->company->errors)); + } + + if (empty(DolibarrApi::_checkAccessToResource('societe', $this->company->id))) { + throw new RestException(401, 'Access to thirdparty ' . $id . ' not allowed for login ' . DolibarrApiAccess::$user->login); + } + + $result = $this->company->set_price_level($priceLevel, DolibarrApiAccess::$user); + if ($result <= 0) { + throw new RestException(500, 'Error setting new price level for thirdparty ' . $id, array($this->company->db->lasterror())); + } + + return $this->_cleanObjectDatas($this->company); } /** diff --git a/htdocs/takepos/admin/setup.php b/htdocs/takepos/admin/setup.php index 830e5d203d3..22355c70d9d 100644 --- a/htdocs/takepos/admin/setup.php +++ b/htdocs/takepos/admin/setup.php @@ -365,6 +365,13 @@ print ''; print ajax_constantonoff("TAKEPOS_CONTROL_CASH_OPENING", array(), $conf->entity, 0, 0, 1, 0); print "\n"; +// Gift receipt +print ''; +print $langs->trans('GiftReceiptButton'); +print ''; +print ajax_constantonoff("TAKEPOS_GIFT_RECEIPT", array(), $conf->entity, 0, 0, 1, 0); +print "\n"; + // Numbering module //print ''; //print $langs->trans("BillsNumberingModule"); diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index c6b7bb2c734..aee36f9ddfc 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -597,6 +597,9 @@ if ($action == "valid" || $action == "history") $sectionwithinvoicelink .= ' '; } else { $sectionwithinvoicelink .= ' '; + if ($conf->global->TAKEPOS_GIFT_RECEIPT) { + $sectionwithinvoicelink .= '
'; + } } if ($conf->global->TAKEPOS_EMAIL_TEMPLATE_INVOICE > 0) { @@ -700,8 +703,8 @@ function SendTicket(id) $.colorbox({href:"send.php?facid="+id, width:"70%", height:"30%", transition:"none", iframe:"true", title:"trans("SendTicket"); ?>"}); } -function Print(id){ - $.colorbox({href:"receipt.php?facid="+id, width:"40%", height:"90%", transition:"none", iframe:"true", title:"trans("PrintTicket"); ?>"}); } diff --git a/htdocs/takepos/receipt.php b/htdocs/takepos/receipt.php index 1da92de8827..99000c278de 100644 --- a/htdocs/takepos/receipt.php +++ b/htdocs/takepos/receipt.php @@ -34,6 +34,8 @@ $place = (GETPOST('place', 'aZ09') ? GETPOST('place', 'aZ09') : 0); // $place is $facid = GETPOST('facid', 'int'); +$gift = GETPOST('gift', 'int'); + if (empty($user->rights->takepos->run)) { accessforbidden(); } @@ -125,8 +127,8 @@ if ($conf->global->TAKEPOS_SHOW_CUSTOMER) trans("Label"); ?> trans("Qty"); ?> - trans("Price"); ?> - trans("TotalTTC"); ?> + trans("Price"); ?> + trans("TotalTTC"); ?> @@ -140,8 +142,8 @@ if ($conf->global->TAKEPOS_SHOW_CUSTOMER) else echo $line->description; ?> qty; ?> - total_ttc / $line->qty, 'MT'), 1); ?> - total_ttc, 1); ?> + total_ttc / $line->qty, 'MT'), 1); ?> + total_ttc, 1); ?> global->TAKEPOS_SHOW_CUSTOMER)
- - + + global->TAKEPOS_TICKET_VAT_GROUPPED) { $vat_groups = array(); @@ -166,18 +168,18 @@ if ($conf->global->TAKEPOS_SHOW_CUSTOMER) foreach ($vat_groups as $key => $val) { ?> - - + + - + - +
trans("TotalHT"); ?>total_ht, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?>trans("TotalHT"); ?>total_ht, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?>
trans("VAT").' '.vatrate($key, 1); ?>currency)."\n"; ?>trans("VAT").' '.vatrate($key, 1); ?>currency)."\n"; ?>
trans("TotalVAT").''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?>trans("TotalVAT").''.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?>
trans("TotalTTC").''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?>trans("TotalTTC").''.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?>