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

Conflicts:
	htdocs/filefunc.inc.php
This commit is contained in:
Laurent Destailleur 2020-01-04 14:03:21 +01:00
commit b9e0f8999f
15 changed files with 354 additions and 189 deletions

View File

@ -1,5 +1,8 @@
# DOLIBARR ERP & CRM
![Downloads per day](https://img.shields.io/sourceforge/dw/dolibarr.svg)
![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg)
Dolibarr ERP & CRM est un logiciel moderne pour gérer votre activité (société, association, auto-entrepreneurs, artisans).
Il est simple d'utilisation et modulaire, vous permettant de n'activez que les fonctions dont vous avez besoin (contacts, fournisseurs, factures, commandes, stocks, agenda, ...).

View File

@ -1,10 +1,7 @@
# DOLIBARR ERP & CRM
![Downloads per day](https://img.shields.io/sourceforge/dw/dolibarr.svg)
|7|8|9|10|develop|
|----------|----------|----------|----------|----------|
|![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/7.0.svg)|![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/8.0.svg)|![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/9.0.svg)|![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/10.0.svg)|![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg)|
![Build status](https://img.shields.io/travis/Dolibarr/dolibarr/develop.svg)
Dolibarr ERP & CRM is a modern software package to manage your organization's activity (contacts, suppliers, invoices, orders, stocks, agenda…).

View File

@ -3747,18 +3747,24 @@ elseif ($id > 0 || !empty($ref))
$i++;
$close[$i]['code'] = 'badcustomer';
$i++;
$close[$i]['code'] = 'other';
$i++;
// Help
$i = 0;
$close[$i]['label'] = $langs->trans("HelpEscompte").'<br><br>'.$langs->trans("ConfirmClassifyPaidPartiallyReasonDiscountVatDesc");
$i++;
$close[$i]['label'] = $langs->trans("ConfirmClassifyPaidPartiallyReasonBadCustomerDesc");
$i++;
$close[$i]['label'] = $langs->trans("Other");
$i++;
// Texte
$i = 0;
$close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonDiscount", $resteapayer, $langs->trans("Currency".$conf->currency)), $close[$i]['label'], 1);
$i++;
$close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("ConfirmClassifyPaidPartiallyReasonBadCustomer", $resteapayer, $langs->trans("Currency".$conf->currency)), $close[$i]['label'], 1);
$i++;
$close[$i]['reason'] = $form->textwithpicto($langs->transnoentities("Other"), $close[$i]['label'], 1);
$i++;
// arrayreasons[code]=reason
foreach ($close as $key => $val) {
$arrayreasons[$close [$key]['code']] = $close[$key]['reason'];

View File

@ -124,10 +124,10 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_CLOSE','BOM disabled','Executed when a BOM is disabled','bom',652);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_REOPEN','BOM reopen','Executed when a BOM is re-open','bom',653);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_DELETE','BOM deleted','Executed when a BOM deleted','bom',654);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_VALIDATE','MO validated','Executed when a MO is validated','bom',660);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_PRODUCED','MO produced','Executed when a MO is produced','bom',661);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_DELETE','MO deleted','Executed when a MO is deleted','bom',662);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_CANCEL','MO canceled','Executed when a MO is canceled','bom',663);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_VALIDATE','MO validated','Executed when a MO is validated','bom',660);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_PRODUCED','MO produced','Executed when a MO is produced','bom',661);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_DELETE','MO deleted','Executed when a MO is deleted','bom',662);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_CANCEL','MO canceled','Executed when a MO is canceled','bom',663);
-- actions not enabled by default : they are excluded when we enable the module Agenda (except TASK_...)
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_CREATE','Task created','Executed when a project task is created','project',150);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_MODIFY','Task modified','Executed when a project task is modified','project',151);

View File

@ -59,6 +59,8 @@ ALTER TABLE llx_emailcollector_emailcollectoraction ADD COLUMN position integer
-- For v11
ALTER TABLE llx_product_price MODIFY COLUMN tva_tx double(6,3) DEFAULT 0 NOT NULL;
ALTER TABLE llx_facturedet MODIFY COLUMN situation_percent real DEFAULT 100;
UPDATE llx_facturedet SET situation_percent = 100 WHERE situation_percent IS NULL AND fk_prev_id IS NULL;
@ -520,10 +522,11 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_REOPEN','BOM reopen','Executed when a BOM is re-open','bom',653);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BOM_DELETE','BOM deleted','Executed when a BOM deleted','bom',654);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_VALIDATE','MO validated','Executed when a MO is validated','bom',660);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_PRODUCED','MO produced','Executed when a MO is produced','bom',661);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_DELETE','MO deleted','Executed when a MO is deleted','bom',662);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MO_CANCEL','MO canceled','Executed when a MO is canceled','bom',663);
DELETE FROM llx_c_action_trigger where code LIKE 'MO_%';
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_VALIDATE','MO validated','Executed when a MO is validated','bom',660);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_PRODUCED','MO produced','Executed when a MO is produced','bom',661);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_DELETE','MO deleted','Executed when a MO is deleted','bom',662);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('MRP_MO_CANCEL','MO canceled','Executed when a MO is canceled','bom',663);
ALTER TABLE llx_comment ADD COLUMN fk_user_modif integer DEFAULT NULL;

View File

@ -35,7 +35,7 @@ create table llx_product_price
price_min_ttc double(24,8) default NULL,
price_base_type varchar(3) DEFAULT 'HT',
default_vat_code varchar(10), -- Same code than into table llx_c_tva (but no constraints). Should be used in priority to find default vat, npr, localtaxes for product.
tva_tx double(6,3) NOT NULL,
tva_tx double(6,3) DEFAULT 0 NOT NULL, -- Used only when option PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL is on (not supported)
recuperableonly integer NOT NULL DEFAULT '0',
localtax1_tx double(6,3) DEFAULT 0,
localtax1_type varchar(10) NOT NULL DEFAULT '0',

View File

@ -110,9 +110,9 @@ BOM_UNVALIDATEInDolibarr=BOM unvalidated
BOM_CLOSEInDolibarr=BOM disabled
BOM_REOPENInDolibarr=BOM reopen
BOM_DELETEInDolibarr=BOM deleted
MO_VALIDATEInDolibarr=MO validated
MO_PRODUCEDInDolibarr=MO produced
MO_DELETEInDolibarr=MO deleted
MRP_MO_VALIDATEInDolibarr=MO validated
MRP_MO_PRODUCEDInDolibarr=MO produced
MRP_MO_DELETEInDolibarr=MO deleted
##### End agenda events #####
AgendaModelModule=Document templates for event
DateActionStart=Start date

View File

@ -223,6 +223,7 @@ ErrorSearchCriteriaTooSmall=Search criteria too small.
ErrorObjectMustHaveStatusActiveToBeDisabled=Objects must have status 'Active' to be disabled
ErrorObjectMustHaveStatusDraftOrDisabledToBeActivated=Objects must have status 'Draft' or 'Disabled' to be enabled
ErrorNoFieldWithAttributeShowoncombobox=No fields has property 'showoncombobox' into definition of object '%s'. No way to show the combolist.
ErrorFieldRequiredForProduct=Field '%s' is required for product %s
# Warnings
WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup.
WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user.

View File

@ -741,7 +741,7 @@ NotSupported=Not supported
RequiredField=Required field
Result=Result
ToTest=Test
ValidateBefore=Card must be validated before using this feature
ValidateBefore=Item must be validated before using this feature
Visibility=Visibility
Totalizable=Totalizable
TotalizableDesc=This field is totalizable in list

View File

@ -44,8 +44,8 @@ StatusMOProduced=Produced
QtyFrozen=Frozen Qty
QuantityFrozen=Frozen Quantity
QuantityConsumedInvariable=When this flag is set, the quantity consumed is always the value defined and is not relative to the quantity produced.
DisableStockChange=Disable stock change
DisableStockChangeHelp=When this flag is set, there is no stock change on this product, whatever is the quantity produced
DisableStockChange=Stock change disabled
DisableStockChangeHelp=When this flag is set, there is no stock change on this product, whatever is the quantity consumed
BomAndBomLines=Bills Of Material and lines
BOMLine=Line of BOM
WarehouseForProduction=Warehouse for production
@ -58,4 +58,8 @@ ConsumeAndProduceAll=Consume and Produce All
Manufactured=Manufactured
TheProductXIsAlreadyTheProductToProduce=The product to add is already the product to produce.
ForAQuantityOf1=For a quantity to produce of 1
ConfirmValidateMo=Are you sure you want to validate this Manufacturing Order?
ConfirmValidateMo=Are you sure you want to validate this Manufacturing Order?
ConfirmProductionDesc=By clicking on '%s', you will validate the consumption and/or production for the quantities set. This will also update the stock and record stock movements.
ProductionForRefAndDate=Production %s - %s
AutoCloseMO=Close automatically the Manufacturing Order if quantities to consume and to produce are reached
NoStockChangeOnServices=No stock change on services

View File

@ -505,7 +505,7 @@ class Mo extends CommonObject
}
/**
* Erase and update the line to produce
* Erase and update the line to produce.
*
* @param User $user User that modifies
* @return int <0 if KO, >0 if OK
@ -557,7 +557,11 @@ class Mo extends CommonObject
$moline = new MoLine($this->db);
$moline->fk_mo = $this->id;
$moline->qty = round($line->qty * $this->qty / $bom->efficiency, 2);
if ($line->qty_frozen) {
$moline->qty = $line->qty; // Qty to consume does not depends on quantity to produce
} else {
$moline->qty = round($line->qty * $this->qty / $bom->efficiency, 2);
}
if ($moline->qty <= 0) {
$error++;
$this->error = "BadValueForquantityToConsume";
@ -980,10 +984,16 @@ class Mo extends CommonObject
global $langs;
//$langs->load("mrp");
$this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft');
$this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Validated');
$this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Validated').' ('.$langs->trans("ToProduce").')';
$this->labelStatus[self::STATUS_INPROGRESS] = $langs->trans('InProgress');
$this->labelStatus[self::STATUS_PRODUCED] = $langs->trans('StatusMOProduced');
$this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Canceled');
$this->labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Draft');
$this->labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Validated');
$this->labelStatusShort[self::STATUS_INPROGRESS] = $langs->trans('InProgress');
$this->labelStatusShort[self::STATUS_PRODUCED] = $langs->trans('StatusMOProduced');
$this->labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Canceled');
}
$statusType = 'status'.$status;
@ -992,7 +1002,7 @@ class Mo extends CommonObject
if ($status == self::STATUS_PRODUCED) $statusType = 'status5';
if ($status == self::STATUS_CANCELED) $statusType = 'status6';
return dolGetStatus($this->labelStatus[$status], $this->labelStatus[$status], '', $statusType, $mode);
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
}
/**
@ -1448,6 +1458,24 @@ class MoLine extends CommonObjectLine
}
}
/**
* Get list of lines linked to current line for a defined role
*
* @param string $role Get lines linked to current line with the selected role ('consumed', 'produced', ...)
* @return array Array of lines
*/
public function fetchLinesLinked($role) {
$array = array();
$sql = 'SELECT rowid, qty ';
$sql .= $this->getFieldList();
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')';
else $sql .= ' WHERE 1 = 1';
return $array;
}
/**
* Update object into database
*

View File

@ -117,8 +117,6 @@ $upload_dir = $conf->mrp->multidir_output[isset($object->entity) ? $object->enti
/*
* Actions
*
* Put here all code to do according to value of "action" parameter
*/
$parameters = array();

View File

@ -47,11 +47,13 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
dol_include_once('/mrp/class/mo.class.php');
dol_include_once('/mrp/lib/mrp_mo.lib.php');
// Load translation files required by the page
$langs->loadLangs(array("mrp", "other"));
$langs->loadLangs(array("mrp", "stocks", "other"));
// Get parameters
$id = GETPOST('id', 'int');
@ -103,8 +105,6 @@ $permissiontoproduce = $permissiontoadd;
/*
* Actions
*
* Put here all code to do according to value of "action" parameter
*/
$parameters = array();
@ -120,7 +120,7 @@ if (empty($reshook))
if (empty($backtopage) || ($cancel && empty($id))) {
//var_dump($backurlforlist);exit;
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
else $backtopage = DOL_URL_ROOT.'/mrp/mo_card.php?id='.($id > 0 ? $id : '__ID__');
else $backtopage = DOL_URL_ROOT.'/mrp/mo_production.php?id='.($id > 0 ? $id : '__ID__');
}
$triggermodname = 'MRP_MO_MODIFY'; // Name of trigger action code to execute when we modify record
@ -150,6 +150,89 @@ if (empty($reshook))
{
$object->setProject(GETPOST('projectid', 'int'));
}
if ($action == 'confirm_consumeandproduceall') {
$db->begin();
// Process line to consume
foreach($object->lines as $line) {
if ($line->role == 'toconsume') {
$tmpproduct = new Product($db);
$tmpproduct->fetch($line->fk_product);
$i=1;
while (GETPOSTISSET('qty-'.$line->id.'-'.$i)) {
// Check warehouse is set if we should have to
if (GETPOST('idwarehouse-'.$line->id.'-'.$i)) {
if (! (GETPOST('idwarehouse-'.$line->id.'-'.$i) > 0)) {
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors');
$error++;
}
if ($tmpproduct->status_batch && (! GETPOST('batch-'.$line->id.'-'.$i))) {
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors');
$error++;
}
}
if (! $error) {
}
$i++;
}
}
}
// Process line to produce
foreach($object->lines as $line) {
if ($line->role == 'toproduce') {
$tmpproduct = new Product($db);
$tmpproduct->fetch($line->fk_product);
$i=1;
while (GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i)) {
// Check warehouse is set if we should have to
if (GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i)) {
if (! (GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) > 0)) {
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Warehouse"), $tmpproduct->ref), null, 'errors');
$error++;
}
if ($tmpproduct->status_batch && (! GETPOST('batchtoproduce-'.$line->id.'-'.$i))) {
$langs->load("errors");
setEventMessages($langs->trans("ErrorFieldRequiredForProduct", $langs->transnoentitiesnoconv("Batch"), $tmpproduct->ref), null, 'errors');
$error++;
}
}
if (! $error) {
}
$i++;
}
}
}
if (! $error) {
// Update status of MO
}
if ($error) {
$action = str_replace('confirm_', '', $action);
$db->rollback();
} else {
$db->commit();
}
}
}
@ -162,6 +245,7 @@ if (empty($reshook))
$form = new Form($db);
$formfile = new FormFile($db);
$formproject = new FormProjets($db);
$formproduct = new FormProduct($db);
llxHeader('', $langs->trans('Mo'), '');
@ -306,48 +390,86 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
dol_fiche_end();
print '<div class="tabsAction">';
$parameters = array();
// Note that $action and $object may be modified by hook
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action);
if (empty($reshook)) {
// Consume
if (! in_array($action, array('consume', 'produce', 'consumeandproduceall')))
{
print '<div class="tabsAction">';
if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) {
if ($permissiontoproduce) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=consume">'.$langs->trans('Consume').'</a>';
$parameters = array();
// Note that $action and $object may be modified by hook
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action);
if (empty($reshook)) {
// Consume
if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) {
if ($permissiontoproduce) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=consume">'.$langs->trans('Consume').'</a>';
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('Consume').'</a>';
}
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('Consume').'</a>';
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateBefore").'">'.$langs->trans('Consume').'</a>';
}
// Produce
if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) {
if ($permissiontoproduce) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=produce">'.$langs->trans('Produce').'</a>';
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('Produce').'</a>';
}
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateBefore").'">'.$langs->trans('Produce').'</a>';
}
// ConsumeAndProduceAll
if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) {
if ($permissiontoproduce) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=consumeandproduceall">'.$langs->trans('ConsumeAndProduceAll').'</a>';
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('ConsumeAndProduceAll').'</a>';
}
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateBefore").'">'.$langs->trans('ConsumeAndProduceAll').'</a>';
}
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateFirst").'">'.$langs->trans('Consume').'</a>';
}
// Produce
if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) {
if ($permissiontoproduce) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=produce">'.$langs->trans('Produce').'</a>';
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('Produce').'</a>';
}
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateFirst").'">'.$langs->trans('Produce').'</a>';
}
// ConsumeAndProduceAll
if ($object->status == Mo::STATUS_VALIDATED || $object->status == Mo::STATUS_INPROGRESS) {
if ($permissiontoproduce) {
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=consumeandproduceall">'.$langs->trans('ConsumeAndProduceAll').'</a>';
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans('ConsumeAndProduceAll').'</a>';
}
} else {
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("ValidateFirst").'">'.$langs->trans('ConsumeAndProduceAll').'</a>';
}
print '</div>';
}
print '</div>';
if (in_array($action, array('consume', 'produce', 'consumeandproduceall')))
{
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="confirm_'.$action.'">';
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
print '<input type="hidden" name="id" value="'.$id.'">';
if ($action == 'consume')
{
print $langs->trans("FeatureNotYetAvailable");
}
if ($action == 'produce')
{
print $langs->trans("FeatureNotYetAvailable");
}
if ($action == 'consumeandproduceall')
{
$defaultstockmovementlabel = $langs->trans("ProductionForRefAndDate", $object->ref, dol_print_date(dol_now(), 'standard'));
$defaultstockmovementcode = $object->ref.'_'.dol_print_date(dol_now(), 'dayhourlog');
print '<div class="center">';
print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("ConfirmProductionDesc", $langs->transnoentitiesnoconv("Confirm")).'<br></span>';
print $langs->trans("MovementLabel").': <input type="text" class="minwidth300" name="label" value="'.$defaultstockmovementlabel.'"> &nbsp; ';
print $langs->trans("InventoryCode").': <input type="text" class="minwidth200" name="inventorycode" value="'.$defaultstockmovementcode.'"><br><br>';
print '<input type="checkbox" name="autoclose" value="1" checked="checked"> '.$langs->trans("AutoCloseMO").'<br>';
print '<input class="button" type="submit" value="'.$langs->trans("Confirm").'" name="confirm">';
print ' &nbsp; ';
print '<input class="button" type="submit" value="'.$langs->trans("Cancel").'" name="cancel">';
print '</div>';
print '<br>';
}
}
/*
@ -360,17 +482,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
//$result = $object->getLinesArray();
$object->fetchLines();
print ' <form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '#line_'.GETPOST('lineid', 'int')).'" method="POST">
<input type="hidden" name="token" value="' . $_SESSION ['newtoken'].'">
<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
<input type="hidden" name="mode" value="">
<input type="hidden" name="id" value="' . $object->id.'">
';
if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
}
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="clearboth"></div>';
@ -384,27 +495,77 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td>'.$langs->trans("Product").'</td>';
print '<td>'.$langs->trans("Qty").'</td>';
print '<td>'.$langs->trans("QtyAlreadyConsumed").'</td>';
/*print '<td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("Batch").'</td>';*/
print '<td></td>';
if ($conf->productbatch->enabled) {
print '<td>';
if ($action == 'consumeandproduceall') print $langs->trans("Batch");
print '</td>';
}
print '</tr>';
if (!empty($object->lines))
{
foreach($object->lines as $line) {
if ($line->role == 'toconsume') {
print '<tr>';
$tmpproduct = new Product($db);
$tmpproduct->fetch($line->fk_product);
print '<td>'.$tmpproduct->getNomUrl(1).'</td>';
print '<td>'.$line->qty.'</td>';
$arrayoflines = $line->fetchLinesLinked('consumed');
$alreadyconsumed = 0;
foreach($arrayoflines as $line2) {
$alreadyconsumed += $line2->qty;
}
print '<tr>';
print '<td>'.$tmpproduct->getNomUrl(1).'</td>';
print '<td>';
$help = '';
if ($line->qty_frozen) $help.=($help ? '<br>' : '').'<strong>'.$langs->trans("QuantityFrozen").'</strong>: '.yn(1).' ('.$langs->trans("QuantityConsumedInvariable").')';
if ($line->disable_stock_change) $help.=($help ? '<br>' : '').'<strong>'.$langs->trans("DisableStockChange").'</strong>: '.yn(1).' ('.(($tmpproduct->type == Product::TYPE_SERVICE && empty($conf->global->STOCK_SUPPORTS_SERVICES)) ? $langs->trans("NoStockChangeOnServices") : $langs->trans("DisableStockChangeHelp")).')';
if ($help) {
print $form->textwithpicto($line->qty, $help);
} else {
print $line->qty;
}
print '</td>';
print '<td>'.$alreadyconsumed.'</td>';
/*print '<td>'.'</td>';
print '<td>'.'</td>';*/
print '<td></td>'; // Warehouse
if ($conf->productbatch->enabled) {
print '<td></td>'; // Lot
}
print '</tr>';
// Show detailed of already consumed
// Show detailed of already consumed with js code to collapse
//$arrayoflines = $line->fetchLinesLinked('consumed');
if ($action == 'consumeandproduceall') {
$i = 1;
print '<tr>';
print '<td>'.$langs->trans("ToConsume").'</td>';
print '<td><input type="text" class="width50" name="qty-'.$line->id.'-'.$i.'" value="'.(GETPOSTISSET('qty-'.$line->id.'-'.$i) ? GETPOST('qty-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyconsumed)).'"></td>';
print '<td></td>';
print '<td>';
if ($tmpproduct->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
if (empty($line->disable_stock_change)) {
$preselected = (GETPOSTISSET('idwarehouse-'.$line->id.'-'.$i) ? GETPOST('idwarehouse-'.$line->id.'-'.$i) : 'ifone');
print $formproduct->selectWarehouses($preselected, 'idwarehouse-'.$line->id.'-'.$i, '', 1, 0, $line->fk_product, '', 1);
} else {
print '<span class="opacitymedium">'.$langs->trans("DisableStockChange").'</span>';
}
} else {
print '<span class="opacitymedium">'.$langs->trans("NoStockChangeOnServices").'</span>';
}
print '</td>';
if ($conf->productbatch->enabled) {
print '<td>';
if ($tmpproduct->status_batch) {
$preselected = (GETPOSTISSET('batch-'.$line->id.'-'.$i) ? GETPOST('batch-'.$line->id.'-'.$i) : '');
print '<input type="text" class="width50" name="batch-'.$line->id.'-'.$i.'" value="'.$preselected.'">';
}
print '</td>';
}
print '</tr>';
}
}
}
}
@ -443,27 +604,58 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '<td>'.$langs->trans("Product").'</td>';
print '<td>'.$langs->trans("Qty").'</td>';
print '<td>'.$langs->trans("QtyAlreadyProduced").'</td>';
/*print '<td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("Batch").'</td>';*/
print '<td></td>';
if ($conf->productbatch->enabled) {
print '<td>';
if ($action == 'consumeandproduceall') print $langs->trans("Batch");
print '</td>';
}
print '</tr>';
if (!empty($object->lines))
{
foreach($object->lines as $line) {
if ($line->role == 'toproduce') {
print '<tr>';
$tmpproduct = new Product($db);
$tmpproduct->fetch($line->fk_product);
$arrayoflines = $line->fetchLinesLinked('produced');
$alreadyproduced = 0;
foreach($arrayoflines as $line2) {
$alreadyproduced += $line2->qty;
}
print '<tr>';
print '<td>'.$tmpproduct->getNomUrl(1).'</td>';
print '<td>'.$line->qty.'</td>';
$alreadyconsumed = 0;
print '<td>'.$alreadyconsumed.'</td>';
/*print '<td>'.'</td>';
print '<td>'.'</td>';*/
print '<td>'.$alreadyproduced.'</td>';
print '<td></td>'; // Warehouse
if ($conf->productbatch->enabled) {
print '<td></td>'; // Lot
}
print '</tr>';
// Show detailed of already consumed
//$arrayoflines = $line->fetchLinesLinked('consumed');
if ($action == 'consumeandproduceall') {
print '<tr>';
print '<td>'.$langs->trans("ToProduce").'</td>';
print '<td><input type="text" class="width50" name="qtytoproduce-'.$line->id.'-'.$i.'" value="'.(GETPOSTISSET('qtytoproduce-'.$line->id.'-'.$i) ? GETPOST('qtytoproduce-'.$line->id.'-'.$i) : max(0, $line->qty - $alreadyproduced)).'"></td>';
print '<td></td>';
print '<td>';
if ($tmpproduct->type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
$preselected = (GETPOSTISSET('idwarehousetoproduce-'.$line->id.'-'.$i) ? GETPOST('idwarehousetoproduce-'.$line->id.'-'.$i) : ($object->fk_warehouse > 0 ? $object->fk_warehouse : 'ifone'));
print $formproduct->selectWarehouses($preselected, 'idwarehousetoproduce-'.$line->id.'-'.$i, '', 1, 0, $line->fk_product, '', 1);
}
print '</td>';
if ($conf->productbatch->enabled) {
print '<td>';
if ($tmpproduct->status_batch) {
$preselected = (GETPOSTISSET('batchtoproduce-'.$line->id.'-'.$i) ? GETPOST('batchtoproduce-'.$line->id.'-'.$i) : '');
print '<input type="text" class="width50" name="batchtoproduce-'.$line->id.'-'.$i.'" value="'.$preselected.'">';
}
print '</td>';
}
print '</tr>';
}
}
}
}
@ -473,66 +665,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</div>';
print '</div>';
print "</form>\n";
}
// Buttons for actions
/*
if ($action != 'presend' && $action != 'editline') {
print '<div class="tabsAction">'."\n";
$parameters=array();
$reshook=$hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{
// Send
print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'."\n";
// Modify
if (! empty($user->rights->mrp->write))
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'."\n";
}
else
{
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
}
// Clone
if (! empty($user->rights->mrp->write))
{
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;socid=' . $object->socid . '&amp;action=clone&amp;object=order">' . $langs->trans("ToClone") . '</a></div>';
}
// Delete (need delete permission, or if draft, just need create/modify permission)
if (! empty($user->rights->mrp->delete) || (! empty($object->fields['status']) && $object->status == $object::STATUS_DRAFT && ! empty($user->rights->mrp->write)))
{
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'."\n";
}
else
{
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
}
}
print '</div>'."\n";
}*/
if ($action != 'presend')
if (in_array($action, array('consume', 'produce', 'consumeandproduceall')))
{
print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
print '</div></div></div>';
print "</form>\n";
}
}

View File

@ -58,6 +58,10 @@ class CompanyPaymentMode extends CommonObject
public $picto = 'generic';
const STATUS_ENABLED = 1;
const STATUS_CANCELED = 0;
/**
* 'type' if the field format.
* 'label' the translation key.
@ -477,9 +481,9 @@ class CompanyPaymentMode extends CommonObject
}
/**
* Retourne le libelle du status d'un user (actif, inactif)
* Return label of the status
*
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label of status
*/
public function getLibStatut($mode = 0)
@ -495,47 +499,29 @@ class CompanyPaymentMode extends CommonObject
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
* @return string Label of status
*/
public static function LibStatut($status, $mode = 0)
public function LibStatut($status, $mode = 0)
{
// phpcs:enable
global $langs;
// phpcs:enable
if (empty($this->labelStatus) || empty($this->labelStatusShort))
{
global $langs;
//$langs->load("mymodule");
$this->labelStatus[self::STATUS_ENABLED] = $langs->trans('Enabled');
$this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Disabled');
$this->labelStatusShort[self::STATUS_ENABLED] = $langs->trans('Enabled');
$this->labelStatusShort[self::STATUS_CANCELED] = $langs->trans('Disabled');
}
if ($mode == 0 || $mode == 1)
{
if ($status == 1) return $langs->trans('Enabled');
elseif ($status == 0) return $langs->trans('Disabled');
}
elseif ($mode == 2)
{
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
}
elseif ($mode == 3)
{
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
}
elseif ($mode == 4)
{
if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
}
elseif ($mode == 5)
{
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
}
elseif ($mode == 6)
{
if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
}
$statusType = 'status5';
if ($status == self::STATUS_ENABLED) $statusType = 'status4';
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
}
/**
* Charge les informations d'ordre info dans l'objet commande
* Load the info information in the object
*
* @param int $id Id of order
* @param int $id Id of object
* @return void
*/
public function info($id)

View File

@ -1635,9 +1635,9 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer)
dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<div class="div-table-responsive-no-min">';
print '<table class="border centpercent">';
print '<tr><td class="titlefield fieldrequired">'.$langs->trans("LabelRIB").'</td>';
@ -1697,11 +1697,13 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer)
print "</textarea></td></tr>";
print '</table>';
print '</div>';
if ($conf->prelevement->enabled)
{
print '<br>';
print '<div class="div-table-responsive-no-min">';
print '<table class="border centpercent">';
if (empty($companybankaccount->rum)) $companybankaccount->rum = $prelevement->buildRumNumber($object->code_client, $companybankaccount->datec, $companybankaccount->id);
@ -1719,9 +1721,9 @@ if ($socid && $action == 'edit' && $user->rights->societe->creer)
print '</td></tr>';
print '</table>';
print '</div>';
}
print '</div>';
dol_fiche_end();