Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur
2020-08-02 15:53:48 +02:00
15 changed files with 156 additions and 53 deletions

View File

@@ -890,7 +890,10 @@ if ($rowid > 0) {
if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. <span class="opacitymedium">'.$langs->trans("NoVatOnSubscription", 0).'</span>';
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 '<br>';
@@ -912,7 +915,10 @@ if ($rowid > 0) {
if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. <span class="opacitymedium">'.$langs->trans("NoVatOnSubscription", 0).'</span>';
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 '<br>';

View File

@@ -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);
}
}

View File

@@ -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;

View File

@@ -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)

View File

@@ -52,8 +52,15 @@ foreach ($linkedObjectBlock as $key => $objectlink)
}
echo '</td>';
echo '<td class="linkedcol-name nowraponall" >'.$objectlink->getNomUrl(1).'</td>';
$product_static->fetch($objectlink->fk_product);
echo '<td class="linkedcol-ref" align="center">'.$product_static->getNomUrl(1).'</td>';
echo '<td class="linkedcol-ref" align="center">';
$result=$product_static->fetch($objectlink->fk_product);
if ($result<0) {
setEventMessage($product_static->error, 'errors');
} elseif ($result>0) {
$product_static->getNomUrl(1);
}
print '</td>';
echo '<td class="linkedcol-date" align="center">'.dol_print_date($objectlink->date_creation, 'day').'</td>';
echo '<td class="linkedcol-amount right">';
if ($user->rights->commande->lire) {

View File

@@ -971,7 +971,7 @@ if ($id > 0 || !empty($ref)) {
// Discount
print '<td class="right">';
print '<input id="pu'.$suffix.'" name="dto'.$suffix.'" type="text" size="8" value="'.(GETPOST('dto'.$suffix) != '' ? GETPOST('dto'.$suffix) : '').'">';
print '<input id="dto' . $suffix . '" name="dto' . $suffix . '" type="text" size="8" value="' . (GETPOST('dto' . $suffix) != '' ? GETPOST('dto' . $suffix) : '') . '">';
print '</td>';
// Save price

View File

@@ -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 '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="add">';
@@ -2048,8 +2051,6 @@ if ($action == 'create')
// Public note
print '<tr><td>'.$langs->trans('NotePublic').'</td>';
print '<td>';
$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 '</td>';
@@ -2059,9 +2060,6 @@ if ($action == 'create')
// Private note
print '<tr><td>'.$langs->trans('NotePrivate').'</td>';
print '<td>';
$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 '</td>';

View File

@@ -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

View File

@@ -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;
/* ************************************************************************** */
/* */

View File

@@ -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;
}
}

View File

@@ -654,8 +654,8 @@ if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $n
$urlsource .= str_replace('&amp;', '&', $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);
}

View File

@@ -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);
}
/**

View File

@@ -365,6 +365,13 @@ print '<td colspan="2">';
print ajax_constantonoff("TAKEPOS_CONTROL_CASH_OPENING", array(), $conf->entity, 0, 0, 1, 0);
print "</td></tr>\n";
// Gift receipt
print '<tr class="oddeven"><td>';
print $langs->trans('GiftReceiptButton');
print '<td colspan="2">';
print ajax_constantonoff("TAKEPOS_GIFT_RECEIPT", array(), $conf->entity, 0, 0, 1, 0);
print "</td></tr>\n";
// Numbering module
//print '<tr class="oddeven"><td>';
//print $langs->trans("BillsNumberingModule");

View File

@@ -597,6 +597,9 @@ if ($action == "valid" || $action == "history")
$sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="DolibarrTakeposPrinting('.$placeid.');">'.$langs->trans('PrintTicket').'</button>';
} else {
$sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="Print('.$placeid.');">'.$langs->trans('PrintTicket').'</button>';
if ($conf->global->TAKEPOS_GIFT_RECEIPT) {
$sectionwithinvoicelink .= ' <button id="buttonprint" type="button" onclick="Print('.$placeid.', 1);">'.$langs->trans('GiftReceipt').'</button><br>';
}
}
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:"<?php echo $langs->trans("SendTicket"); ?>"});
}
function Print(id){
$.colorbox({href:"receipt.php?facid="+id, width:"40%", height:"90%", transition:"none", iframe:"true", title:"<?php
function Print(id, gift){
$.colorbox({href:"receipt.php?facid="+id+"&gift="+gift, width:"40%", height:"90%", transition:"none", iframe:"true", title:"<?php
echo $langs->trans("PrintTicket"); ?>"});
}

View File

@@ -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)
<tr>
<th class="center"><?php print $langs->trans("Label"); ?></th>
<th class="right"><?php print $langs->trans("Qty"); ?></th>
<th class="right"><?php print $langs->trans("Price"); ?></th>
<th class="right"><?php print $langs->trans("TotalTTC"); ?></th>
<th class="right"><?php if ($gift!=1) print $langs->trans("Price"); ?></th>
<th class="right"><?php if ($gift!=1) print $langs->trans("TotalTTC"); ?></th>
</tr>
</thead>
<tbody>
@@ -140,8 +142,8 @@ if ($conf->global->TAKEPOS_SHOW_CUSTOMER)
else echo $line->description; ?>
</td>
<td class="right"><?php echo $line->qty; ?></td>
<td class="right"><?php echo price(price2num($line->total_ttc / $line->qty, 'MT'), 1); ?></td>
<td class="right"><?php echo price($line->total_ttc, 1); ?></td>
<td class="right"><?php if ($gift!=1) echo price(price2num($line->total_ttc / $line->qty, 'MT'), 1); ?></td>
<td class="right"><?php if ($gift!=1) echo price($line->total_ttc, 1); ?></td>
</tr>
<?php
}
@@ -151,8 +153,8 @@ if ($conf->global->TAKEPOS_SHOW_CUSTOMER)
<br>
<table class="right">
<tr>
<th class="right"><?php echo $langs->trans("TotalHT"); ?></th>
<td class="right"><?php echo price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td>
<th class="right"><?php if ($gift!=1) echo $langs->trans("TotalHT"); ?></th>
<td class="right"><?php if ($gift!=1) echo price($object->total_ht, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td>
</tr>
<?php if ($conf->global->TAKEPOS_TICKET_VAT_GROUPPED) {
$vat_groups = array();
@@ -166,18 +168,18 @@ if ($conf->global->TAKEPOS_SHOW_CUSTOMER)
foreach ($vat_groups as $key => $val) {
?>
<tr>
<th align="right"><?php echo $langs->trans("VAT").' '.vatrate($key, 1); ?></th>
<td align="right"><?php echo price($val, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td>
<th align="right"><?php if ($gift!=1) echo $langs->trans("VAT").' '.vatrate($key, 1); ?></th>
<td align="right"><?php if ($gift!=1) echo price($val, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td>
</tr>
<?php
}
} else { ?>
<tr>
<th class="right"><?php echo $langs->trans("TotalVAT").'</th><td class="right">'.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td>
<th class="right"><?php if ($gift!=1) echo $langs->trans("TotalVAT").'</th><td class="right">'.price($object->total_tva, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td>
</tr>
<?php } ?>
<tr>
<th class="right"><?php echo ''.$langs->trans("TotalTTC").'</th><td class="right">'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td>
<th class="right"><?php if ($gift!=1) echo ''.$langs->trans("TotalTTC").'</th><td class="right">'.price($object->total_ttc, 1, '', 1, - 1, - 1, $conf->currency)."\n"; ?></td>
</tr>
</table>
<div style="border-top-style: double;">