';
// Label
diff --git a/htdocs/core/actions_linkedfiles.inc.php b/htdocs/core/actions_linkedfiles.inc.php
index 7090b71c773..2542cf23268 100644
--- a/htdocs/core/actions_linkedfiles.inc.php
+++ b/htdocs/core/actions_linkedfiles.inc.php
@@ -52,15 +52,16 @@ if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC))
{
// Define if we have to generate thumbs or not
$generatethumbs = 1;
- if (GETPOST('section_dir')) $generatethumbs = 0;
+ if (GETPOST('section_dir', 'alpha')) $generatethumbs = 0;
+ $allowoverwrite = (GETPOST('overwritefile', 'int') ? 1 : 0);
if (!empty($upload_dirold) && !empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
{
- $result = dol_add_file_process($upload_dirold, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs);
+ $result = dol_add_file_process($upload_dirold, $allowoverwrite, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs);
}
elseif (!empty($upload_dir))
{
- $result = dol_add_file_process($upload_dir, 0, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs);
+ $result = dol_add_file_process($upload_dir, $allowoverwrite, 1, 'userfile', GETPOST('savingdocmask', 'alpha'), null, '', $generatethumbs);
}
}
}
@@ -145,12 +146,13 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
if (is_object($object) && $object->id > 0) {
if ($backtopage) {
- header('Location: '.$backtopage);
+ header('Location: '.$backtopage);
exit;
}
else
{
- header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(GETPOST('section_dir', 'alpha') ? '§ion_dir='.urlencode(GETPOST('section_dir', 'alpha')) : '').(!empty($withproject) ? '&withproject=1' : ''));
+ $tmpurl = $_SERVER["PHP_SELF"].'?id='.$object->id.(GETPOST('section_dir', 'alpha') ? '§ion_dir='.urlencode(GETPOST('section_dir', 'alpha')) : '').(!empty($withproject) ? '&withproject=1' : '');
+ header('Location: '.$tmpurl);
exit;
}
}
diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php
index a9a7df300c3..31d0b449d5b 100644
--- a/htdocs/core/ajax/ajaxdirpreview.php
+++ b/htdocs/core/ajax/ajaxdirpreview.php
@@ -356,10 +356,12 @@ if ($useajax || $action == 'delete')
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
$useglobalvars = 1;
$form = new Form($db);
- $formquestion['urlfile'] = array('type'=>'hidden', 'value'=>$urlfile, 'name'=>'urlfile'); // We must always put field, even if empty because it is fille by javascript later
- $formquestion['section'] = array('type'=>'hidden', 'value'=>$section, 'name'=>'section'); // We must always put field, even if empty because it is fille by javascript later
- $formquestion['section_id'] = array('type'=>'hidden', 'value'=>$section_id, 'name'=>'section_id'); // We must always put field, even if empty because it is fille by javascript later
- $formquestion['section_dir'] = array('type'=>'hidden', 'value'=>$section_dir, 'name'=>'section_dir'); // We must always put field, even if empty because it is fille by javascript later
+ $formquestion['urlfile'] = array('type'=>'hidden', 'value'=>$urlfile, 'name'=>'urlfile'); // We must always put field, even if empty because it is filled by javascript later
+ $formquestion['section'] = array('type'=>'hidden', 'value'=>$section, 'name'=>'section'); // We must always put field, even if empty because it is filled by javascript later
+ $formquestion['section_id'] = array('type'=>'hidden', 'value'=>$section_id, 'name'=>'section_id'); // We must always put field, even if empty because it is filled by javascript later
+ $formquestion['section_dir'] = array('type'=>'hidden', 'value'=>$section_dir, 'name'=>'section_dir'); // We must always put field, even if empty because it is filled by javascript later
+ $formquestion['sortfield'] = array('type'=>'hidden', 'value'=>$sortfield, 'name'=>'sortfield'); // We must always put field, even if empty because it is filled by javascript later
+ $formquestion['sortorder'] = array('type'=>'hidden', 'value'=>$sortorder, 'name'=>'sortorder'); // We must always put field, even if empty because it is filled by javascript later
if (!empty($action) && $action == 'file_manager') $formquestion['file_manager'] = array('type'=>'hidden', 'value'=>1, 'name'=>'file_manager');
if (!empty($websitekey)) $formquestion['website'] = array('type'=>'hidden', 'value'=>$websitekey, 'name'=>'website');
if (!empty($pageid) && $pageid > 0) $formquestion['pageid'] = array('type'=>'hidden', 'value'=>$pageid, 'name'=>'pageid');
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 4b94f87c65f..f9c3e260e6f 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -575,7 +575,7 @@ abstract class CommonObject
{
$return = '
'."\n";
- $openedDashBoard .= ' '."\n";
+ $openedDashBoard .= ' '."\n";
$openedDashBoard .= ' '."\n";
// Show the span for the total of record
@@ -923,6 +926,7 @@ if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS))
}
if (!empty($boxstatFromHook) || !empty($boxstatItems)) {
+ $boxstat .= ''."\n";
$boxstat .= '
';
$boxstat .= '
';
$boxstat .= '
';
diff --git a/htdocs/install/check.php b/htdocs/install/check.php
index b4de3cebb66..95e3082cb56 100644
--- a/htdocs/install/check.php
+++ b/htdocs/install/check.php
@@ -557,7 +557,7 @@ else
}
if ($disabled)
{
- $choice .= ''.$langs->trans("NotYetAvailable").'';
+ $choice .= ''.$langs->trans("NotYetAvailable").'';
}
else
{
diff --git a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql
index 91361d76ec6..681731e27a5 100644
--- a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql
+++ b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql
@@ -45,6 +45,11 @@ UPDATE llx_accounting_system SET fk_country = NULL, active = 0 WHERE pcg_version
-- For v12
+
+-- Delete an old index that is duplicated
+-- VMYSQL4.1 DROP INDEX ix_fk_product_stock on llx_product_batch;
+-- VPGSQL8.2 DROP INDEX ix_fk_product_stock
+
DELETE FROM llx_menu where module='supplier_proposal';
UPDATE llx_website SET lang = 'en' WHERE lang like 'en_%';
@@ -200,6 +205,8 @@ DELETE FROM llx_const WHERE name = __ENCRYPT('DONATION_ART885')__;
ALTER TABLE llx_extrafields MODIFY COLUMN printable integer DEFAULT 0;
ALTER TABLE llx_extrafields ADD COLUMN printable integer DEFAULT 0;
+UPDATE llx_const SET name = 'INVOICE_USE_RETAINED_WARRANTY' WHERE name = 'INVOICE_USE_SITUATION_RETAINED_WARRANTY';
+
ALTER TABLE llx_accounting_account DROP COLUMN pcg_subtype;
ALTER TABLE llx_product ADD COLUMN accountancy_code_buy_intra varchar(32) AFTER accountancy_code_buy;
@@ -241,3 +248,5 @@ ALTER TABLE llx_categorie ADD COLUMN date_creation datetime;
ALTER TABLE llx_categorie ADD COLUMN tms timestamp;
ALTER TABLE llx_categorie ADD COLUMN fk_user_creat integer;
ALTER TABLE llx_categorie ADD COLUMN fk_user_modif integer;
+
+ALTER TABLE llx_commandedet ADD CONSTRAINT fk_commandedet_fk_commandefourndet FOREIGN KEY (fk_commandefourndet) REFERENCES llx_commande_fournisseurdet (rowid);
diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql
index 65752a542ca..5727b946bcb 100644
--- a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql
+++ b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql
@@ -216,10 +216,6 @@ ALTER TABLE llx_expeditiondet_batch ADD INDEX idx_fk_expeditiondet (fk_expeditio
ALTER TABLE llx_expeditiondet_batch ADD CONSTRAINT fk_expeditiondet_batch_fk_expeditiondet FOREIGN KEY (fk_expeditiondet) REFERENCES llx_expeditiondet(rowid);
-ALTER TABLE llx_product_batch ADD INDEX ix_fk_product_stock (fk_product_stock);
-ALTER TABLE llx_product_batch ADD CONSTRAINT fk_product_batch_fk_product_stock FOREIGN KEY (fk_product_stock) REFERENCES llx_product_stock (rowid);
-
-
-- New 1074 : Stock mouvement link to origin
ALTER TABLE llx_stock_mouvement ADD fk_origin integer;
ALTER TABLE llx_stock_mouvement ADD origintype VARCHAR(32);
diff --git a/htdocs/install/mysql/tables/llx_commandedet.key.sql b/htdocs/install/mysql/tables/llx_commandedet.key.sql
index bba65d62aa0..a609294a363 100644
--- a/htdocs/install/mysql/tables/llx_commandedet.key.sql
+++ b/htdocs/install/mysql/tables/llx_commandedet.key.sql
@@ -25,3 +25,8 @@ ALTER TABLE llx_commandedet ADD INDEX idx_commandedet_fk_product (fk_product);
ALTER TABLE llx_commandedet ADD CONSTRAINT fk_commandedet_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
ALTER TABLE llx_commandedet ADD CONSTRAINT fk_commandedet_fk_commande FOREIGN KEY (fk_commande) REFERENCES llx_commande (rowid);
+ALTER TABLE llx_commandedet ADD CONSTRAINT fk_commandedet_fk_commandefourndet FOREIGN KEY (fk_commandefourndet) REFERENCES llx_commande_fournisseurdet (rowid);
+--ALTER TABLE llx_commandedet ADD CONSTRAINT fk_commandedet_fk_multicurrency FOREIGN KEY (fk_multicurrency) REFERENCES llx_multicurrency (rowid);
+--ALTER TABLE llx_commandedet ADD CONSTRAINT fk_commandedet_fk_product_fournisseur_price FOREIGN KEY (fk_product_fournisseur_price) REFERENCES llx_product_fournisseur_price (rowid);
+--ALTER TABLE llx_commandedet ADD CONSTRAINT fk_commandedet_fk_remise_except FOREIGN KEY (fk_remise_except) REFERENCES llx_societe_remise_except (rowid);
+
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index 1293a51c193..ab26114d905 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -219,7 +219,10 @@ ShowInvoiceSituation=Show situation invoice
UseSituationInvoices=Allow situation invoice
UseSituationInvoicesCreditNote=Allow situation invoice credit note
Retainedwarranty=Retained warranty
+AllowedInvoiceForRetainedWarranty=Retained warranty usable on the following types of invoices
RetainedwarrantyDefaultPercent=Retained warranty default percent
+RetainedwarrantyOnlyForSituation=Make "retained warranty" available only for situation invoices
+RetainedwarrantyOnlyForSituationFinal=On situation invoices the global "retained warranty" deduction is applied only on the final situation
ToPayOn=To pay on %s
toPayOn=to pay on %s
RetainedWarranty=Retained Warranty
diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang
index 609ea0efdf2..f8b3d0354e2 100644
--- a/htdocs/langs/en_US/companies.lang
+++ b/htdocs/langs/en_US/companies.lang
@@ -446,6 +446,7 @@ SaleRepresentativeFirstname=First name of sales representative
SaleRepresentativeLastname=Last name of sales representative
ErrorThirdpartiesMerge=There was an error when deleting the third parties. Please check the log. Changes have been reverted.
NewCustomerSupplierCodeProposed=Customer or Vendor code already used, a new code is suggested
+KeepEmptyIfGenericAddress=Keep this field empty if this address is a generic address
#Imports
PaymentTypeCustomer=Payment Type - Customer
PaymentTermsCustomer=Payment Terms - Customer
diff --git a/htdocs/langs/en_US/link.lang b/htdocs/langs/en_US/link.lang
index fdcf07aeff4..1ffcd41a18b 100644
--- a/htdocs/langs/en_US/link.lang
+++ b/htdocs/langs/en_US/link.lang
@@ -8,3 +8,4 @@ LinkRemoved=The link %s has been removed
ErrorFailedToDeleteLink= Failed to remove link '%s'
ErrorFailedToUpdateLink= Failed to update link '%s'
URLToLink=URL to link
+OverwriteIfExists=Overwrite file if exists
diff --git a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php
index e0dd34cf180..dcee9eeaea5 100644
--- a/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php
+++ b/htdocs/modulebuilder/template/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php
@@ -118,9 +118,9 @@ class InterfaceMyModuleTriggers extends DolibarrTriggers
//case 'ACTION_DELETE':
// Groups
- //case 'GROUP_CREATE':
- //case 'GROUP_MODIFY':
- //case 'GROUP_DELETE':
+ //case 'USERGROUP_CREATE':
+ //case 'USERGROUP_MODIFY':
+ //case 'USERGROUP_DELETE':
// Companies
//case 'COMPANY_CREATE':
diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php
index 69272de686f..e299fec88c5 100644
--- a/htdocs/modulebuilder/template/myobject_card.php
+++ b/htdocs/modulebuilder/template/myobject_card.php
@@ -100,11 +100,6 @@ if (empty($action) && empty($id) && empty($ref)) $action = 'view';
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
-// Security check - Protection if external user
-//if ($user->socid > 0) accessforbidden();
-//if ($user->socid > 0) $socid = $user->socid;
-//$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0);
-//$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
$permissiontoread = $user->rights->mymodule->myobject->read;
$permissiontoadd = $user->rights->mymodule->myobject->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
@@ -113,6 +108,14 @@ $permissionnote = $user->rights->mymodule->myobject->write; // Used by the inclu
$permissiondellink = $user->rights->mymodule->myobject->write; // Used by the include of actions_dellink.inc.php
$upload_dir = $conf->mymodule->multidir_output[isset($object->entity) ? $object->entity : 1];
+// Security check - Protection if external user
+//if ($user->socid > 0) accessforbidden();
+//if ($user->socid > 0) $socid = $user->socid;
+//$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0);
+//$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
+
+//if (!$permissiontoread) accessforbidden();
+
/*
* Actions
diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php
index 5865af34e78..9b230eae594 100644
--- a/htdocs/modulebuilder/template/myobject_list.php
+++ b/htdocs/modulebuilder/template/myobject_list.php
@@ -107,16 +107,6 @@ $search_array_options = $extrafields->getOptionalsFromPost($object->table_elemen
if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
if (!$sortorder) $sortorder = "ASC";
-// Security check
-if (empty($conf->mymodule->enabled)) accessforbidden('Module not enabled');
-$socid = 0;
-if ($user->socid > 0) // Protection if external user
-{
- //$socid = $user->socid;
- accessforbidden();
-}
-//$result = restrictedArea($user, 'mymodule', $id, '');
-
// Initialize array of search criterias
$search_all = trim(GETPOST("search_all", 'alpha'));
$search = array();
@@ -161,6 +151,18 @@ $permissiontoread = $user->rights->mymodule->myobject->read;
$permissiontoadd = $user->rights->mymodule->myobject->write;
$permissiontodelete = $user->rights->mymodule->myobject->delete;
+// Security check
+if (empty($conf->mymodule->enabled)) accessforbidden('Module not enabled');
+$socid = 0;
+if ($user->socid > 0) // Protection if external user
+{
+ //$socid = $user->socid;
+ accessforbidden();
+}
+//$result = restrictedArea($user, 'mymodule', $id, '');
+//if (!$permissiontoread) accessforbidden();
+
+
/*
* Actions
diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php
index 8fac5fb3028..c37dbaeb3f7 100644
--- a/htdocs/product/class/product.class.php
+++ b/htdocs/product/class/product.class.php
@@ -4734,7 +4734,7 @@ class Product extends CommonObject
$op[1] = "-".trim($nbpiece);
$movementstock = new MouvementStock($this->db);
- $movementstock->setOrigin($origin_element, $origin_id);
+ $movementstock->setOrigin($origin_element, $origin_id); // Set ->origin and ->origin->id
$result = $movementstock->_create($user, $this->id, $id_entrepot, $op[$movement], $movement, $price, $label, $inventorycode);
if ($result >= 0) {
diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php
index b7c92215e2a..5bbc3f9d92c 100644
--- a/htdocs/product/stock/class/mouvementstock.class.php
+++ b/htdocs/product/stock/class/mouvementstock.class.php
@@ -142,7 +142,7 @@ class MouvementStock extends CommonObject
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
- $langs->load("errors");
+
$error = 0;
dol_syslog(get_class($this)."::_create start userid=$user->id, fk_product=$fk_product, warehouse_id=$entrepot_id, qty=$qty, type=$type, price=$price, label=$label, inventorycode=$inventorycode, datem=".$datem.", eatby=".$eatby.", sellby=".$sellby.", batch=".$batch.", skip_batch=".$skip_batch);
@@ -408,13 +408,13 @@ class MouvementStock extends CommonObject
$sql .= " ".($batch ? "'".$batch."'" : "null").", ";
$sql .= " ".($eatby ? "'".$this->db->idate($eatby)."'" : "null").", ";
$sql .= " ".($sellby ? "'".$this->db->idate($sellby)."'" : "null").", ";
- $sql .= " ".$this->entrepot_id.", ".$this->qty.", ".$this->type.",";
+ $sql .= " ".$this->entrepot_id.", ".$this->qty.", ".((int) $this->type).",";
$sql .= " ".$user->id.",";
$sql .= " '".$this->db->escape($label)."',";
$sql .= " ".($inventorycode ? "'".$this->db->escape($inventorycode)."'" : "null").",";
- $sql .= " '".price2num($price)."',";
- $sql .= " '".$fk_origin."',";
- $sql .= " '".$origintype."',";
+ $sql .= " ".price2num($price).",";
+ $sql .= " ".$fk_origin.",";
+ $sql .= " '".$this->db->escape($origintype)."',";
$sql .= " ".$fk_project;
$sql .= ")";
@@ -438,7 +438,7 @@ class MouvementStock extends CommonObject
$oldpmp = $product->pmp;
$oldqtywarehouse = 0;
- // Test if there is already a record for couple (warehouse / product)
+ // Test if there is already a record for couple (warehouse / product), so later we will make an update or create.
$alreadyarecord = 0;
if (!$error)
{
@@ -486,7 +486,7 @@ class MouvementStock extends CommonObject
}
elseif ($type == 1 || $type == 2)
{
- // After a stock decrease, we don't change value of PMP for product.
+ // After a stock decrease, we don't change value of the AWP/PMP of a product.
$newpmp = $oldpmp;
}
else
@@ -543,7 +543,7 @@ class MouvementStock extends CommonObject
// $sql = "UPDATE ".MAIN_DB_PREFIX."product SET pmp = ".$newpmp.", stock = ".$this->db->ifsql("stock IS NULL", 0, "stock") . " + ".$qty;
// $sql.= " WHERE rowid = ".$fk_product;
// Update pmp + denormalized fields because we change content of produt_stock. Warning: Do not use "SET p.stock", does not works with pgsql
- $sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET pmp = ".$newpmp.", ";
+ $sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET pmp = ".$newpmp.",";
$sql .= " stock=(SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock as ps WHERE ps.fk_product = p.rowid)";
$sql .= " WHERE rowid = ".$fk_product;
diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php
index 9035df18742..0e793361d2b 100644
--- a/htdocs/projet/class/project.class.php
+++ b/htdocs/projet/class/project.class.php
@@ -1046,9 +1046,12 @@ class Project extends CommonObject
$result = '';
$label = '';
- if ($option != 'nolink') $label = ''.$langs->trans("ShowProject").'';
+ if ($option != 'nolink') $label = ''.$langs->trans("Project").'';
$label .= ($label ? ' ' : '').''.$langs->trans('Ref').': '.$this->ref; // The space must be after the : to not being explode when showing the title in img_picto
$label .= ($label ? ' ' : '').''.$langs->trans('Label').': '.$this->title; // The space must be after the : to not being explode when showing the title in img_picto
+ if (isset($this->public)) {
+ $label .= ' '.$langs->trans("Visibility").": ".($this->public ? $langs->trans("SharedProject") : $langs->trans("PrivateProject"));
+ }
if (!empty($this->thirdparty_name))
$label .= ($label ? ' ' : '').''.$langs->trans('ThirdParty').': '.$this->thirdparty_name; // The space must be after the : to not being explode when showing the title in img_picto
if (!empty($this->dateo))
diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php
index 8ed94cc1180..26b00bae2a9 100644
--- a/htdocs/projet/list.php
+++ b/htdocs/projet/list.php
@@ -289,7 +289,7 @@ else dol_print_error($db);
if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0] = '0'; // To avoid sql syntax error if not found
$distinct = 'DISTINCT'; // We add distinct until we are added a protection to be sure a contact of a project and task is only once.
-$sql = "SELECT ".$distinct." p.rowid as id, p.ref, p.title, p.fk_statut, p.fk_opp_status, p.public, p.fk_user_creat";
+$sql = "SELECT ".$distinct." p.rowid as id, p.ref, p.title, p.fk_statut as status, p.fk_opp_status, p.public, p.fk_user_creat";
$sql .= ", p.datec as date_creation, p.dateo as date_start, p.datee as date_end, p.opp_amount, p.opp_percent, (p.opp_amount*p.opp_percent/100) as opp_weighted_amount, p.tms as date_update, p.budget_amount, p.usage_opportunity, p.usage_task, p.usage_bill_time";
$sql .= ", s.rowid as socid, s.nom as name, s.email";
$sql .= ", cls.code as opp_status_code";
@@ -713,7 +713,9 @@ while ($i < min($num, $limit))
$object->public = $obj->public;
$object->ref = $obj->ref;
$object->datee = $db->jdate($obj->date_end);
- $object->statut = $obj->fk_statut;
+ $object->statut = $obj->status; // deprecated
+ $object->status = $obj->status;
+ $object->public = $obj->public;
$object->opp_status = $obj->fk_opp_status;
$object->title = $obj->title;
diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php
index 19c36bcaa22..3e69fbc167f 100644
--- a/htdocs/supplier_proposal/class/supplier_proposal.class.php
+++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php
@@ -70,7 +70,7 @@ class SupplierProposal extends CommonObject
/**
* @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
*/
- public $picto = 'propal';
+ public $picto = 'supplier_proposal';
/**
* 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
@@ -2225,7 +2225,7 @@ class SupplierProposal extends CommonObject
*/
public function getLibStatut($mode = 0)
{
- return $this->LibStatut($this->statut, $mode);
+ return $this->LibStatut((isset($this->statut) ? $this->statut : $this->status), $mode);
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -2555,17 +2555,16 @@ class SupplierProposal extends CommonObject
$url = '';
$result = '';
- $label = ''.$langs->trans("ShowSupplierProposal").'';
- if (!empty($this->ref))
- $label .= ' '.$langs->trans('Ref').': '.$this->ref;
- if (!empty($this->ref_fourn))
- $label .= ' '.$langs->trans('RefSupplier').': '.$this->ref_fourn;
- if (!empty($this->total_ht))
- $label .= ' '.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency);
- if (!empty($this->total_tva))
- $label .= ' '.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency);
- if (!empty($this->total_ttc))
- $label .= ' '.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
+ $label = ''.$langs->trans("SupplierProposal").'';
+ if (!empty($this->ref)) $label .= ' '.$langs->trans('Ref').': '.$this->ref;
+ if (!empty($this->ref_fourn)) $label .= ' '.$langs->trans('RefSupplier').': '.$this->ref_fourn;
+ if (!empty($this->total_ht)) $label .= ' '.$langs->trans('AmountHT').': '.price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency);
+ if (!empty($this->total_tva)) $label .= ' '.$langs->trans('VAT').': '.price($this->total_tva, 0, $langs, 0, -1, -1, $conf->currency);
+ if (!empty($this->total_ttc)) $label .= ' '.$langs->trans('AmountTTC').': '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
+ if (isset($this->status)) {
+ $label .= ' '.$langs->trans("Status").": ".$this->getLibStatut(5);
+ }
+
if ($option == '') {
$url = DOL_URL_ROOT.'/supplier_proposal/card.php?id='.$this->id.$get_params;
}
@@ -2597,8 +2596,6 @@ class SupplierProposal extends CommonObject
$linkstart .= $linkclose.'>';
$linkend = '';
- $picto = 'supplier_proposal';
-
$result .= $linkstart;
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
if ($withpicto != 2) $result .= $this->ref;
diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php
index c778536685e..28dbc3e12b8 100644
--- a/htdocs/supplier_proposal/list.php
+++ b/htdocs/supplier_proposal/list.php
@@ -259,7 +259,7 @@ if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT';
$sql .= ' s.rowid as socid, s.nom as name, s.town, s.zip, s.fk_pays, s.client, s.code_client,';
$sql .= " typent.code as typent_code,";
$sql .= " state.code_departement as state_code, state.nom as state_name,";
-$sql .= ' sp.rowid, sp.note_private, sp.total_ht, sp.tva as total_vat, sp.total as total_ttc, sp.localtax1, sp.localtax2, sp.ref, sp.fk_statut, sp.fk_user_author, sp.date_valid, sp.date_livraison as dp,';
+$sql .= ' sp.rowid, sp.note_private, sp.total_ht, sp.tva as total_vat, sp.total as total_ttc, sp.localtax1, sp.localtax2, sp.ref, sp.fk_statut as status, sp.fk_user_author, sp.date_valid, sp.date_livraison as dp,';
$sql .= ' sp.fk_multicurrency, sp.multicurrency_code, sp.multicurrency_tx, sp.multicurrency_total_ht, sp.multicurrency_total_tva as multicurrency_total_vat, sp.multicurrency_total_ttc,';
$sql .= ' sp.datec as date_creation, sp.tms as date_update,';
$sql .= " p.rowid as project_id, p.ref as project_ref,";
@@ -695,6 +695,13 @@ if ($resql)
$objectstatic->ref = $obj->ref;
$objectstatic->note_public = $obj->note_public;
$objectstatic->note_private = $obj->note_private;
+ $objectstatic->status = $obj->status;
+
+ // Company
+ $companystatic->id = $obj->socid;
+ $companystatic->name = $obj->name;
+ $companystatic->client = $obj->client;
+ $companystatic->code_client = $obj->code_client;
print '
';
@@ -728,14 +735,6 @@ if ($resql)
if (!$i) $totalarray['nbfield']++;
}
- $url = DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid;
-
- // Company
- $companystatic->id = $obj->socid;
- $companystatic->name = $obj->name;
- $companystatic->client = $obj->client;
- $companystatic->code_client = $obj->code_client;
-
// Thirdparty
if (!empty($arrayfields['s.nom']['checked']))
{
@@ -901,7 +900,7 @@ if ($resql)
// Status
if (!empty($arrayfields['sp.fk_statut']['checked']))
{
- print '
'.$objectstatic->LibStatut($obj->fk_statut, 5)."
\n";
+ print '
'.$objectstatic->getLibStatut(5)."
\n";
if (!$i) $totalarray['nbfield']++;
}
diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php
index bba62298989..0688d4a8584 100644
--- a/htdocs/takepos/index.php
+++ b/htdocs/takepos/index.php
@@ -763,8 +763,10 @@ if (empty($conf->global->TAKEPOS_HIDE_HEAD_BAR)) {
echo ' - '.dol_print_date(dol_now(), "day").'';
?>
+
';
- if (empty($object->fk_user)) print $langs->trans("None");
+ if (empty($object->fk_user)) {
+ print ''.$langs->trans("None").'';
+ }
else {
$huser = new User($db);
$huser->fetch($object->fk_user);
@@ -1993,6 +1995,8 @@ else
if ($canreadgroup)
{
+ print ''."\n";
+
print load_fiche_titre($langs->trans("ListOfGroupsForUser"), '', '');
// On selectionne les groupes auquel fait parti le user
@@ -2031,13 +2035,11 @@ else
print $form->select_dolgroups('', 'group', 1, $exclude, 0, '', '', $object->entity);
print ' ';
print '';
- print '';
+ print '';
}
print '
'."\n";
- /*
- * Groups assigned to user
- */
+ // List of groups of user
if (!empty($groupslist))
{
foreach ($groupslist as $group)
@@ -2046,7 +2048,7 @@ else
print '
';
if ($caneditgroup)
{
- print ''.img_object($langs->trans("ShowGroup"), "group").' '.$group->name.'';
+ print $group->getNomUrl(1);
}
else
{
@@ -2085,7 +2087,7 @@ else
}
/*
- * Fiche en mode edition
+ * Card in edit mode
*/
if ($action == 'edit' && ($canedituser || $caneditfield || $caneditpassword || ($user->id == $object->id)))
{
diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php
index 1f8040a83ea..c897db44412 100644
--- a/htdocs/user/class/usergroup.class.php
+++ b/htdocs/user/class/usergroup.class.php
@@ -100,6 +100,31 @@ class UserGroup extends CommonObject
public $oldcopy; // To contains a clone of this when we need to save old properties of object
+ public $fields = array(
+ 'rowid'=>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
+ 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=> 1, 'default'=>1, 'index'=>1, 'position'=>5),
+ 'nom'=>array('type'=>'varchar(180)', 'label'=>'Name', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'searchall'=>1, 'comment'=>'Group name'),
+ 'note' => array('type'=>'html', 'label'=>'Description', 'enabled'=>1, 'visible'=>1, 'position'=>20, 'notnull'=>-1,),
+ 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>50, 'notnull'=>1,),
+ 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>60, 'notnull'=>1,),
+ 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'ModelPDF', 'enabled'=>1, 'visible'=>0, 'position'=>100),
+ );
+
+ /**
+ * @var int Field with ID of parent key if this field has a parent
+ */
+ public $fk_element = 'fk_usergroup';
+
+ /**
+ * @var array List of child tables. To test if we can delete object.
+ */
+ protected $childtables=array();
+
+ /**
+ * @var array List of child tables. To know object to delete on cascade.
+ */
+ protected $childtablesoncascade = array('usergroup_rights','usergroup_user');
+
/**
* Constructor de la classe
@@ -125,47 +150,25 @@ class UserGroup extends CommonObject
{
global $conf;
- $sql = "SELECT g.rowid, g.entity, g.nom as name, g.note, g.datec, g.tms as datem";
- $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g";
- if ($groupname)
+ dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
+ if (!empty($groupname))
{
- $sql .= " WHERE g.nom = '".$this->db->escape($groupname)."'";
+ $result = $this->fetchCommon(0, '', ' AND nom = \''.$this->db->escape($groupname).'\'');
}
else
{
- $sql .= " WHERE g.rowid = ".$id;
+ $result = $this->fetchCommon($id);
}
- dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
- $result = $this->db->query($sql);
- if ($result)
+ $this->name = $this->nom; // For compatibility with field name
+
+ if($result)
{
- if ($this->db->num_rows($result))
+ if ($load_members)
{
- $obj = $this->db->fetch_object($result);
-
- $this->id = $obj->rowid;
- $this->ref = $obj->rowid;
- $this->entity = $obj->entity;
- $this->name = $obj->name;
- $this->nom = $obj->name; // Deprecated
- $this->note = $obj->note;
- $this->datec = $obj->datec;
- $this->datem = $obj->datem;
-
- if ($load_members)
- $this->members = $this->listUsersForGroup();
-
-
- // Retreive all extrafield
- // fetch optionals attributes and labels
- $this->fetch_optionals();
-
-
- // Sav current LDAP Current DN
- //$this->ldap_dn = $this->_load_ldap_dn($this->_load_ldap_info(),0);
+ $this->members = $this->listUsersForGroup();
}
- $this->db->free($result);
+
return 1;
}
else
@@ -403,7 +406,7 @@ class UserGroup extends CommonObject
$this->context = array('audit'=>$langs->trans("PermissionsAdd").($rid ? ' (id='.$rid.')' : ''));
// Call trigger
- $result = $this->call_trigger('GROUP_MODIFY', $user);
+ $result = $this->call_trigger('USERGROUP_MODIFY', $user);
if ($result < 0) { $error++; }
// End call triggers
}
@@ -527,7 +530,7 @@ class UserGroup extends CommonObject
$this->context = array('audit'=>$langs->trans("PermissionsDelete").($rid ? ' (id='.$rid.')' : ''));
// Call trigger
- $result = $this->call_trigger('GROUP_MODIFY', $user);
+ $result = $this->call_trigger('USERGROUP_MODIFY', $user);
if ($result < 0) { $error++; }
// End call triggers
}
@@ -637,50 +640,7 @@ class UserGroup extends CommonObject
*/
public function delete(User $user)
{
- global $conf, $langs;
-
- $error = 0;
-
- $this->db->begin();
-
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_rights";
- $sql .= " WHERE fk_usergroup = ".$this->id;
- $this->db->query($sql);
-
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup_user";
- $sql .= " WHERE fk_usergroup = ".$this->id;
- $this->db->query($sql);
-
- // Remove extrafields
- if ((!$error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used
- {
- $result = $this->deleteExtraFields();
- if ($result < 0)
- {
- $error++;
- dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR);
- }
- }
-
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup";
- $sql .= " WHERE rowid = ".$this->id;
- $result = $this->db->query($sql);
- if ($result)
- {
- // Call trigger
- $result = $this->call_trigger('GROUP_DELETE', $user);
- if ($result < 0) { $error++; $this->db->rollback(); return -1; }
- // End call triggers
-
- $this->db->commit();
- return 1;
- }
- else
- {
- $this->db->rollback();
- dol_print_error($this->db);
- return -1;
- }
+ return $this->deleteCommon($user);
}
/**
@@ -691,67 +651,15 @@ class UserGroup extends CommonObject
*/
public function create($notrigger = 0)
{
- global $user, $conf, $langs, $hookmanager;
+ global $user, $conf;
- $error = 0;
- $now = dol_now();
+ $this->datec = dol_now();
if (!isset($this->entity)) $this->entity = $conf->entity; // If not defined, we use default value
-
$entity = $this->entity;
if (!empty($conf->multicompany->enabled) && $conf->entity == 1) $entity = $this->entity;
- $this->db->begin();
-
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."usergroup (";
- $sql .= "datec";
- $sql .= ", nom";
- $sql .= ", entity";
- $sql .= ") VALUES (";
- $sql .= "'".$this->db->idate($now)."'";
- $sql .= ",'".$this->db->escape($this->nom)."'";
- $sql .= ",".$this->db->escape($entity);
- $sql .= ")";
-
- dol_syslog(get_class($this)."::create", LOG_DEBUG);
- $result = $this->db->query($sql);
- if ($result)
- {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."usergroup");
-
- if ($this->update(1) < 0) return -2;
-
- $action = 'create';
-
- // Actions on extra fields (by external module or standard code)
- if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
- {
- $result = $this->insertExtraFields();
- if ($result < 0)
- {
- $error++;
- }
- }
-
- if (!$error && !$notrigger)
- {
- // Call trigger
- $result = $this->call_trigger('GROUP_CREATE', $user);
- if ($result < 0) { $error++; $this->db->rollback(); return -1; }
- // End call triggers
- }
-
- if ($error > 0) { $error++; $this->db->rollback(); return -1; }
- else $this->db->commit();
-
- return $this->id;
- }
- else
- {
- $this->db->rollback();
- $this->error = $this->db->lasterror();
- return -1;
- }
+ return $this->createCommon($user, $notrigger);
}
/**
@@ -762,9 +670,7 @@ class UserGroup extends CommonObject
*/
public function update($notrigger = 0)
{
- global $user, $conf, $langs, $hookmanager;
-
- $error = 0;
+ global $user, $conf;
$entity = $conf->entity;
if (!empty($conf->multicompany->enabled) && $conf->entity == 1)
@@ -772,55 +678,7 @@ class UserGroup extends CommonObject
$entity = $this->entity;
}
- $this->db->begin();
-
- $sql = "UPDATE ".MAIN_DB_PREFIX."usergroup SET ";
- $sql .= " nom = '".$this->db->escape($this->name)."'";
- $sql .= ", entity = ".$this->db->escape($entity);
- $sql .= ", note = '".$this->db->escape($this->note)."'";
- $sql .= " WHERE rowid = ".$this->id;
-
- dol_syslog(get_class($this)."::update", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $action = 'update';
-
- // Actions on extra fields (by external module or standard code)
- if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
- {
- $result = $this->insertExtraFields();
- if ($result < 0)
- {
- $error++;
- }
- }
-
- if (!$error && !$notrigger)
- {
- // Call trigger
- $result = $this->call_trigger('GROUP_MODIFY', $user);
- if ($result < 0) { $error++; }
- // End call triggers
- }
-
- if (!$error)
- {
- $this->db->commit();
- return 1;
- }
- else
- {
- $this->db->rollback();
- return -$error;
- }
- }
- else
- {
- $this->db->rollback();
- dol_print_error($this->db);
- return -1;
- }
+ return $this->updateCommon($user, $notrigger);
}
diff --git a/htdocs/user/group/card.php b/htdocs/user/group/card.php
index 335b66ebdd2..618f569c1e3 100644
--- a/htdocs/user/group/card.php
+++ b/htdocs/user/group/card.php
@@ -54,6 +54,7 @@ $action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'groupcard'; // To manage different context of search
+$backtopage = GETPOST('backtopage', 'alpha');
$userid = GETPOST('user', 'int');
@@ -67,16 +68,14 @@ if (!empty($conf->multicompany->enabled) && $conf->entity > 1 && $conf->global->
}
$object = new Usergroup($db);
-if ($id > 0)
-{
- $object->fetch($id);
- $object->getrights();
-}
-
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
+// Load object
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
+$object->getrights();
+
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
$hookmanager->initHooks(array('groupcard', 'globalcard'));
@@ -91,19 +90,19 @@ $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) {
+ $backurlforlist = DOL_URL_ROOT.'/user/group/list.php';
+
+ if (empty($backtopage) || ($cancel && empty($id))) {
+ if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
+ if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
+ else $backtopage = dol_buildpath('/user/group/card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
+ }
+ }
+
if ($cancel)
{
- if (!empty($backtopage))
- {
- header("Location: ".$backtopage);
- exit;
- }
- else
- {
- header("Location: ".DOL_URL_ROOT.'/user/group/list.php');
- exit;
- }
- $action = '';
+ header("Location: ".$backtopage);
+ exit;
}
// Action remove group
@@ -215,7 +214,7 @@ if (empty($reshook)) {
$object->oldcopy = clone $object;
- $object->name = trim(GETPOST("group", 'nohtml'));
+ $object->name = trim(GETPOST("nom", 'nohtml'));
$object->nom = $object->name; // For backward compatibility
$object->note = dol_htmlcleanlastbr(trim(GETPOST("note", 'none')));
@@ -273,14 +272,11 @@ if ($action == 'create')
print '
';
+ print ''."\n";
$sql = "SELECT r.id, r.libelle as label, r.module";
$sql .= " FROM ".MAIN_DB_PREFIX."rights_def as r";
@@ -250,16 +261,15 @@ if ($object->id > 0)
$result = $db->query($sql);
if ($result)
{
- $i = 0;
+ $num = $db->num_rows($result);
+ $i = 0;
$oldmod = '';
- $num = $db->num_rows($result);
-
while ($i < $num)
{
$obj = $db->fetch_object($result);
- // Si la ligne correspond a un module qui n'existe plus (absent de includes/module), on l'ignore
+ // If line is for a module that doe snot existe anymore (absent of includes/module), we ignore it
if (empty($modules[$obj->module]))
{
$i++;
@@ -270,29 +280,37 @@ if ($object->id > 0)
{
$oldmod = $obj->module;
- // Rupture detectee, on recupere objMod
+ // Break detected, we get objMod
$objMod = $modules[$obj->module];
$picto = ($objMod->picto ? $objMod->picto : 'generic');
+ // Show break line
print '