From 1b646f755dd036c62b7c8af1621c352c2ff4b0ce Mon Sep 17 00:00:00 2001 From: vvnt Date: Wed, 22 Nov 2017 23:11:36 +0100 Subject: [PATCH 01/19] modSociete.class.php permissions in English --- htdocs/core/modules/modSociete.class.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index a437e2b547d..0ec3fd83072 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -92,7 +92,7 @@ class modSociete extends DolibarrModules $this->const[$r][0] = "SOCIETE_FISCAL_MONTH_START"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "0"; - $this->const[$r][3] = "Mettre le numéro du mois du début d\'année fiscale, ex: 9 pour septembre"; + $this->const[$r][3] = "Enter the month number of the first month of the fiscal year, e. g. 9 for September"; $this->const[$r][4] = 0; $r++; @@ -141,7 +141,7 @@ class modSociete extends DolibarrModules $r++; $this->rights[$r][0] = 121; // id de la permission - $this->rights[$r][1] = 'Lire les sociétés'; // libelle de la permission + $this->rights[$r][1] = 'Read third parties'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'lire'; @@ -165,7 +165,7 @@ class modSociete extends DolibarrModules $r++; $this->rights[$r][0] = 122; // id de la permission - $this->rights[$r][1] = 'Créer modifier les sociétés'; // libelle de la permission + $this->rights[$r][1] = 'Create and update third parties'; // libelle de la permission $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'creer'; @@ -189,14 +189,14 @@ class modSociete extends DolibarrModules $r++; $this->rights[$r][0] = 125; // id de la permission - $this->rights[$r][1] = 'Supprimer les sociétés'; // libelle de la permission + $this->rights[$r][1] = 'Delete third parties'; // libelle de la permission $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'supprimer'; $r++; $this->rights[$r][0] = 126; // id de la permission - $this->rights[$r][1] = 'Exporter les sociétés'; // libelle de la permission + $this->rights[$r][1] = 'Export third parties'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'export'; @@ -204,7 +204,7 @@ class modSociete extends DolibarrModules // 262 : Resteindre l'acces des commerciaux $r++; $this->rights[$r][0] = 262; - $this->rights[$r][1] = 'Consulter tous les tiers par utilisateurs internes (sinon uniquement si contact commercial). Non effectif pour utilisateurs externes (tjs limités à eux-même).'; + $this->rights[$r][1] = 'Read all third parties by internal users (otherwise only if commercial contact). Not effective for external users (limited to themselves).'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'client'; @@ -212,7 +212,7 @@ class modSociete extends DolibarrModules $r++; $this->rights[$r][0] = 281; // id de la permission - $this->rights[$r][1] = 'Lire les contacts'; // libelle de la permission + $this->rights[$r][1] = 'Read contacts'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'contact'; @@ -220,7 +220,7 @@ class modSociete extends DolibarrModules $r++; $this->rights[$r][0] = 282; // id de la permission - $this->rights[$r][1] = 'Créer modifier les contacts'; // libelle de la permission + $this->rights[$r][1] = 'Create and update contact'; // libelle de la permission $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'contact'; @@ -228,7 +228,7 @@ class modSociete extends DolibarrModules $r++; $this->rights[$r][0] = 283; // id de la permission - $this->rights[$r][1] = 'Supprimer les contacts'; // libelle de la permission + $this->rights[$r][1] = 'Delete contacts'; // libelle de la permission $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'contact'; @@ -236,7 +236,7 @@ class modSociete extends DolibarrModules $r++; $this->rights[$r][0] = 286; // id de la permission - $this->rights[$r][1] = 'Exporter les contacts'; // libelle de la permission + $this->rights[$r][1] = 'Export contacts'; // libelle de la permission $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'contact'; From 10ba9a2fee154624f3fced85491c0a02e6cc1481 Mon Sep 17 00:00:00 2001 From: vvnt Date: Wed, 22 Nov 2017 23:16:15 +0100 Subject: [PATCH 02/19] modFacture.class.php permissions in English --- htdocs/core/modules/modFacture.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index 3dc1c6890cb..c117b6ff337 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -128,14 +128,14 @@ class modFacture extends DolibarrModules $r++; $this->rights[$r][0] = 11; - $this->rights[$r][1] = 'Lire les factures'; + $this->rights[$r][1] = 'Read invoices'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'lire'; $r++; $this->rights[$r][0] = 12; - $this->rights[$r][1] = 'Créer/modifier les factures'; + $this->rights[$r][1] = 'Create and update invoices'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'creer'; @@ -143,7 +143,7 @@ class modFacture extends DolibarrModules // There is a particular permission for unvalidate because this may be not forbidden by some laws $r++; $this->rights[$r][0] = 13; - $this->rights[$r][1] = 'Dévalider les factures'; + $this->rights[$r][1] = 'Devalidate invoices'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'invoice_advance'; @@ -151,7 +151,7 @@ class modFacture extends DolibarrModules $r++; $this->rights[$r][0] = 14; - $this->rights[$r][1] = 'Valider les factures'; + $this->rights[$r][1] = 'Validate invoices'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'invoice_advance'; @@ -159,7 +159,7 @@ class modFacture extends DolibarrModules $r++; $this->rights[$r][0] = 15; - $this->rights[$r][1] = 'Envoyer les factures par email'; + $this->rights[$r][1] = 'Send invoices by email'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'invoice_advance'; @@ -167,21 +167,21 @@ class modFacture extends DolibarrModules $r++; $this->rights[$r][0] = 16; - $this->rights[$r][1] = 'Émettre des paiements sur les factures'; + $this->rights[$r][1] = 'Issue payments on invoices'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'paiement'; $r++; $this->rights[$r][0] = 19; - $this->rights[$r][1] = 'Supprimer les factures'; + $this->rights[$r][1] = 'Delete invoices'; $this->rights[$r][2] = 'a'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'supprimer'; $r++; $this->rights[$r][0] = 1321; - $this->rights[$r][1] = 'Exporter les factures clients, attributs et règlements'; + $this->rights[$r][1] = 'Export customer invoices, attributes and payments'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'facture'; @@ -189,7 +189,7 @@ class modFacture extends DolibarrModules $r++; $this->rights[$r][0] = 1322; - $this->rights[$r][1] = 'Rouvrir une facture totalement réglée'; + $this->rights[$r][1] = 'Re-open a fully paid invoice'; $this->rights[$r][2] = 'r'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'invoice_advance'; From 09f4abd38ec7c1c569fcab9b17a4b453e6e32e96 Mon Sep 17 00:00:00 2001 From: vvnt Date: Wed, 22 Nov 2017 23:22:43 +0100 Subject: [PATCH 03/19] modPropale.class.php permissions in English --- htdocs/core/modules/modPropale.class.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index 9bb1aeaa818..a6b38f7d5ff 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -77,14 +77,14 @@ class modPropale extends DolibarrModules $this->const[$r][0] = "PROPALE_ADDON_PDF"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "azur"; - $this->const[$r][3] = 'Nom du gestionnaire de génération des propales en PDF'; + $this->const[$r][3] = 'Name of the proposal generation manager in PDF format'; $this->const[$r][4] = 0; $r++; $this->const[$r][0] = "PROPALE_ADDON"; $this->const[$r][1] = "chaine"; $this->const[$r][2] = "mod_propale_marbre"; - $this->const[$r][3] = 'Nom du gestionnaire de numérotation des propales'; + $this->const[$r][3] = 'Name of proposal numbering manager'; $this->const[$r][4] = 0; $r++; @@ -121,21 +121,21 @@ class modPropale extends DolibarrModules $r++; $this->rights[$r][0] = 21; // id de la permission - $this->rights[$r][1] = 'Lire les propositions commerciales'; // libelle de la permission + $this->rights[$r][1] = 'Read commercial proposals'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'lire'; $r++; $this->rights[$r][0] = 22; // id de la permission - $this->rights[$r][1] = 'Créer/modifier les propositions commerciales'; // libelle de la permission + $this->rights[$r][1] = 'Create and update commercial proposals'; // libelle de la permission $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'creer'; $r++; $this->rights[$r][0] = 24; // id de la permission - $this->rights[$r][1] = 'Valider les propositions commerciales'; // libelle de la permission + $this->rights[$r][1] = 'Validate commercial proposals'; // libelle de la permission $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'propal_advance'; @@ -143,7 +143,7 @@ class modPropale extends DolibarrModules $r++; $this->rights[$r][0] = 25; // id de la permission - $this->rights[$r][1] = 'Envoyer les propositions commerciales aux clients'; // libelle de la permission + $this->rights[$r][1] = 'Send commercial proposals to customers'; // libelle de la permission $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'propal_advance'; @@ -151,21 +151,21 @@ class modPropale extends DolibarrModules $r++; $this->rights[$r][0] = 26; // id de la permission - $this->rights[$r][1] = 'Clôturer les propositions commerciales'; // libelle de la permission + $this->rights[$r][1] = 'Close commercial proposals'; // libelle de la permission $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'cloturer'; $r++; $this->rights[$r][0] = 27; // id de la permission - $this->rights[$r][1] = 'Supprimer les propositions commerciales'; // libelle de la permission + $this->rights[$r][1] = 'Delete commercial proposals'; // libelle de la permission $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'supprimer'; $r++; $this->rights[$r][0] = 28; // id de la permission - $this->rights[$r][1] = 'Exporter les propositions commerciales et attributs'; // libelle de la permission + $this->rights[$r][1] = 'Exporting commercial proposals and attributes'; // libelle de la permission $this->rights[$r][2] = 'r'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut $this->rights[$r][4] = 'export'; From 6428c2157cec2eafe3fe6230dc76a478bc1a1f56 Mon Sep 17 00:00:00 2001 From: Ion Date: Tue, 21 Nov 2017 23:11:33 +0100 Subject: [PATCH 04/19] Add country to resource --- htdocs/install/mysql/migration/6.0.0-7.0.0.sql | 4 ++++ .../install/mysql/tables/llx_resource.key.sql | 5 ++++- htdocs/install/mysql/tables/llx_resource.sql | 1 + htdocs/resource/card.php | 18 ++++++++++++++++++ htdocs/resource/class/dolresource.class.php | 9 +++++++++ 5 files changed, 36 insertions(+), 1 deletion(-) mode change 100755 => 100644 htdocs/install/mysql/tables/llx_resource.sql diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 9ede853c752..652f8ea8418 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -574,3 +574,7 @@ ALTER TABLE llx_societe MODIFY COLUMN capital double(24,8); ALTER TABLE llx_tva MODIFY COLUMN amount double(24,8); ALTER TABLE llx_subscription MODIFY COLUMN subscription double(24,8); +ALTER TABLE llx_resource ADD fk_country integer DEFAULT NULL; +ALTER TABLE llx_resource ADD INDEX idx_resource_fk_country (fk_country); +ALTER TABLE llx_resource ADD CONSTRAINT fk_resource_fk_country FOREIGN KEY (fk_country) REFERENCES llx_c_country (rowid); + diff --git a/htdocs/install/mysql/tables/llx_resource.key.sql b/htdocs/install/mysql/tables/llx_resource.key.sql index 4912b02b1f9..d90f5c00f94 100644 --- a/htdocs/install/mysql/tables/llx_resource.key.sql +++ b/htdocs/install/mysql/tables/llx_resource.key.sql @@ -17,4 +17,7 @@ ALTER TABLE llx_resource ADD UNIQUE INDEX uk_resource_ref (ref, entity); -ALTER TABLE llx_resource ADD INDEX fk_code_type_resource_idx (fk_code_type_resource); \ No newline at end of file +ALTER TABLE llx_resource ADD INDEX fk_code_type_resource_idx (fk_code_type_resource); + +ALTER TABLE llx_resource ADD INDEX idx_resource_fk_country (fk_country); +ALTER TABLE llx_resource ADD CONSTRAINT fk_resource_fk_country FOREIGN KEY (fk_country) REFERENCES llx_c_country (rowid); diff --git a/htdocs/install/mysql/tables/llx_resource.sql b/htdocs/install/mysql/tables/llx_resource.sql old mode 100755 new mode 100644 index afb73e9fd5f..5da0872eb21 --- a/htdocs/install/mysql/tables/llx_resource.sql +++ b/htdocs/install/mysql/tables/llx_resource.sql @@ -33,5 +33,6 @@ CREATE TABLE llx_resource note_private text, import_key varchar(14), extraparams varchar(255), -- for stock other parameters with json format + fk_country integer DEFAULT NULL, -- Optional id of original country tms timestamp )ENGINE=innodb; diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 0dccd9fab13..6e3d1896a71 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/dolresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load traductions files requiredby by page @@ -48,6 +49,7 @@ $ref = GETPOST('ref','alpha'); $description = GETPOST('description'); $confirm = GETPOST('confirm'); $fk_code_type_resource = GETPOST('fk_code_type_resource','alpha'); +$country_id = GETPOST('country_id', 'int'); // Protection if external user if ($user->socid > 0) @@ -111,6 +113,7 @@ if (empty($reshook)) $object->ref = $ref; $object->description = $description; $object->fk_code_type_resource = $fk_code_type_resource; + $object->country_id = $country_id; // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels,$object); @@ -157,6 +160,7 @@ if (empty($reshook)) $object->ref = $ref; $object->description = $description; $object->fk_code_type_resource = $fk_code_type_resource; + $object->country_id = $country_id; // Fill array 'array_options' with data from add form $ret = $extrafields->setOptionalsFromPost($extralabels, $object); @@ -271,6 +275,12 @@ if ($action == 'create' || $object->fetch($id) > 0) $doleditor->Create(); print ''; + // Origin country + print ''.$langs->trans("CountryOrigin").''; + print $form->select_country($object->country_id,'country_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + print ''; + // Other attributes $parameters=array('objectsrc' => $objectsrc); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -345,6 +355,14 @@ if ($action == 'create' || $object->fetch($id) > 0) print ''; + // Origin country code + print ''; + print ''.$langs->trans("CountryOrigin").''; + print ''; + print getCountry($object->country_id,0,$db); + print ''; + print ''; + print ''; print ''; diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 59a5412b0c7..c880f9538c7 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -73,6 +73,7 @@ class Dolresource extends CommonObject if (isset($this->ref)) $this->ref=trim($this->ref); if (isset($this->description)) $this->description=trim($this->description); + if (!is_numeric($this->country_id)) $this->country_id = 0; if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource=trim($this->fk_code_type_resource); if (isset($this->note_public)) $this->note_public=trim($this->note_public); if (isset($this->note_private)) $this->note_private=trim($this->note_private); @@ -84,6 +85,7 @@ class Dolresource extends CommonObject $sql.= "entity,"; $sql.= "ref,"; $sql.= "description,"; + $sql.= "fk_country,"; $sql.= "fk_code_type_resource,"; $sql.= "note_public,"; $sql.= "note_private"; @@ -93,6 +95,7 @@ class Dolresource extends CommonObject $sql.= $conf->entity.", "; $sql.= " ".(! isset($this->ref)?'NULL':"'".$this->db->escape($this->ref)."'").","; $sql.= " ".(! isset($this->description)?'NULL':"'".$this->db->escape($this->description)."'").","; + $sql.= " ".($this->country_id > 0 ? $this->country_id : 'null').","; $sql.= " ".(! isset($this->fk_code_type_resource)?'NULL':"'".$this->db->escape($this->fk_code_type_resource)."'").","; $sql.= " ".(! isset($this->note_public)?'NULL':"'".$this->db->escape($this->note_public)."'").","; $sql.= " ".(! isset($this->note_private)?'NULL':"'".$this->db->escape($this->note_private)."'"); @@ -181,6 +184,7 @@ class Dolresource extends CommonObject $sql.= " t.entity,"; $sql.= " t.ref,"; $sql.= " t.description,"; + $sql.= " t.fk_country,"; $sql.= " t.fk_code_type_resource,"; $sql.= " t.note_public,"; $sql.= " t.note_private,"; @@ -203,6 +207,7 @@ class Dolresource extends CommonObject $this->entity = $obj->entity; $this->ref = $obj->ref; $this->description = $obj->description; + $this->country_id = $obj->fk_country; $this->fk_code_type_resource = $obj->fk_code_type_resource; $this->note_public = $obj->note_public; $this->note_private = $obj->note_private; @@ -228,6 +233,7 @@ class Dolresource extends CommonObject } } + /** * Update object into database * @@ -244,6 +250,7 @@ class Dolresource extends CommonObject if (isset($this->ref)) $this->ref=trim($this->ref); if (isset($this->fk_code_type_resource)) $this->fk_code_type_resource=trim($this->fk_code_type_resource); if (isset($this->description)) $this->description=trim($this->description); + if (!is_numeric($this->country_id)) $this->country_id = 0; if (empty($this->oldcopy)) { @@ -256,6 +263,7 @@ class Dolresource extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element." SET"; $sql.= " ref=".(isset($this->ref)?"'".$this->db->escape($this->ref)."'":"null").","; $sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").","; + $sql.= " fk_country=".($this->country_id > 0 ? $this->country_id :"null").","; $sql.= " fk_code_type_resource=".(isset($this->fk_code_type_resource)?"'".$this->db->escape($this->fk_code_type_resource)."'":"null").","; $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').""; $sql.= " WHERE rowid=".$this->id; @@ -555,6 +563,7 @@ class Dolresource extends CommonObject $line->id = $obj->rowid; $line->ref = $obj->ref; $line->description = $obj->description; + $line->country_id = $obj->fk_country; $line->fk_code_type_resource = $obj->fk_code_type_resource; $line->type_label = $obj->type_label; From 0ee30171db1b62ff37c0c2b30ccc4fd902cb476e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 22 Nov 2017 20:24:04 +0100 Subject: [PATCH 05/19] Update html.form.class.php --- htdocs/compta/facture/class/facture.class.php | 1 - htdocs/core/class/html.form.class.php | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 0f96e1e3ce2..73313884041 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -962,7 +962,6 @@ class Facture extends CommonInvoice * @param User $user Object user * @return int <0 if KO, 0 if nothing done, 1 if OK */ - function createFromOrder($object, User $user) { global $hookmanager; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 88b40bb4734..ad94d06a6d1 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1651,7 +1651,7 @@ class Form * @param int $showproperties Show properties of each attendees * @param array $listofuserid Array with properties of each user * @param array $listofcontactid Array with properties of each contact - * @param array $listofother Array with properties of each other contact + * @param array $listofotherid Array with properties of each other contact * @return string HTML select string * @see select_dolgroups */ @@ -1957,7 +1957,7 @@ class Form } if (!empty($conf->global->PRODUIT_ATTRIBUTES_HIDECHILD)) { - $sql .= " LEFT JOIN llx_product_attribute_combination pac ON pac.fk_product_child = p.rowid"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_attribute_combination pac ON pac.fk_product_child = p.rowid"; } $sql.= ' WHERE p.entity IN ('.getEntity('product').')'; From d8f18e18ce2a4c00c891907bfdb020ca83ea80d9 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 23 Nov 2017 12:08:33 +0100 Subject: [PATCH 06/19] Add new doActions hook --- htdocs/accountancy/journal/purchasesjournal.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 0f9081bdc98..aa185b5c897 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -55,7 +55,11 @@ $now = dol_now(); // Security check if ($user->societe_id > 0) accessforbidden(); - + +$hookmanager->initHooks(array('purchasesjournal')); +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$user,$action); // Note that $action and $object may have been modified by some hooks + /* * Actions */ From 2a7b04e795c1d62056c6cbecc15a9bb1700acd83 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 23 Nov 2017 12:18:49 +0100 Subject: [PATCH 07/19] Fix: wrong table name and id field name --- htdocs/comm/action/class/api_agendaevents.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 4edd656da53..252d2915050 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -76,7 +76,7 @@ class AgendaEvents extends DolibarrApi throw new RestException(401, "Insuffisant rights to read event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } - if ( ! DolibarrApi::_checkAccessToResource('agenda',$this->actioncomm->id)) { + if ( ! DolibarrApi::_checkAccessToResource('agenda',$this->actioncomm->id,'actioncomm','','fk_soc','id')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } From 38ef5890dc692731de4c6662e5802e8b45c9f5d0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 23 Nov 2017 18:47:24 +0100 Subject: [PATCH 08/19] Replace deprecated dol_print_graph with DolGraph --- htdocs/societe/index.php | 67 +++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index 0973de848b5..c2e232fcec0 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -69,7 +69,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { $listofsearchfields['search_contact']=array('text'=>'Contact'); } - + if (count($listofsearchfields)) { print '
'; @@ -85,7 +85,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele print ''; $i++; } - print ''; + print ''; print '
'; print '
'; } @@ -95,7 +95,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele /* * Statistics area */ - + $third = array( 'customer' => 0, 'prospect' => 0, @@ -131,33 +131,40 @@ print ''."\n"; print ''; if (! empty($conf->use_javascript_ajax) && ((round($third['prospect'])?1:0)+(round($third['customer'])?1:0)+(round($third['supplier'])?1:0)+(round($third['other'])?1:0) >= 2)) { - print ''."\n"; } else { if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) { - $statstring = ""; + $statstring = ""; $statstring.= ''; $statstring.= ""; } if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) { - $statstring.= ""; + $statstring.= ""; $statstring.= ''; $statstring.= ""; } if (! empty($conf->fournisseur->enabled) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire) { - $statstring2 = ""; + $statstring2 = ""; $statstring2.= ''; $statstring2.= ""; } @@ -202,24 +209,36 @@ if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHS { $obj = $db->fetch_object($result); if ($i < $nbmax) - $dataseries[]=array('label'=>$obj->label,'data'=>round($obj->nb)); + { + $dataseries[]=array($obj->label, round($obj->nb)); + } else + { $rest+=$obj->nb; + } $total+=$obj->nb; $i++; } if ($i > $nbmax) - $dataseries[]=array('label'=>$langs->trans("Other"),'data'=>round($rest)); - $data=array('series'=>$dataseries); - dol_print_graph('statscategclient',300,180,$data,1,'pie',0); + { + $dataseries[]=array($langs->trans("Other"), round($rest)); + } + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->setShowLegend(1); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setWidth('100%'); + $dolgraph->draw('idgraphcateg'); + print $dolgraph->show(); } else { - $var=true; while ($i < $num) { $obj = $db->fetch_object($result); - + print ''; $total+=$obj->nb; $i++; @@ -275,16 +294,10 @@ if ($result) print ''; print ''."\n"; - $var=True; - while ($i < $num) { $objp = $db->fetch_object($result); - - print ''; - // Name - print ''; + // Name + print '\n"; // Type From 9c22b5f33587b610c1730fcc92475eb434115616 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 23 Nov 2017 20:00:54 +0100 Subject: [PATCH 09/19] Replace deprecated dol_print_graph with DolGraph --- htdocs/adherents/index.php | 28 ++++++++++----- htdocs/comm/propal/index.php | 37 ++++++++++---------- htdocs/commande/index.php | 42 +++++++++++------------ htdocs/compta/deplacement/index.php | 19 +++++++--- htdocs/contrat/index.php | 15 ++++++-- htdocs/contrat/list.php | 14 +++++--- htdocs/core/class/dolgraph.class.php | 20 ++++++++--- htdocs/don/index.php | 28 ++++++++++----- htdocs/expensereport/index.php | 19 +++++++--- htdocs/fichinter/index.php | 24 +++++++++---- htdocs/fichinter/list.php | 2 +- htdocs/fourn/commande/index.php | 25 +++++++++----- htdocs/product/index.php | 25 ++++++++++---- htdocs/projet/graph_opportunities.inc.php | 19 +++++++--- htdocs/supplier_proposal/index.php | 25 +++++++++----- 15 files changed, 228 insertions(+), 114 deletions(-) diff --git a/htdocs/adherents/index.php b/htdocs/adherents/index.php index 001f6132e95..a04b1df5786 100644 --- a/htdocs/adherents/index.php +++ b/htdocs/adherents/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -165,12 +165,13 @@ if ($conf->use_javascript_ajax) print '
'; print '
'.$langs->trans("Statistics").'
'; + print '
'; $dataseries=array(); - if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[]=array('label'=>$langs->trans("Prospects"),'data'=>round($third['prospect'])); - if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[]=array('label'=>$langs->trans("Customers"),'data'=>round($third['customer'])); - if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[]=array('label'=>$langs->trans("Suppliers"),'data'=>round($third['supplier'])); - if (! empty($conf->societe->enabled)) $dataseries[]=array('label'=>$langs->trans("Others"),'data'=>round($third['other'])); - $data=array('series'=>$dataseries); - dol_print_graph('stats',300,180,$data,1,'pie',0,'',0); + if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) $dataseries[]=array($langs->trans("Prospects"), round($third['prospect'])); + if (! empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[]=array($langs->trans("Customers"), round($third['customer'])); + if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[]=array($langs->trans("Suppliers"), round($third['supplier'])); + if (! empty($conf->societe->enabled)) $dataseries[]=array($langs->trans("Others"), round($third['other'])); + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->setShowLegend(1); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setWidth('100%'); + $dolgraph->draw('idgraphthirdparties'); + print $dolgraph->show(); print '
'.$langs->trans("Prospects").''.round($third['prospect']).'
'.$langs->trans("Customers").''.round($third['customer']).'
'.$langs->trans("Suppliers").''.round($third['supplier']).'
'.$obj->label.''.$obj->nb.'
'.$langs->trans('Status').'
'; $thirdparty_static->id=$objp->rowid; $thirdparty_static->name=$objp->name; $thirdparty_static->client=$objp->client; @@ -295,6 +308,10 @@ if ($result) $thirdparty_static->code_client = $objp->code_client; $thirdparty_static->code_fournisseur = $objp->code_fournisseur; $thirdparty_static->canvas=$objp->canvas; + + print '
'; print $thirdparty_static->getNomUrl(1); print "
'; print ''; - print ''; print '\n"; $listofstatus=array(0,1,-1,2); foreach ($listofstatus as $status) { - $dataseries[]=array('label'=>$donstatic->LibStatut($status,1),'data'=>(isset($nb[$status])?(int) $nb[$status]:0)); + $dataseries[]=array($donstatic->LibStatut($status,1), (isset($nb[$status])?(int) $nb[$status]:0)); } if ($conf->use_javascript_ajax) { - print ''; } @@ -141,7 +153,7 @@ $totalnb=0; $var=true; foreach ($listofstatus as $status) { - + print ''; print ''; print ''; @@ -191,7 +203,7 @@ if ($resql) $var = True; while ($i < $num) { - + $obj = $db->fetch_object($resql); print ''; diff --git a/htdocs/expensereport/index.php b/htdocs/expensereport/index.php index 0d9bcd20577..77db05da49a 100644 --- a/htdocs/expensereport/index.php +++ b/htdocs/expensereport/index.php @@ -118,14 +118,23 @@ print "\n"; $listoftype=$tripandexpense_static->listOfTypes(); foreach ($listoftype as $code => $label) { - $dataseries[]=array('label'=>$label,'data'=>(isset($somme[$code])?(int) $somme[$code]:0)); + $dataseries[]=array($label, (isset($somme[$code])?(int) $somme[$code]:0)); } if ($conf->use_javascript_ajax) { - print ''; } @@ -208,7 +217,7 @@ if ($result) print $expensereportstatic->LibStatut($obj->fk_status,3); print ''; print ''; - + $i++; } diff --git a/htdocs/fichinter/index.php b/htdocs/fichinter/index.php index 53116dae843..d7cae075eb1 100644 --- a/htdocs/fichinter/index.php +++ b/htdocs/fichinter/index.php @@ -3,7 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2015 Charlie Benke - + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -121,15 +121,25 @@ if ($resql) $bool=false; foreach ($listofstatus as $status) { - $dataseries[]=array('label'=>$fichinterstatic->LibStatut($status,$bool,1),'data'=>(isset($vals[$status.$bool])?(int) $vals[$status.$bool]:0)); + $dataseries[]=array($fichinterstatic->LibStatut($status,$bool,1), (isset($vals[$status.$bool])?(int) $vals[$status.$bool]:0)); if ($status==3 && ! $bool) $bool=true; else $bool=false; } if ($conf->use_javascript_ajax) { print ''; } $var=true; @@ -138,7 +148,7 @@ if ($resql) { if (! $conf->use_javascript_ajax) { - + print ''; print ''; print ''; print ''; @@ -311,7 +321,7 @@ if (! empty($conf->ficheinter->enabled)) $var = true; while ($i < $num) { - + $obj = $db->fetch_object($resql); print ''; print '\n"; foreach (array(0,1,2,3,4,5,6) as $statut) { - $dataseries[]=array('label'=>$commandestatic->LibStatut($statut,1),'data'=>(isset($vals[$statut])?(int) $vals[$statut]:0)); + $dataseries[]=array($commandestatic->LibStatut($statut,1), (isset($vals[$statut])?(int) $vals[$statut]:0)); if (! $conf->use_javascript_ajax) { - + print ''; print ''; print ''; @@ -129,8 +129,17 @@ if ($resql) if ($conf->use_javascript_ajax) { print ''; } //if ($totalinprocess != $total) @@ -177,7 +186,7 @@ if ($resql) while ($i < $num) { $row = $db->fetch_row($resql); - + print ''; print ''; @@ -225,7 +234,7 @@ if (! empty($conf->fournisseur->enabled)) $var = True; while ($i < $num) { - + $obj = $db->fetch_object($resql); print ''; print ''; print ''; diff --git a/htdocs/product/index.php b/htdocs/product/index.php index 3e29bf4e041..6eebc4d85e2 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -221,25 +221,38 @@ if (! empty($conf->categorie->enabled) && ! empty($conf->global->CATEGORY_GRAPHS { $obj = $db->fetch_object($result); if ($i < $nbmax) - $dataseries[]=array('label'=>$obj->label,'data'=>round($obj->nb)); + { + $dataseries[]=array($obj->label, round($obj->nb)); + } else + { $rest+=$obj->nb; + } $total+=$obj->nb; $i++; } if ($i > $nbmax) - $dataseries[]=array('label'=>$langs->trans("Other"),'data'=>round($rest)); - $data=array('series'=>$dataseries); - dol_print_graph('statscategproduct',300,180,$data,1,'pie',0); + { + $dataseries[]=array($langs->trans("Other"), round($rest)); + } + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->setShowLegend(1); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setWidth('100%'); + $dolgraph->draw('idstatscategproduct'); + print $dolgraph->show($total?0:1); } else { - $var=true; while ($i < $num) { $obj = $db->fetch_object($result); - print ''; + print ''; $total+=$obj->nb; $i++; } diff --git a/htdocs/projet/graph_opportunities.inc.php b/htdocs/projet/graph_opportunities.inc.php index 60b0ffa0809..8c919b5d213 100644 --- a/htdocs/projet/graph_opportunities.inc.php +++ b/htdocs/projet/graph_opportunities.inc.php @@ -52,7 +52,6 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) print '
'; print '
'.$langs->trans("Statistics").'
'; + print '
'; $SommeA=0; $SommeB=0; $SommeC=0; $SommeD=0; + $total=0; $dataval=array(); $datalabels=array(); $i=0; @@ -187,14 +188,23 @@ if ($conf->use_javascript_ajax) $SommeD+=isset($MembersResiliated[$key])?$MembersResiliated[$key]:0; $i++; } - + $total = $SommeA + $SommeB + $SommeC + $SommeD; $dataseries=array(); - $dataseries[]=array('label'=>$langs->trans("MenuMembersNotUpToDate"),'data'=>round($SommeB)); - $dataseries[]=array('label'=>$langs->trans("MenuMembersUpToDate"),'data'=>round($SommeC)); - $dataseries[]=array('label'=>$langs->trans("MembersStatusResiliated"),'data'=>round($SommeD)); - $dataseries[]=array('label'=>$langs->trans("MembersStatusToValid"),'data'=>round($SommeA)); - $data=array('series'=>$dataseries); - dol_print_graph('stats',300,180,$data,1,'pie',1); + $dataseries[]=array($langs->trans("MenuMembersNotUpToDate"), round($SommeB)); + $dataseries[]=array($langs->trans("MenuMembersUpToDate"), round($SommeC)); + $dataseries[]=array($langs->trans("MembersStatusResiliated"), round($SommeD)); + $dataseries[]=array($langs->trans("MembersStatusToValid"), round($SommeA)); + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->setShowLegend(1); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setWidth('100%'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($total?0:1); + print '
'.$langs->trans("Total").''; print $SommeA+$SommeB+$SommeC+$SommeD; diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index a54ceb32f0b..42a7bb4b448 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004-2017 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -61,7 +61,6 @@ print '
'; if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo { - $var=false; print '
'; print ''; print ''; @@ -115,14 +114,13 @@ if ($resql) print '
'; print ''."\n"; - $var=true; $listofstatus=array(0,1,2,3,4); foreach ($listofstatus as $status) { - $dataseries[]=array('label'=>$propalstatic->LibStatut($status,1),'data'=>(isset($vals[$status])?(int) $vals[$status]:0)); + $dataseries[]=array($propalstatic->LibStatut($status,1), (isset($vals[$status])?(int) $vals[$status]:0)); if (! $conf->use_javascript_ajax) { - + print ''; print ''; print ''; @@ -131,9 +129,18 @@ if ($resql) } if ($conf->use_javascript_ajax) { - print ''; } //if ($totalinprocess != $total) @@ -173,10 +180,8 @@ if (! empty($conf->propal->enabled)) if ($num) { $i = 0; - $var = True; while ($i < $num) { - $obj = $db->fetch_object($resql); print ''; @@ -233,10 +238,8 @@ if ($resql) if ($num) { $i = 0; - $var = True; while ($i < $num) { - $obj = $db->fetch_object($resql); print ''; @@ -308,8 +311,6 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) $i = 0; if ($num > 0) { - $var=true; - print '
'.$langs->trans("Statistics").' - '.$langs->trans("Proposals").'
'.$propalstatic->LibStatut($status,0).''.(isset($vals[$status])?$vals[$status]:0).'
'; - $data=array('series'=>$dataseries); - dol_print_graph('stats',300,180,$data,1,'pie',1); + print '
'; + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->setShowLegend(1); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setWidth('100%'); + $dolgraph->draw('idgraphthirdparties'); + print $dolgraph->show($total?0:1); + print '
'; print ''; @@ -317,7 +318,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire) while ($i < $nbofloop) { $obj = $db->fetch_object($result); - + print ''; // Ref @@ -402,10 +403,9 @@ if (! empty($conf->propal->enabled)) if ($num) { $i = 0; - $var = True; while ($i < $num) { - + $obj = $db->fetch_object($resql); print ''; print ''; print '
'.$langs->trans("ProposalsOpened").' '.$num.'
'; @@ -474,10 +474,9 @@ if (! empty($conf->propal->enabled)) if ($num) { $i = 0; - $var = True; while ($i < $num) { - + $obj = $db->fetch_object($resql); print '
'; diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index 1a694336714..feacdd70b07 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -79,7 +79,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele * Statistics */ -$sql = "SELECT count(c.rowid), c.fk_statut, c.facture"; +$sql = "SELECT count(c.rowid), c.fk_statut"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."commande as c"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; @@ -87,7 +87,8 @@ $sql.= " WHERE c.fk_soc = s.rowid"; $sql.= " AND c.entity IN (".getEntity('societe').")"; if ($user->societe_id) $sql.=' AND c.fk_soc = '.$user->societe_id; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql.= " GROUP BY c.fk_statut, c.facture"; +$sql.= " GROUP BY c.fk_statut"; + $resql = $db->query($sql); if ($resql) { @@ -98,7 +99,6 @@ if ($resql) $totalinprocess=0; $dataseries=array(); $vals=array(); - $bool=false; // -1=Canceled, 0=Draft, 1=Validated, 2=Accepted/On process, 3=Closed (Sent/Received, billed or not) while ($i < $num) { @@ -107,8 +107,7 @@ if ($resql) { //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) { - $bool=(! empty($row[2])?true:false); - if (! isset($vals[$row[1].$bool])) $vals[$row[1].$bool]=0; + if (! isset($vals[$row[1]])) $vals[$row[1]]=0; $vals[$row[1].$bool]+=$row[0]; $totalinprocess+=$row[0]; } @@ -119,37 +118,38 @@ if ($resql) $db->free($resql); print ''; print ''."\n"; - $listofstatus=array(0,1,2,3,3,-1); - $bool=false; + $listofstatus=array(0,1,2,3,-1); foreach ($listofstatus as $status) { - $dataseries[]=array('label'=>$commandestatic->LibStatut($status,$bool,1),'data'=>(isset($vals[$status.$bool])?(int) $vals[$status.$bool]:0)); - if ($status==3 && ! $bool) $bool=true; - else $bool=false; + $dataseries[]=array($commandestatic->LibStatut($status,$bool,1), (isset($vals[$status.$bool])?(int) $vals[$status.$bool]:0)); } if ($conf->use_javascript_ajax) { print ''; } - $var=true; - $bool=false; - foreach ($listofstatus as $status) + else { - if (! $conf->use_javascript_ajax) - { - - print ''; + foreach ($listofstatus as $status) + { + print ''; print ''; print ''; print "\n"; - if ($status==3 && ! $bool) $bool=true; - else $bool=false; } } //if ($totalinprocess != $total) diff --git a/htdocs/compta/deplacement/index.php b/htdocs/compta/deplacement/index.php index fdb7e46900c..2cd3823bacd 100644 --- a/htdocs/compta/deplacement/index.php +++ b/htdocs/compta/deplacement/index.php @@ -106,14 +106,23 @@ print "\n"; $listoftype=$tripandexpense_static->listOfTypes(); foreach ($listoftype as $code => $label) { - $dataseries[]=array('label'=>$label,'data'=>(isset($nb[$code])?(int) $nb[$code]:0)); + $dataseries[]=array($label, (isset($nb[$code])?(int) $nb[$code]:0)); } if ($conf->use_javascript_ajax) { - print ''; } @@ -180,7 +189,7 @@ if ($result) print ''; print ''; print ''; - + $i++; } diff --git a/htdocs/contrat/index.php b/htdocs/contrat/index.php index e0874d41595..5cd0d3773de 100644 --- a/htdocs/contrat/index.php +++ b/htdocs/contrat/index.php @@ -184,7 +184,7 @@ print ''; } $listofstatus=array(0,4,4,5); $bool=false; diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 988a3e2d352..34924681c87 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -125,7 +125,7 @@ $arrayfields=array( 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>0), 'state.nom'=>array('label'=>$langs->trans("StateShort"), 'checked'=>0), 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0), - 'sale_representative'=>array('label'=>$langs->trans("SalesRepresentative"), 'checked'=>1), + 'sale_representative'=>array('label'=>$langs->trans("SaleRepresentativesOfThirdParty"), 'checked'=>1), 'c.date_contrat'=>array('label'=>$langs->trans("DateContract"), 'checked'=>1), 'c.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 'c.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), @@ -740,10 +740,16 @@ if ($resql) $userstatic->id=$val['id']; $userstatic->lastname=$val['lastname']; $userstatic->firstname=$val['firstname']; - print '
'.$userstatic->getNomUrl(1); + $userstatic->email=$val['email']; + $userstatic->statut=$val['statut']; + $userstatic->entity=$val['entity']; + $userstatic->photo=$val['photo']; + + //print '
': + print $userstatic->getNomUrl(-2); $j++; - if ($j < $nbofsalesrepresentative) print ', '; - print '
'; + if ($j < $nbofsalesrepresentative) print ' '; + //print '
'; } } //else print $langs->trans("NoSalesRepresentativeAffected"); diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index f2885a50951..329383160aa 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -27,7 +27,7 @@ * Class to build graphs. * Usage is: * $dolgraph=new DolGraph(); - * $dolgraph->SetTitle($langs->transnoentities('Tracking_Projects_Pourcent').'
'.$langs->transnoentities('Tracking_IndicatorDefGraph').'%'); + * $dolgraph->SetTitle($langs->transnoentities('MyTitle').'
'.$langs->transnoentities('MyTitlePercent').'%'); * $dolgraph->SetMaxValue(50); * $dolgraph->SetData($data); * $dolgraph->setShowLegend(1); @@ -35,7 +35,7 @@ * $dolgraph->SetType(array('pie')); * $dolgraph->setWidth('100%'); * $dolgraph->draw('idofgraph'); - * print $dolgraph->show(); + * print $dolgraph->show($total?0:1); */ class DolGraph { @@ -796,7 +796,7 @@ class DolGraph * Build a graph using JFlot library. Input when calling this method should be: * $this->data = array(array(0=>'labelxA',1=>yA), array('labelxB',yB)); * $this->data = array(array(0=>'labelxA',1=>yA1,...,n=>yAn), array('labelxB',yB1,...yBn)); // or when there is n series to show for each x - * $this->data = array(array('label'=>'labelxA','data'=>yA), array('labelxB',yB)); // TODO Syntax not supported. Removed when dol_print_graph_removed + * $this->data = array(array('label'=>'labelxA','data'=>yA), array('labelxB',yB)); // Syntax deprecated * $this->legend= array("Val1",...,"Valn"); // list of n series name * $this->type = array('bars',...'lines'); or array('pie') * $this->mode = 'depth' ??? @@ -1041,10 +1041,20 @@ class DolGraph /** * Output HTML string to show graph * - * @return string HTML string to show graph + * @param int $shownographyet Show graph to say there is not enough data + * @return string HTML string to show graph */ - function show() + function show($shownographyet=0) { + global $langs; + + if ($shownographyet) + { + $s= '
'; + $s.='
'.$langs->trans("NotEnoughDataYet").'
'; + return $s; + } + return $this->stringtoshow; } diff --git a/htdocs/don/index.php b/htdocs/don/index.php index 4912b6d8f1a..e9a12861968 100644 --- a/htdocs/don/index.php +++ b/htdocs/don/index.php @@ -52,6 +52,7 @@ llxHeader('',$langs->trans("Donations"),$help_url); $nb=array(); $somme=array(); +$total = 0; $sql = "SELECT count(d.rowid) as nb, sum(d.amount) as somme , d.fk_statut"; $sql.= " FROM ".MAIN_DB_PREFIX."don as d"; @@ -69,6 +70,8 @@ if ($result) $somme[$objp->fk_statut] = $objp->somme; $nb[$objp->fk_statut] = $objp->nb; + $total += $objp->somme; + $i++; } $db->free($result); @@ -87,7 +90,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele { $listofsearchfields['search_donation']=array('text'=>'Donation'); } - + if (count($listofsearchfields)) { print ''; @@ -103,7 +106,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele print ''; $i++; } - print '
'.$langs->trans("Statistics").' - '.$langs->trans("CustomersOrders").'
'; - $data=array('series'=>$dataseries); - dol_print_graph('stats',300,180,$data,1,'pie',1); + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->setShowLegend(1); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setWidth('100%'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($total?0:1); + print '
'.$commandestatic->LibStatut($status,$bool,0).''.(isset($vals[$status.$bool])?$vals[$status.$bool]:0).' '; print $commandestatic->LibStatut($status,$bool,3); print ''; print '
'; - $data=array('series'=>$dataseries); - dol_print_graph('stats',300,180,$data,1,'pie',1); + print '
'; + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->setShowLegend(1); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setWidth('100%'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($totalnb?0:1); + print '
'.dol_print_date($db->jdate($obj->dm),'day').''.$deplacementstatic->LibStatut($obj->fk_statut,3).'
'.$langs->trans("Statistics").' - $listofstatus=array(0,4,4,5); $bool=false; foreach($listofstatus as $status) { - $dataseries[]=array('label'=>$staticcontratligne->LibStatut($status,1,($bool?1:0)),'data'=>(isset($nb[$status.$bool])?(int) $nb[$status.$bool]:0)); + $dataseries[]=array($staticcontratligne->LibStatut($status,1,($bool?1:0)),(isset($nb[$status.$bool])?(int) $nb[$status.$bool]:0)); if (empty($conf->use_javascript_ajax)) { @@ -199,8 +199,17 @@ foreach($listofstatus as $status) if (! empty($conf->use_javascript_ajax)) { print '
'; - $data=array('series'=>$dataseries); - dol_print_graph('stats',300,180,$data,1,'pie',1); + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->setShowLegend(1); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setWidth('100%'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($total?0:1); + print '
'; + print '
'; print '
'; print '
'; } @@ -118,14 +121,23 @@ print "
'; - $data=array('series'=>$dataseries); - dol_print_graph('stats',300,180,$data,1,'pie',1); + print '
'; + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->setShowLegend(1); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setWidth('100%'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($total?0:1); + print '
'.$donstatic->LibStatut($status,4).''.(! empty($nb[$status])?$nb[$status]:' ').'
'; - $data=array('series'=>$dataseries); - dol_print_graph('stats',320,180,$data,1,'pie',0,'',0); + print '
'; + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->setShowLegend(1); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setWidth('100%'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($totalnb?0:1); + print '
'; + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->setShowLegend(1); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setWidth('100%'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($total?0:1); $data=array('series'=>$dataseries); - dol_print_graph('stats',300,180,$data,1,'pie',1); + print '
'.$fichinterstatic->LibStatut($status,$bool,0).''.(isset($vals[$status.$bool])?$vals[$status.$bool]:0).' '; @@ -190,7 +200,7 @@ if (! empty($conf->ficheinter->enabled)) $var = true; while ($i < $num) { - + $obj = $db->fetch_object($resql); print '
'; @@ -240,7 +250,7 @@ if ($resql) $var = true; while ($i < $num) { - + $obj = $db->fetch_object($resql); print '
'; diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php index 89ad3f77c3a..84ccb017266 100644 --- a/htdocs/fichinter/list.php +++ b/htdocs/fichinter/list.php @@ -304,7 +304,7 @@ if ($resql) $topicmail="Information"; $modelmail="intervention"; - $objecttmp=new Intervention($db); + $objecttmp=new Fichinter($db); $trackid='int'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index ccb54930573..ca395d0cf47 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -116,10 +116,10 @@ if ($resql) print "
'.$commandestatic->LibStatut($statut,0).''.(isset($vals[$statut])?$vals[$statut]:0).'
'; - $data=array('series'=>$dataseries); - dol_print_graph('stats',300,180,$data,1,'pie',1,'',0); + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->setShowLegend(1); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setWidth('100%'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($total?0:1); + print '
'.$langs->trans($commandestatic->statuts[$row[1]]).'
'; @@ -268,7 +277,7 @@ if ($resql) while ($i < $num) { $obj = $db->fetch_object($resql); - + print '
'; @@ -324,7 +333,7 @@ if ($resql) $var = True; while ($i < $num) { - + $obj = $db->fetch_object($resql); print '
'.$obj->label.''.$obj->nb.'
'.$obj->label.''.$obj->nb.'
'; print ''."\n"; - $var=true; $listofstatus=array_keys($listofoppstatus); foreach ($listofstatus as $status) { @@ -65,7 +64,7 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) //$labelstatus .= ' ('.$langs->trans("Coeff").': '.price2num($listofoppstatus[$status]).')'; //$labelstatus .= ' - '.price2num($listofoppstatus[$status]).'%'; - $dataseries[]=array('label'=>$labelstatus,'data'=>(isset($valsamount[$status])?(float) $valsamount[$status]:0)); + $dataseries[]=array($labelstatus, (isset($valsamount[$status])?(float) $valsamount[$status]:0)); if (! $conf->use_javascript_ajax) { @@ -77,9 +76,19 @@ if (! empty($conf->global->PROJECT_USE_OPPORTUNITIES)) } if ($conf->use_javascript_ajax) { - print ''; } //if ($totalinprocess != $total) diff --git a/htdocs/supplier_proposal/index.php b/htdocs/supplier_proposal/index.php index 1c16d48e086..4b25dfb82ac 100644 --- a/htdocs/supplier_proposal/index.php +++ b/htdocs/supplier_proposal/index.php @@ -122,10 +122,10 @@ if ($resql) $listofstatus=array(0,1,2,3,4); foreach ($listofstatus as $status) { - $dataseries[]=array('label'=>$supplier_proposalstatic->LibStatut($status,1),'data'=>(isset($vals[$status])?(int) $vals[$status]:0)); + $dataseries[]=array($supplier_proposalstatic->LibStatut($status,1), (isset($vals[$status])?(int) $vals[$status]:0)); if (! $conf->use_javascript_ajax) { - + print ''; print ''; print ''; @@ -134,9 +134,18 @@ if ($resql) } if ($conf->use_javascript_ajax) { - print ''; } @@ -178,7 +187,7 @@ if (! empty($conf->supplier_proposal->enabled)) $var = True; while ($i < $num) { - + $obj = $db->fetch_object($resql); print ''; @@ -236,7 +245,7 @@ if ($resql) $var = True; while ($i < $num) { - + $obj = $db->fetch_object($resql); print ''; @@ -317,7 +326,7 @@ if (! empty($conf->supplier_proposal->enabled) && $user->rights->supplier_propos while ($i < $nbofloop) { $obj = $db->fetch_object($result); - + print ''; // Ref From abe13d108b40975b5fd28ee2a75b7915ca4fbbdc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Nov 2017 09:23:18 +0100 Subject: [PATCH 10/19] Clean code used for autocompletion --- htdocs/barcode/printsheet.php | 4 +- htdocs/core/class/html.form.class.php | 44 +++++++------------- htdocs/core/class/html.formbarcode.class.php | 1 + 3 files changed, 17 insertions(+), 32 deletions(-) diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index e8deb15a8d2..27674fe7ad0 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -292,9 +292,9 @@ foreach(array_keys($_Avery_Labels) as $codecards) $labeltoshow=$_Avery_Labels[$codecards]['name']; //$labeltoshow.=' ('.$_Avery_Labels[$row['code']]['paper-size'].')'; $arrayoflabels[$codecards]=$labeltoshow; - $arrayoflabels[$codecards]=$_Avery_Labels[$codecards]['name']; } -print $form->selectarray('modellabel',$arrayoflabels,(GETPOST('modellabel')?GETPOST('modellabel'):$conf->global->ADHERENT_ETIQUETTE_TYPE),1,0,0); +asort($arrayoflabels); +print $form->selectarray('modellabel', $arrayoflabels, (GETPOST('modellabel')?GETPOST('modellabel'):$conf->global->ADHERENT_ETIQUETTE_TYPE), 1, 0, 0, '', 0, 0, 0, '', '', 1); print ''; // Number of stickers to print diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6ec92a69d11..afcc2e047f6 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1096,11 +1096,10 @@ class Form $resql=$this->db->query($sql); if ($resql) { - if ($conf->use_javascript_ajax && ! $forcecombo) + if (! $forcecombo) { include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $comboenhancement =ajax_combobox($htmlname, $events, $conf->global->COMPANY_USE_SEARCH_TO_SELECT); - $out.= $comboenhancement; + $out .= ajax_combobox($htmlname, $events, $conf->global->COMPANY_USE_SEARCH_TO_SELECT); } // Construct $out and $outarray @@ -1333,8 +1332,7 @@ class Form if ($conf->use_javascript_ajax && ! $forcecombo && ! $options_only) { include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $comboenhancement = ajax_combobox($htmlid, $events, $conf->global->CONTACT_USE_SEARCH_TO_SELECT); - $out.= $comboenhancement; + $out .= ajax_combobox($htmlid, $events, $conf->global->CONTACT_USE_SEARCH_TO_SELECT); } if ($htmlname != 'none' || $options_only) $out.= ''; @@ -2023,11 +2017,10 @@ class Form $events=null; - if ($conf->use_javascript_ajax && ! $forcecombo) + if (! $forcecombo) { include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $comboenhancement =ajax_combobox($htmlname, $events, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT); - $out.= $comboenhancement; + $out .= ajax_combobox($htmlname, $events, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT); } $out.='use_javascript_ajax) - { - include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; - $comboenhancement = ajax_combobox($htmlname); - $out.= $comboenhancement; - } + include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; + $out .= ajax_combobox($htmlname); $out.= '"; + print ajax_combobox("select_".$htmlname); } else { dol_print_error($this->db); From f0d0969a3b48a03f046bc47dc8afc6ed565acfab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Nov 2017 09:30:21 +0100 Subject: [PATCH 11/19] Better name for generated page of barcodes --- htdocs/barcode/printsheet.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/barcode/printsheet.php b/htdocs/barcode/printsheet.php index 27674fe7ad0..04a181d3613 100644 --- a/htdocs/barcode/printsheet.php +++ b/htdocs/barcode/printsheet.php @@ -236,7 +236,10 @@ if ($action == 'builddoc') { $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("DescADHERENT_ETIQUETTE_TYPE")); } - if (! $mesg) $result=doc_label_pdf_create($db, $arrayofrecords, $modellabel, $outputlangs, $diroutput, $template, 'tmp_barcode_sheet.pdf'); + + $outfile = $langs->trans("BarCode").'_sheets_'.dol_print_date(dol_now(),'dayhourlog').'.pdf'; + + if (! $mesg) $result=doc_label_pdf_create($db, $arrayofrecords, $modellabel, $outputlangs, $diroutput, $template, dol_sanitizeFileName($outfile)); } if ($result <= 0) From 6d5f2b2f21cd752dfaba306237912f6d16f6b588 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Nov 2017 10:00:46 +0100 Subject: [PATCH 12/19] Fix filters on surveys --- htdocs/fourn/card.php | 2 +- htdocs/opensurvey/card.php | 2 +- htdocs/opensurvey/list.php | 42 +++++++++++++++++++++----------------- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 08a57fae706..6f473f8deb3 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -132,7 +132,7 @@ if ($object->id > 0) dol_fiche_head($head, 'supplier', $langs->trans("ThirdParty"), -1, 'company'); - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom'); diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index 4d71efe6395..2768b32ba3f 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -216,7 +216,7 @@ dol_fiche_head($head,'general',$langs->trans("Survey"), -1, DOL_URL_ROOT.'/opens $morehtmlref = ''; -$linkback = ''.$langs->trans("BackToList").''; +$linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, 1, 'id_sondage', 'id_sondage', $morehtmlref); diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index 0ca1819e7bc..41ae2778080 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2013-2017 Laurent Destailleur * Copyright (C) 2014 Marcos García * * This program is free software; you can redistribute it and/or modify @@ -34,9 +34,8 @@ $action=GETPOST('action','aZ09'); $id=GETPOST('id','alpha'); $numsondage= $id; $search_ref = GETPOST('search_ref', 'alpha'); -$surveytitle=GETPOST('surveytitle', 'alpha'); -$status=GETPOST('status', 'int'); -//if (! isset($_POST['status']) && ! isset($_GET['status'])) $status='opened'; // If filter unknown, we choose 'opened' +$search_title = GETPOST('search_title', 'alpha'); +$search_status = GETPOST('search_status', 'alpha'); $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); @@ -58,10 +57,10 @@ $langs->load("opensurvey"); * Actions */ -if (GETPOST('button_removefilter')) +if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers { - $status=''; - $surveytitle=''; + $search_status=''; + $search_title=''; $search_ref=''; } @@ -75,7 +74,7 @@ $opensurvey_static = new Opensurveysondage($db); $now = dol_now(); -llxHeader(); +llxHeader('', $langs->trans("OpenSurveyArea")); $param=''; $fieldtosortuser=empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?'firstname':'lastname'; @@ -98,13 +97,13 @@ print '
'.$langs->trans("Statistics").' - '.$langs->trans("OpportunitiesStatusForOpenedProjects").'
'; - $data=array('series'=>$dataseries); - dol_print_graph('stats',360,180,$data,1,'pie',0,'',0,$totaloppnb?0:1); + print '
'; + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->setShowLegend(1); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setWidth('100%'); + $dolgraph->SetHeight(180); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($totaloppnb?0:1); + print '
'.$supplier_proposalstatic->LibStatut($status,0).''.(isset($vals[$status])?$vals[$status]:0).'
'; - $data=array('series'=>$dataseries); - dol_print_graph('stats',300,180,$data,1,'pie',1,'',0); + print '
'; + + include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; + $dolgraph = new DolGraph(); + $dolgraph->SetData($dataseries); + $dolgraph->setShowLegend(1); + $dolgraph->setShowPercent(1); + $dolgraph->SetType(array('pie')); + $dolgraph->setWidth('100%'); + $dolgraph->draw('idgraphstatus'); + print $dolgraph->show($total?0:1); + print '
'; print ''; -print ''; +print ''; print ''; print ''; print ''; -$arraystatus=array(''=>' ','expired'=>$langs->trans("Expired"),'opened'=>$langs->trans("Opened")); -print ''; print ''; +$arraystatus=array('-1'=>' ','0'=>$langs->trans("Draft"),'1'=>$langs->trans("Opened"),'2'=>$langs->trans("Closed")); +print ''; print ''."\n"; print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.id_sondage", $param,"","",$sortfield,$sortorder); print_liste_field_titre("Title", $_SERVER["PHP_SELF"], "p.titre", $param,"","",$sortfield,$sortorder); -print_liste_field_titre("Type"); +print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "p.format", $param,"","",$sortfield,$sortorder); print_liste_field_titre("Author", $_SERVER["PHP_SELF"], "u.".$fieldtosortuser, $param,"","",$sortfield,$sortorder); print_liste_field_titre("NbOfVoters", $_SERVER["PHP_SELF"], "", $param,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre("ExpireDate", $_SERVER["PHP_SELF"], "p.date_fin", $param,"",'align="center"',$sortfield,$sortorder); @@ -125,7 +124,7 @@ print ''."\n"; $sql = "SELECT p.id_sondage, p.fk_user_creat, p.format, p.date_fin, p.status, p.titre, p.nom_admin,"; $sql.= " u.login, u.firstname, u.lastname"; $sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p"; -$sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat"; // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -134,11 +133,11 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } $sql.= " WHERE p.entity = ".getEntity('survey'); -if ($status == 'expired') $sql.=" AND date_fin < '".$db->idate($now)."'"; -if ($status == 'opened') $sql.=" AND date_fin >= '".$db->idate($now)."'"; +if ($search_status != '-1' && $search_status != '') $sql.=natural_search("p.status", $search_status, 2); +if ($search_expired == 'expired') $sql.=" AND p.date_fin < '".$db->idate($now)."'"; +if ($search_expired == 'opened') $sql.=" AND p.date_fin >= '".$db->idate($now)."'"; if ($search_ref) $sql.=natural_search("p.id_sondage", $search_ref); -if ($surveytitle) $sql.=natural_search("p.titre", $surveytitle); - +if ($search_title) $sql.=natural_search("p.titre", $search_title); $sql.= $db->order($sortfield,$sortorder); // Count total nb of records @@ -149,7 +148,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $nbtotalofrecords = $db->num_rows($result); } -$sql.= $db->plimit($limit + 1,$offset); +$sql.= $db->plimit($limit+1, $offset); $resql=$db->query($sql); if (! $resql) dol_print_error($db); @@ -174,6 +173,7 @@ while ($i < min($num,$limit)) $opensurvey_static->ref=$obj->id_sondage; $opensurvey_static->title=$obj->titre; $opensurvey_static->status=$obj->status; + $opensurvey_static->date_fin=$db->jdate($obj->date_fin); print ''; @@ -183,7 +183,10 @@ while ($i < min($num,$limit)) print ''; // Title - print ''; + + // Type + print ''; + // Nb of voters print''."\n"; print ''; diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index 41ae2778080..9d0f2c1ed13 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -211,7 +211,7 @@ while ($i < min($num,$limit)) print''."\n"; print ''; print''."\n"; diff --git a/htdocs/opensurvey/results.php b/htdocs/opensurvey/results.php index 49f26e47cb0..cd6e6ed3225 100644 --- a/htdocs/opensurvey/results.php +++ b/htdocs/opensurvey/results.php @@ -389,13 +389,13 @@ for ($i = 0; $i < $nbcolonnes; $i++) * View */ +$form=new Form($db); + if ($object->fk_user_creat) { $userstatic = new User($db); $userstatic->fetch($object->fk_user_creat); } -$form=new Form($db); - $result=$object->fetch(0,$numsondage); if ($result <= 0) { @@ -430,7 +430,7 @@ dol_fiche_head($head,'preview',$langs->trans("Survey"), -1, DOL_URL_ROOT.'/opens $morehtmlref = ''; -$linkback = ''.$langs->trans("BackToList").''; +$linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, 1, 'id_sondage', 'id_sondage', $morehtmlref); From 3db52b5f9ea228b9e6dc572350bc3df22a67e410 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Nov 2017 14:23:25 +0100 Subject: [PATCH 14/19] Debug responsive of v7 --- htdocs/compta/bank/releve.php | 7 ++-- htdocs/compta/facture/card.php | 3 +- htdocs/compta/facture/prelevement.php | 9 ++++-- htdocs/core/js/lib_head.js.php | 35 ++++++++++---------- htdocs/core/lib/functions.lib.php | 46 +++++++++++++++++---------- htdocs/fourn/facture/info.php | 1 + htdocs/theme/eldy/style.css.php | 20 +++++++++++- htdocs/theme/md/style.css.php | 12 ++++++- 8 files changed, 90 insertions(+), 43 deletions(-) diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index fb43f098583..aadc9d47bde 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -41,10 +41,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; -$langs->load("banks"); -$langs->load("categories"); -$langs->load("companies"); -$langs->load("bills"); +$langs->loadLangs(array("banks","categories","companies","bills","trips")); $action=GETPOST('action', 'alpha'); $id=GETPOST('account','int'); @@ -705,7 +702,7 @@ else $newline=0; } elseif ($links[$key]['type']=='user') { - print ''; + print ''; print img_object($langs->trans('ShowUser'),'user').' '; print $links[$key]['label']; print ''; diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index dd7c6bc51e5..733ef9e9f16 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3791,7 +3791,7 @@ else if ($id > 0 || ! empty($ref)) // List of payments already done - + print '
'; print '
'. $form->selectarray('status', $arraystatus, $status).''. $form->selectarray('search_status', $arraystatus, $search_status).''; $searchpicto=$form->showFilterAndCheckAddButtons(0); print $searchpicto; @@ -114,7 +113,7 @@ print '
'.dol_htmlentities($obj->titre).''; + print ''.dol_htmlentities($obj->titre).''; $type=($obj->format=='A')?'classic':'date'; print img_picto('',dol_buildpath('/opensurvey/img/'.($type == 'classic'?'chart-32.png':'calendar-32.png'),1),'width="16"',1); print ' '.$langs->trans($type=='classic'?"TypeClassic":"TypeDate"); @@ -204,6 +207,7 @@ while ($i < min($num,$limit)) print ''.$nbuser.''.dol_print_date($db->jdate($obj->date_fin),'day'); From 8450c78dffaed879026f78bd3eeb3bdffb915a88 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Nov 2017 10:06:42 +0100 Subject: [PATCH 13/19] Fix warning on late surveys --- htdocs/opensurvey/card.php | 2 +- htdocs/opensurvey/list.php | 2 +- htdocs/opensurvey/results.php | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php index 2768b32ba3f..fda06d67012 100644 --- a/htdocs/opensurvey/card.php +++ b/htdocs/opensurvey/card.php @@ -310,7 +310,7 @@ if ($action == 'edit') print $form->select_date($expiredate?$expiredate:$object- else { print dol_print_date($object->date_fin,'day'); - if ($object->date_fin && $object->date_fin < dol_now()) print img_warning($langs->trans("Expired")); + if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) print img_warning($langs->trans("Expired")); } print '
'.$nbuser.''.dol_print_date($db->jdate($obj->date_fin),'day'); - if ($db->jdate($obj->date_fin) < time()) { print img_warning($langs->trans("Expired")); } + if ($db->jdate($obj->date_fin) < $now && $obj->status == Opensurveysondage::STATUS_VALIDATED) { print img_warning($langs->trans("Expired")); } print ''.$opensurvey_static->getLibStatut(5).'
'; print ''; @@ -4002,6 +4002,7 @@ else if ($id > 0 || ! empty($ref)) } print '
'; + print ''; // Margin Infos if (! empty($conf->margin->enabled)) { diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 9f2245d38a5..01494955feb 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -591,7 +591,9 @@ if ($object->id > 0) /* * Withdrawals - */ + */ + + print '
'; print ''; print ''; @@ -664,7 +666,6 @@ if ($object->id > 0) { $obj = $db->fetch_object($result); - print ''; print '\n"; @@ -689,7 +690,8 @@ if ($object->id > 0) print "\n"; $i++; } - + if (! $num) + print ''; $db->free($result); } else @@ -698,6 +700,7 @@ if ($object->id > 0) } print "
'.dol_print_date($db->jdate($obj->date_demande),'day')."
'.$langs->trans("None").'
"; + print '
'; } diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index a5f9aa597f0..ca22ad05fd4 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -1067,22 +1067,25 @@ if (empty($conf->global->MAIN_DISABLE_JQUERY_JNOTIFY) && ! defined('DISABLE_JQUE ?> // Defined properties for JNotify $(document).ready(function() { - $.jnotify.setup({ - delay: 3000 // the default time to show each notification (in milliseconds) - , sticky: false // determines if the message should be considered "sticky" (user must manually close notification) - , closeLabel: "×" // the HTML to use for the "Close" link - , showClose: true // determines if the "Close" link should be shown if notification is also sticky - , fadeSpeed: 1000 // the speed to fade messages out (in milliseconds) - , slideSpeed: 250 // the speed used to slide messages out (in milliseconds) - , classContainer: "jnotify-container" - , classNotification: "jnotify-notification" - , classBackground: "jnotify-background" - , classClose: "jnotify-close" - , classMessage: "jnotify-message" - , init: null // callback that occurs when the main jnotify container is created - , create: null // callback that occurs when when the note is created (occurs just before appearing in DOM) - , beforeRemove: null // callback that occurs when before the notification starts to fade away - }); + if (typeof $.jnotify == 'function') + { + $.jnotify.setup({ + delay: 3000 // the default time to show each notification (in milliseconds) + , sticky: false // determines if the message should be considered "sticky" (user must manually close notification) + , closeLabel: "×" // the HTML to use for the "Close" link + , showClose: true // determines if the "Close" link should be shown if notification is also sticky + , fadeSpeed: 1000 // the speed to fade messages out (in milliseconds) + , slideSpeed: 250 // the speed used to slide messages out (in milliseconds) + , classContainer: "jnotify-container" + , classNotification: "jnotify-notification" + , classBackground: "jnotify-background" + , classClose: "jnotify-close" + , classMessage: "jnotify-message" + , init: null // callback that occurs when the main jnotify container is created + , create: null // callback that occurs when when the note is created (occurs just before appearing in DOM) + , beforeRemove: null // callback that occurs when before the notification starts to fade away + }); + } }); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f3b2f3892ca..435ae68fa94 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1119,7 +1119,7 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi if (count($keys)) $maxkey=max($keys); } - //$conf->global->MAIN_MAXTABS_IN_CARD=3; + if (! empty($conf->dol_optimize_smallscreen)) $conf->global->MAIN_MAXTABS_IN_CARD=2; // Show tabs $bactive=false; @@ -1132,9 +1132,8 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi { if ((is_numeric($active) && $i == $active) || (! empty($links[$i][2]) && ! is_numeric($active) && $active == $links[$i][2])) { - // si l'active est présent dans la box - if ($i >= $limittoshow) - $limittoshow--; + // If active tab is already present + if ($i >= $limittoshow) $limittoshow--; } } @@ -1146,7 +1145,9 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi $bactive=true; } else + { $isactive=false; + } if ($i < $limittoshow || $isactive) { @@ -1155,11 +1156,11 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi { if (!empty($links[$i][0])) { - $out.=''.$links[$i][1].''."\n"; + $out.=''.$links[$i][1].''."\n"; } else { - $out.=''.$links[$i][1].''."\n"; + $out.=''.$links[$i][1].''."\n"; } } else if (! empty($links[$i][1])) @@ -1167,11 +1168,15 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi //print "x $i $active ".$links[$i][2]." z"; if ($isactive) { - $out.=''.$links[$i][1].''."\n"; + $out.=''; + $out.=$links[$i][1]; + $out.=''."\n"; } else { - $out.=''.$links[$i][1].''."\n"; + $out.=''; + $out.=$links[$i][1]; + $out.=''."\n"; } } $out.=''; @@ -1182,9 +1187,9 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi if (! $popuptab) { $popuptab=1; - $outmore.='
'; + $outmore.='
'; // The css used to hide/show popup } - $outmore.='
'; + $outmore.='
'; if (isset($links[$i][2]) && $links[$i][2] == 'image') { if (!empty($links[$i][0])) @@ -1194,8 +1199,11 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi } else if (! empty($links[$i][1])) - $outmore.=''.$links[$i][1].''."\n"; - + { + $outmore.=''; + $outmore.=preg_replace('/([a-z])\/([a-z])/i', '\\1 / \\2', $links[$i][1]); // Replace x/y with x / y to allow wrap on long composed texts. + $outmore.=''."\n"; + } $outmore.='
'; $nbintab++; @@ -1206,15 +1214,21 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi if ($displaytab > $limittoshow) { + $left=($langs->trans("DIRECTION") == 'rtl'?'right':'left'); + $right=($langs->trans("DIRECTION") == 'rtl'?'left':'right'); + $tabsname=str_replace("@", "", $picto); $out.='
'; - $out.=''.$langs->trans("More").'... ('.$nbintab.')'; - $out.='
'.$outmore.'
'; + $out.=''.$langs->trans("More").'... ('.$nbintab.')'; + $out.='
'; + $out.=$outmore; + $out.='
'; + $out.='
'; $out.="
\n"; $out.=""; } diff --git a/htdocs/fourn/facture/info.php b/htdocs/fourn/facture/info.php index ffda7e2f4cd..d2241b9841a 100644 --- a/htdocs/fourn/facture/info.php +++ b/htdocs/fourn/facture/info.php @@ -30,6 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +$langs->load('companies'); $langs->load('bills'); $id = GETPOST("facid",'int')?GETPOST("facid",'int'):GETPOST("id",'int'); diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 3a9a0e4a666..fc992bd5cf9 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -456,6 +456,9 @@ fieldset { border: 1px solid #AAAAAA !important; } .trextrafieldseparator td { border-bottom: 2px solid rgb(120,120,120) !important; } +input#onlinepaymenturl, input#directdownloadlink { + opacity: 0.7; +} hr { border: 0; border-top: 1px solid #ccc; } @@ -581,6 +584,9 @@ textarea.centpercent { .nowraponall { white-space: nowrap; } +.wordwrap { + word-wrap: break-word; +} .nobold { font-weight: normal !important; } @@ -911,6 +917,9 @@ select.selectarrowonleft option { body { font-size: px; } + div.refidno { + font-size: px !important; + } } /* Force values for small screen 570 */ @@ -919,6 +928,9 @@ select.selectarrowonleft option { body { font-size: px; } + div.refidno { + font-size: px !important; + } .divmainbodylarge { margin-left: 20px !important; margin-right: 20px !important; } @@ -932,7 +944,8 @@ select.selectarrowonleft option { margin-top: px !important; } div.titre { - line-height: 2em; + margin-top: 12px; + /* line-height: 2em; */ } .border tbody tr, .border tbody tr td, div.tabBar table.border tr, div.tabBar table.border tr td, div.tabBar div.border .table-border-row, div.tabBar div.border .table-key-border-col, div.tabBar div.border .table-val-border-col { height: 40px !important; @@ -4080,6 +4093,7 @@ div#ecm-layout-center { max-width: 1024px; padding-left: 10px !important; padding-right: 10px !important; + word-wrap: break-word; } .jnotify-container .jnotify-notification .jnotify-message { font-weight: normal; @@ -4887,6 +4901,10 @@ div.tabsElem a.tab { div.tmenuleft { display: none; } + + .dropdown dd ul { + max-width: 300px; + } } /* rule to reduce top menu - 2nd reduction */ @media only screen and (max-width: px) /* reduction 2 */ diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index d2b7323983a..59f5ac9208c 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -589,6 +589,9 @@ textarea.centpercent { .nowraponall { white-space: nowrap; } +.wordwrap { + word-wrap: break-word; +} .nobold { font-weight: normal !important; } @@ -908,6 +911,9 @@ select.selectarrowonleft option { body { font-size: px; } + div.refidno { + font-size: px !important; + } } /* Force values for small screen 570 */ @@ -916,6 +922,9 @@ select.selectarrowonleft option { body { font-size: px; } + div.refidno { + font-size: px !important; + } .divmainbodylarge { margin-left: 20px; margin-right: 20px; } @@ -929,7 +938,8 @@ select.selectarrowonleft option { margin-top: px !important; } div.titre { - line-height: 2em; + margin-top: 12px; + /* line-height: 2em; */ } .border tbody tr, .border tbody tr td, div.tabBar table.border tr { height: 40px !important; From 9f235e1ff6f2b6226fa812516c42ab14eef38d7b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Nov 2017 15:27:00 +0100 Subject: [PATCH 15/19] Standardize database: field ref of warehouse was renamed label -> ref --- htdocs/commande/class/commande.class.php | 2 +- htdocs/expedition/card.php | 12 +- .../install/mysql/migration/6.0.0-7.0.0.sql | 2 + htdocs/install/mysql/tables/llx_entrepot.sql | 4 +- .../modulebuilder/template/myobject_card.php | 37 ++-- .../product/class/html.formproduct.class.php | 24 +-- htdocs/product/inventory/card.php | 166 +++++++----------- .../inventory/class/inventory.class.php | 2 +- htdocs/product/reassortlot.php | 8 +- htdocs/product/stock/card.php | 2 +- htdocs/product/stock/class/entrepot.class.php | 31 ++-- htdocs/product/stock/index.php | 25 ++- htdocs/product/stock/list.php | 23 +-- htdocs/product/stock/mouvement.php | 12 +- htdocs/product/stock/product.php | 4 +- htdocs/product/stock/replenish.php | 11 +- htdocs/product/stock/valo.php | 15 +- 17 files changed, 189 insertions(+), 191 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 1fcf4bf8427..7b455234b39 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -768,7 +768,7 @@ class Commande extends CommonOrder $sql.= ", multicurrency_code"; $sql.= ", multicurrency_tx"; $sql.= ")"; - $sql.= " VALUES ('(PROV)',".$this->socid.", '".$this->db->idate($now)."', ".$user->id; + $sql.= " VALUES ('(PROV)', ".$this->socid.", '".$this->db->idate($now)."', ".$user->id; $sql.= ", ".($this->fk_project>0?$this->fk_project:"null"); $sql.= ", '".$this->db->idate($date)."'"; $sql.= ", ".($this->source>=0 && $this->source != '' ?$this->db->escape($this->source):'null'); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index e85cb70a74d..acd6730dc35 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -750,7 +750,7 @@ if (empty($reshook)) } } } - if ($lineIdToAddLot) + if ($lineIdToAddLot) { // add lot to existing line if ($line->fetch($lineIdToAddLot) > 0) @@ -787,7 +787,7 @@ if (empty($reshook)) } } } - else + else { setEventMessages($lotStock->error, $lotStock->errors, 'errors'); $error++; @@ -2477,7 +2477,7 @@ else if ($id || $ref) } // Create bill - if (! empty($conf->facture->enabled) && $object->statut > 0) + if (! empty($conf->facture->enabled) && ($object->statut == Expedition::STATUS_VALIDATED || $object->statut == Expedition::STATUS_CLOSED)) { if ($user->rights->facture->creer) { @@ -2489,18 +2489,18 @@ else if ($id || $ref) // This is just to generate a delivery receipt //var_dump($object->linkedObjectsIds['delivery']); - if ($conf->livraison_bon->enabled && ($object->statut == 1 || $object->statut == 2) && $user->rights->expedition->livraison->creer && count($object->linkedObjectsIds['delivery']) == 0) + if ($conf->livraison_bon->enabled && ($object->statut == Expedition::STATUS_VALIDATED || $object->statut == Expedition::STATUS_CLOSED) && $user->rights->expedition->livraison->creer && count($object->linkedObjectsIds['delivery']) == 0) { print ''.$langs->trans("CreateDeliveryOrder").''; } // Close - if (! empty($conf->facture->enabled) && $object->statut > 0) + if ($object->statut == Expedition::STATUS_VALIDATED) { if ($user->rights->expedition->creer && $object->statut > 0 && ! $object->billed) { $label="Close"; $paramaction='classifyclosed'; // = Transferred/Received // Label here should be "Close" or "ClassifyBilled" if we decided to make bill on shipments instead of orders - if (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) // TODO Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close. + if (! empty($conf->facture->enabled) && ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) // Quand l'option est on, il faut avoir le bouton en plus et non en remplacement du Close ? { $label="ClassifyBilled"; $paramaction='classifybilled'; diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 7a27fff3218..2112e457a39 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -68,6 +68,8 @@ ALTER TABLE llx_website_page ADD COLUMN fk_user_modif integer; -- For 7.0 +ALTER table llx_entrepot CHANGE COLUMN label ref varchar(255); + UPDATE llx_paiementfourn SET ref = rowid WHERE ref IS NULL; UPDATE llx_paiementfourn SET entity = 1 WHERE entity IS NULL; diff --git a/htdocs/install/mysql/tables/llx_entrepot.sql b/htdocs/install/mysql/tables/llx_entrepot.sql index d93eb6e1575..cfb17c55766 100644 --- a/htdocs/install/mysql/tables/llx_entrepot.sql +++ b/htdocs/install/mysql/tables/llx_entrepot.sql @@ -1,6 +1,6 @@ -- ============================================================================ -- Copyright (C) 2003-2006 Rodolphe Quiedeville --- Copyright (C) 2004 Laurent Destailleur +-- Copyright (C) 2004-2017 Laurent Destailleur -- Copyright (C) 2012 Juanjo Menent -- -- This program is free software; you can redistribute it and/or modify @@ -21,9 +21,9 @@ create table llx_entrepot ( rowid integer AUTO_INCREMENT PRIMARY KEY, + ref varchar(255) NOT NULL, datec datetime, tms timestamp, - label varchar(255) NOT NULL, entity integer DEFAULT 1 NOT NULL, -- multi company id description text, lieu varchar(64), -- resume lieu situation diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 8aa3899f82c..88cb0efed30 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -329,6 +329,16 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print '
'; + + /* Second column + print '
'; + print '
'; + print '
'; + print ''; + + print '
'; + print '
';*/ + print '
'; print '
'; @@ -359,7 +369,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } /* - if ($user->rights->sellyoursaas->create) + if ($user->rights->mymodule->create) { if ($object->status == 1) { @@ -396,13 +406,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; // ancre // Documents - /*$comref = dol_sanitizeFileName($object->ref); + /*$objref = dol_sanitizeFileName($object->ref); $relativepath = $comref . '/' . $comref . '.pdf'; - $filedir = $conf->mymodule->dir_output . '/' . $comref; + $filedir = $conf->mymodule->dir_output . '/' . $objref; $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; $genallowed = $user->rights->mymodule->read; // If you can read, you can build the PDF to read content $delallowed = $user->rights->mymodule->create; // If you can create/edit, you can remove a file on card - print $formfile->showdocuments('mymodule', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + print $formfile->showdocuments('mymodule', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); */ // Show links to link elements @@ -426,13 +436,18 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; } - // Presend form - $modelmail='myobject'; - $defaulttopic='Information'; - $diroutput = $conf->mymodule->dir_output; - $trackid = 'myobject'.$object->id; - - include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + //Select mail models is same action as presend + /* + if (GETPOST('modelselected')) $action = 'presend'; + + // Presend form + $modelmail='inventory'; + $defaulttopic='InformationMessage'; + $diroutput = $conf->product->dir_output.'/inventory'; + $trackid = 'stockinv'.$object->id; + + include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; + */ } diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 68e80454b22..6ae31645a50 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -87,7 +87,7 @@ class FormProduct $warehouseStatus[] = Entrepot::STATUS_OPEN_INTERNAL; } - $sql = "SELECT e.rowid, e.label, e.description, e.fk_parent"; + $sql = "SELECT e.rowid, e.ref as label, e.description, e.fk_parent"; if (!empty($fk_product)) { if (!empty($batch)) @@ -125,8 +125,8 @@ class FormProduct if(!empty($exclude)) $sql.= ' AND e.rowid NOT IN('.$this->db->escape(implode(',', $exclude)).')'; - if ($sumStock && empty($fk_product)) $sql.= " GROUP BY e.rowid, e.label, e.description, e.fk_parent"; - $sql.= " ORDER BY e.label"; + if ($sumStock && empty($fk_product)) $sql.= " GROUP BY e.rowid, e.ref, e.description, e.fk_parent"; + $sql.= " ORDER BY e.ref"; dol_syslog(get_class($this).'::loadWarehouses', LOG_DEBUG); $resql = $this->db->query($sql); @@ -382,14 +382,14 @@ class FormProduct { $productIdArray = array($fk_product); // only show lot stock for product } - else + else { foreach($this->cache_lot as $key => $value) { $productIdArray[] = $key; } } - + foreach($productIdArray as $productId) { foreach($this->cache_lot[$productId] as $id => $arraytypes) @@ -433,21 +433,21 @@ class FormProduct if (count($productIdArray) && count($this->cache_lot)) { // check cache already loaded for product id's - foreach ($productIdArray as $productId) + foreach ($productIdArray as $productId) { $cacheLoaded = ! empty($this->cache_lot[$productId]) ? true : false; } } - if ($cacheLoaded) + if ($cacheLoaded) { return count($this->cache_lot); } - else + else { // clear cache $this->cache_lot = array(); $productIdList = implode(',', $productIdArray); - $sql = "SELECT pb.batch, pb.rowid, ps.fk_entrepot, pb.qty, e.label, ps.fk_product"; + $sql = "SELECT pb.batch, pb.rowid, ps.fk_entrepot, pb.qty, e.ref as label, ps.fk_product"; $sql.= " FROM ".MAIN_DB_PREFIX."product_batch as pb"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps on ps.rowid = pb.fk_product_stock"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."entrepot as e on e.rowid = ps.fk_entrepot AND e.entity IN (".getEntity('stock').")"; @@ -455,8 +455,8 @@ class FormProduct { $sql.= " WHERE ps.fk_product IN (".$productIdList.")"; } - $sql.= " ORDER BY e.label, pb.batch"; - + $sql.= " ORDER BY e.ref, pb.batch"; + dol_syslog(get_class($this).'::loadLotStock', LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) @@ -473,7 +473,7 @@ class FormProduct $this->cache_lot[$obj->fk_product][$obj->rowid]['qty'] = $obj->qty; $i++; } - + return $num; } else diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 4b5a74ed3dd..97fa5140fba 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -30,6 +30,7 @@ $langs->loadLangs(array("inventory","other")); // Get parameters $id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); @@ -53,12 +54,10 @@ foreach($object->fields as $key => $val) if (empty($action) && empty($id) && empty($ref)) $action='view'; -// Protection if external user -if ($user->societe_id > 0) -{ - //accessforbidden(); -} -//$result = restrictedArea($user, 'inventory', $id); +// Security check - Protection if external user +//if ($user->societe_id > 0) access_forbidden(); +//if ($user->societe_id > 0) $socid = $user->societe_id; +//$result = restrictedArea($user, 'mymodule', $id); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); @@ -69,7 +68,7 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be inclu /* - * ACTIONS + * Actions */ $parameters=array(); @@ -86,13 +85,22 @@ if (empty($reshook)) // Actions cancel, add, update or delete include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; + + // Actions when printing a doc from card + include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; + + // Actions to send emails + /*$trigger_name='MYOBJECT_SENTBYMAIL'; + $autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO'; + $trackid='myobject'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';*/ } /* - * VIEW + * View */ $form=new Form($db); @@ -128,39 +136,10 @@ if ($action == 'create') dol_fiche_head(array(), ''); print ''."\n"; - foreach($object->fields as $key => $val) - { - if (in_array($key, array('rowid', 'entity', 'date_creation', 'date_validation', 'tms', 'fk_user_creat', 'fk_user_modif', 'fk_user_valid', 'import_key'))) continue; - print ''; - print ''; - print $langs->trans($val['label']); - print ''; - print ''; - print ''; - } - + + // Common attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; + // Other attributes include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; @@ -171,20 +150,19 @@ if ($action == 'create') print '
'; print ''; print '  '; - print ''; // Cancel for create doe not post form + print ''; // Cancel for create does not post form if we don't know the backtopage print '
'; print ''; } - - // Part to edit record if (($id || $ref) && $action == 'edit') { print load_fiche_titre($langs->trans("Inventory")); print ''; + print ''; print ''; print ''; print ''; @@ -192,37 +170,10 @@ if (($id || $ref) && $action == 'edit') dol_fiche_head(); print '
'; - $defaultcss='minwidth100'; - if ($val['type'] == 'text') - { - print ''; - } - elseif (is_array($val['arrayofkeyval'])) - { - print $form->selectarray($key, $val['arrayofkeyval'], GETPOST($key, 'int')); - } - else - { - $cssforinput = empty($val['css'])?$defaultcss:$val['css']; - print ''; - } - print '
'."\n"; - foreach($object->fields as $key => $val) - { - if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; - - print ''.$langs->trans($val['label']).''; - print ''; - print ''; - } - + + // Common attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; + // Other attributes include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; @@ -237,22 +188,19 @@ if (($id || $ref) && $action == 'edit') print ''; } - - - // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { $res = $object->fetch_optionals($object->id, $extralabels); $head = inventory_prepare_head($object); - dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), -1, 'order'); + dol_fiche_head($head, 'inventory', $langs->trans("Inventory"), -1, 'inventory'); $formconfirm = ''; // Confirmation to delete if ($action == 'delete') { - $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); + $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteInventory'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1); } // Confirmation of action xxxx @@ -280,13 +228,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print $formconfirm; - // Object card // ------------------------------------------------------------ $linkback = '' . $langs->trans("BackToList") . ''; - $morehtmlref='
'; /* // Ref bis @@ -339,24 +285,25 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print '
'; print '
'; - $defaultcss='minwidth100'; - if ($val['type'] == 'text') - { - print ''; - } - elseif (is_array($val['arrayofkeyval'])) - { - print $form->selectarray($key, $val['arrayofkeyval'], GETPOST($key, 'int')!=''?GETPOST($key, 'int'):$object->$key); - } - else - { - $cssforinput = empty($val['css'])?$defaultcss:$val['css']; - print ''; - } - print '
'."\n"; - // print ''; - // LIST_OF_TD_LABEL_FIELDS_VIEW - + // Common attributes + include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; + // Other attributes include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print '
'.$langs->trans("Label").''.$object->label.'
'; print ''; + + /* Second column print '
'; print '
'; print '
'; print ''; - - print '
'; - print '
'; + print '
';*/ + print ''; print ''; @@ -375,16 +322,24 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if (empty($reshook)) { // Send - print ''."\n"; + print '' . $langs->trans('SendMail') . ''."\n"; if ($user->rights->inventory->write) { - print ''."\n"; + print ''.$langs->trans("Modify").''."\n"; } - + else + { + print ''.$langs->trans('Modify').''."\n"; + } + if ($user->rights->inventory->delete) { - print ''."\n"; + print ''.$langs->trans('Delete').''."\n"; + } + else + { + print ''.$langs->trans('Delete').''."\n"; } } print ''."\n"; @@ -400,27 +355,34 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { print '
'; print ''; // ancre + // Documents - $comref = dol_sanitizeFileName($object->ref); - $relativepath = $comref . '/' . $comref . '.pdf'; - $filedir = $conf->product->dir_output . '/inventory/' . $comref; - $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; - $genallowed = $user->rights->inventory->read; - $delallowed = $user->rights->inventory->create; - print $formfile->showdocuments('inventory', $comref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); - + /*$objref = dol_sanitizeFileName($object->ref); + $relativepath = $comref . '/' . $comref . '.pdf'; + $filedir = $conf->mymodule->dir_output . '/' . $objref; + $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id; + $genallowed = $user->rights->mymodule->read; // If you can read, you can build the PDF to read content + $delallowed = $user->rights->mymodule->create; // If you can create/edit, you can remove a file on card + print $formfile->showdocuments('mymodule', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); + */ // Show links to link elements - $linktoelem = $form->showLinkToObjectBlock($object, null, array('order')); + $linktoelem = $form->showLinkToObjectBlock($object, null, array('inventory')); $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem); print '
'; + $MAXEVENT = 10; + + $morehtmlright = ''; + $morehtmlright.= $langs->trans("SeeAll"); + $morehtmlright.= ''; + // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); - $somethingshown = $formactions->showactions($object, 'order', $socid, 1); + $somethingshown = $formactions->showactions($object, 'inventory', $socid, 1, '', $MAXEVENT, '', $morehtmlright); print '
'; } diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 9b48c5164d4..a83602132e3 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -74,7 +74,7 @@ class Inventory extends CommonObject 'ref' => array('type'=>'varchar(64)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>'Reference of object',), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>0, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), 'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300'), - 'fk_warehouse' => array('type'=>'integer', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'index'=>1,), + 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'index'=>1, 'help'=>'LinkToThirparty'), 'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>1,), 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'index'=>1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-1, 'enabled'=>1, 'position'=>500,), diff --git a/htdocs/product/reassortlot.php b/htdocs/product/reassortlot.php index cf4e889e89e..be4ff835c01 100644 --- a/htdocs/product/reassortlot.php +++ b/htdocs/product/reassortlot.php @@ -114,7 +114,7 @@ $sql = 'SELECT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price $sql.= ' p.fk_product_type, p.tms as datem,'; $sql.= ' p.duration, p.tosell as statut, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tobatch,'; $sql.= ' ps.fk_entrepot,'; -$sql.= ' e.label as warehouse_ref, e.lieu as warehouse_lieu, e.fk_parent as warehouse_parent,'; +$sql.= ' e.ref as warehouse_ref, e.lieu as warehouse_lieu, e.fk_parent as warehouse_parent,'; $sql.= ' pb.batch, pb.eatby as oldeatby, pb.sellby as oldsellby,'; $sql.= ' pl.rowid as lotid, pl.eatby, pl.sellby,'; $sql.= ' SUM(pb.qty) as stock_physique, COUNT(pb.rowid) as nbinbatchtable'; @@ -150,13 +150,13 @@ if($catid) $sql.= " AND cp.fk_categorie = ".$catid; if ($fourn_id > 0) $sql.= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id; // Insert categ filter if ($search_categ) $sql .= " AND cp.fk_categorie = ".$db->escape($search_categ); -if ($search_warehouse) $sql .= natural_search("e.label", $search_warehouse); +if ($search_warehouse) $sql .= natural_search("e.ref", $search_warehouse); if ($search_batch) $sql .= natural_search("pb.batch", $search_batch); $sql.= " GROUP BY p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type, p.entity,"; $sql.= " p.fk_product_type, p.tms,"; $sql.= " p.duration, p.tosell, p.tobuy, p.seuil_stock_alerte, p.desiredstock, p.stock, p.tobatch,"; $sql.= " ps.fk_entrepot,"; -$sql.= " e.label, e.lieu, e.fk_parent,"; +$sql.= " e.ref, e.lieu, e.fk_parent,"; $sql.= " pb.batch, pb.eatby, pb.sellby,"; $sql.= " pl.rowid, pl.eatby, pl.sellby"; if ($toolowstock) $sql.= " HAVING SUM(".$db->ifsql('ps.reel IS NULL', '0', 'ps.reel').") < p.seuil_stock_alerte"; // Not used yet @@ -292,7 +292,7 @@ if ($resql) print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "p.ref",$param,"","",$sortfield,$sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "p.label",$param,"","",$sortfield,$sortorder); if (! empty($conf->service->enabled) && $type == 1) print_liste_field_titre("Duration", $_SERVER["PHP_SELF"], "p.duration",$param,"",'align="center"',$sortfield,$sortorder); - print_liste_field_titre("Warehouse", $_SERVER["PHP_SELF"], "e.label",$param,"",'',$sortfield,$sortorder); + print_liste_field_titre("Warehouse", $_SERVER["PHP_SELF"], "e.ref",$param,"",'',$sortfield,$sortorder); //print_liste_field_titre("DesiredStock", $_SERVER["PHP_SELF"], "p.desiredstock",$param,"",'align="right"',$sortfield,$sortorder); print_liste_field_titre("Batch", $_SERVER["PHP_SELF"], "pb.batch",$param,"",'align="center"',$sortfield,$sortorder); print_liste_field_titre("EatByDate", $_SERVER["PHP_SELF"], "pb.eatby",$param,"",'align="center"',$sortfield,$sortorder); diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index c95e805c3f5..97924d330ae 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -275,7 +275,7 @@ else { $head = stock_prepare_head($object); - dol_fiche_head($head, 'card', $langs->trans("Warehouse"), 0, 'stock'); + dol_fiche_head($head, 'card', $langs->trans("Warehouse"), -1, 'stock'); $formconfirm = ''; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 9263fe4ba10..6ff271e062f 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -98,6 +98,8 @@ class Entrepot extends CommonObject { global $conf; + $error = 0; + $this->libelle = trim($this->libelle); // Si libelle non defini, erreur @@ -111,8 +113,8 @@ class Entrepot extends CommonObject $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (entity, datec, fk_user_author, label, fk_parent)"; - $sql .= " VALUES (".$conf->entity.",'".$this->db->idate($now)."',".$user->id.",'".$this->db->escape($this->libelle)."', ".($this->fk_parent > 0 ? $this->fk_parent : "NULL").")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (ref, entity, datec, fk_user_author, fk_parent)"; + $sql .= " VALUES ('".$this->db->escape($this->libelle)."', ".$conf->entity.", '".$this->db->idate($now)."', ".$user->id.", ".($this->fk_parent > 0 ? $this->fk_parent : "NULL").")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); $result=$this->db->query($sql); @@ -123,7 +125,16 @@ class Entrepot extends CommonObject { $this->id = $id; - if ($this->update($id, $user) > 0) + if (! $error) + { + $result = $this->update($id, $user); + if ($result <= 0) + { + $error++; + } + } + + if (! $error) { $this->db->commit(); return $id; @@ -185,7 +196,7 @@ class Entrepot extends CommonObject $this->country_id=($this->country_id > 0 ? $this->country_id : 0); $sql = "UPDATE ".MAIN_DB_PREFIX."entrepot "; - $sql .= " SET label = '" . $this->db->escape($this->libelle) ."'"; + $sql .= " SET ref = '" . $this->db->escape($this->libelle) ."'"; $sql .= ", fk_parent = " . (($this->fk_parent > 0) ? $this->fk_parent : "NULL"); $sql .= ", description = '" . $this->db->escape($this->description) ."'"; $sql .= ", statut = " . $this->statut; @@ -297,7 +308,7 @@ class Entrepot extends CommonObject { global $conf; - $sql = "SELECT rowid, fk_parent, label, description, statut, lieu, address, zip, town, fk_pays as country_id"; + $sql = "SELECT rowid, fk_parent, ref as label, description, statut, lieu, address, zip, town, fk_pays as country_id"; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot"; if ($id) { @@ -306,7 +317,7 @@ class Entrepot extends CommonObject else { $sql.= " WHERE entity = " .$conf->entity; - if ($ref) $sql.= " AND label = '".$this->db->escape($ref)."'"; + if ($ref) $sql.= " AND ref = '".$this->db->escape($ref)."'"; } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -319,8 +330,8 @@ class Entrepot extends CommonObject $this->id = $obj->rowid; $this->fk_parent = $obj->fk_parent; - $this->ref = $obj->rowid; - $this->label = $obj->label; + $this->ref = $obj->label; + $this->label = $obj->label; // deprecated $this->libelle = $obj->label; // deprecated $this->description = $obj->description; $this->statut = $obj->statut; @@ -409,7 +420,7 @@ class Entrepot extends CommonObject { $liste = array(); - $sql = "SELECT rowid, label"; + $sql = "SELECT rowid, ref as label"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot"; $sql.= " WHERE entity IN (".getEntity('stock').")"; $sql.= " AND statut = ".$status; @@ -574,7 +585,7 @@ class Entrepot extends CommonObject $label = ''; $label = '' . $langs->trans("ShowWarehouse").''; - $label.= '
' . $langs->trans('Ref') . ': ' . (empty($this->label)?$this->libelle:$this->label); + $label.= '
' . $langs->trans('Ref') . ': ' . (empty($this->ref)?(empty($this->label)?$this->libelle:$this->label):$this->ref); if (! empty($this->lieu)) $label.= '
' . $langs->trans('LocationSummary').': '.$this->lieu; diff --git a/htdocs/product/stock/index.php b/htdocs/product/stock/index.php index 22a9e95410c..f2494592815 100644 --- a/htdocs/product/stock/index.php +++ b/htdocs/product/stock/index.php @@ -25,6 +25,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $langs->load("stocks"); $langs->load("productbatch"); @@ -37,6 +38,8 @@ $result=restrictedArea($user,'stock'); * View */ +$producttmp=new Product($db); + $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; llxHeader("",$langs->trans("Stocks"),$help_url); @@ -61,7 +64,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is usele } -$sql = "SELECT e.label, e.rowid, e.statut"; +$sql = "SELECT e.ref as label, e.rowid, e.statut"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql.= " WHERE e.statut in (0,1)"; $sql.= " AND e.entity IN (".getEntity('stock').")"; @@ -87,7 +90,7 @@ if ($result) while ($i < $num) { $objp = $db->fetch_object($result); - + print ''; print "rowid\">".img_object($langs->trans("ShowStock"),"stock")." ".$objp->label."\n"; print ''.$entrepot->LibStatut($objp->statut,5).''; @@ -111,8 +114,8 @@ print '
'; // Last movements $max=10; -$sql = "SELECT p.rowid, p.label as produit,"; -$sql.= " e.label as stock, e.rowid as entrepot_id,"; +$sql = "SELECT p.rowid, p.label as produit, p.tobatch, p.tosell, p.tobuy,"; +$sql.= " e.ref as stock, e.rowid as entrepot_id,"; $sql.= " m.value as qty, m.datem, m.batch, m.eatby, m.sellby"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql.= ", ".MAIN_DB_PREFIX."stock_mouvement as m"; @@ -144,17 +147,21 @@ if ($resql) print ''.$langs->trans("FullList").''; print "\n"; - $var=True; $i=0; while ($i < min($num,$max)) { $objp = $db->fetch_object($resql); - + print ''; print ''.dol_print_date($db->jdate($objp->datem),'dayhour').''; - print "rowid\">"; - print img_object($langs->trans("ShowProduct"),"product").' '.$objp->produit; - print "\n"; + print ""; + $producttmp->id = $objp->rowid; + $producttmp->ref = $objp->produit; + $producttmp->status_batch = $objp->tobatch; + $producttmp->status_sell = $objp->tosell; + $producttmp->status_buy = $objp->tobuy; + print $producttmp->getNomUrl(1); + print "\n"; if (! empty($conf->productbatch->enabled)) { print ''.$objp->batch.''; diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index d740a2a9d73..77991ab2909 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -40,7 +40,7 @@ $search_status=GETPOST("search_status","int"); $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield"); $sortorder = GETPOST("sortorder"); -if (! $sortfield) $sortfield="e.label"; +if (! $sortfield) $sortfield="e.ref"; if (! $sortorder) $sortorder="ASC"; $page = GETPOST("page"); if ($page < 0) $page = 0; @@ -50,7 +50,7 @@ $year = strftime("%Y",time()); // List of fields to search into when doing a "search in all" $fieldstosearchall = array( - 'e.label'=>"Ref", + 'e.ref'=>"Ref", 'e.lieu'=>"LocationSummary", 'e.description'=>"Description", 'e.address'=>"Address", @@ -82,17 +82,17 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x', $form=new Form($db); $warehouse=new Entrepot($db); -$sql = "SELECT e.rowid, e.label as ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent,"; +$sql = "SELECT e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent,"; $sql.= " SUM(p.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue, SUM(ps.reel) as stockqty"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; $sql.= " WHERE e.entity IN (".getEntity('stock').")"; -if ($search_ref) $sql.= natural_search("e.label", $search_ref); // ref +if ($search_ref) $sql.= natural_search("e.ref", $search_ref); // ref if ($search_label) $sql.= natural_search("e.lieu", $search_label); // label if ($search_status != '' && $search_status >= 0) $sql.= " AND e.statut = ".$search_status; if ($sall) $sql .= natural_search(array_keys($fieldstosearchall), $sall); -$sql.= " GROUP BY e.rowid, e.label, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent"; +$sql.= " GROUP BY e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays, e.fk_parent"; $totalnboflines=0; $result=$db->query($sql); if ($result) @@ -125,10 +125,10 @@ if ($result) $param=''; if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($search_ref) $param.="&search_ref=".$search_ref; - if ($search_label) $param.="&search_label=".$search_label; - if ($search_status) $param.="&search_status=".$search_status; - if ($sall) $param.="&sall=".$sall; + if ($search_ref) $param.="&search_ref=".urlencode($search_ref); + if ($search_label) $param.="&search_label=".urlencode($search_label); + if ($search_status) $param.="&search_status=".urlencode($search_status); + if ($sall) $param.="&sall=".urlencode($sall); print '
'; print ''; @@ -176,7 +176,7 @@ if ($result) print ''; print ''; - print_liste_field_titre("Ref",$_SERVER["PHP_SELF"], "e.label","",$param,"",$sortfield,$sortorder); + print_liste_field_titre("Ref",$_SERVER["PHP_SELF"], "e.ref","",$param,"",$sortfield,$sortorder); print_liste_field_titre("LocationSummary",$_SERVER["PHP_SELF"], "e.lieu","",$param,"",$sortfield,$sortorder); print_liste_field_titre("PhysicalStock", $_SERVER["PHP_SELF"], "stockqty",'',$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre("EstimatedStockValue", $_SERVER["PHP_SELF"], "estimatedvalue",'',$param,'align="right"',$sortfield,$sortorder); @@ -194,7 +194,8 @@ if ($result) $objp = $db->fetch_object($result); $warehouse->id = $objp->rowid; - $warehouse->label = $objp->ref; + $warehouse->ref = $objp->ref; + $warehouse->label = $objp->ref; $warehouse->lieu = $objp->lieu; $warehouse->fk_parent = $objp->fk_parent; diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index a00a18222e6..f7e0cbd1bc8 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -95,7 +95,7 @@ $arrayfields=array( 'm.batch'=>array('label'=>$langs->trans("BatchNumberShort"), 'checked'=>1, 'enabled'=>(! empty($conf->productbatch->enabled))), 'pl.eatby'=>array('label'=>$langs->trans("EatByDate"), 'checked'=>0, 'enabled'=>(! empty($conf->productbatch->enabled))), 'pl.sellby'=>array('label'=>$langs->trans("SellByDate"), 'checked'=>0, 'position'=>10, 'enabled'=>(! empty($conf->productbatch->enabled))), - 'e.label'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1, 'enabled'=>(! $id > 0)), // If we are on specific warehouse, we hide it + 'e.ref'=>array('label'=>$langs->trans("Warehouse"), 'checked'=>1, 'enabled'=>(! $id > 0)), // If we are on specific warehouse, we hide it 'm.fk_user_author'=>array('label'=>$langs->trans("Author"), 'checked'=>0), 'm.inventorycode'=>array('label'=>$langs->trans("InventoryCodeShort"), 'checked'=>1), 'm.label'=>array('label'=>$langs->trans("LabelMovement"), 'checked'=>1), @@ -414,7 +414,7 @@ $formproduct=new FormProduct($db); if (!empty($conf->projet->enabled)) $formproject=new FormProjets($db); $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.fk_product_type as type, p.entity,"; -$sql.= " e.label as stock, e.rowid as entrepot_id, e.lieu,"; +$sql.= " e.ref as stock, e.rowid as entrepot_id, e.lieu,"; $sql.= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,"; $sql.= " m.batch,"; $sql.= " pl.rowid as lotid, pl.eatby, pl.sellby,"; @@ -529,7 +529,7 @@ if ($resql) { $head = stock_prepare_head($object); - dol_fiche_head($head, 'movements', $langs->trans("Warehouse"), 0, 'stock'); + dol_fiche_head($head, 'movements', $langs->trans("Warehouse"), -1, 'stock'); $linkback = ''.$langs->trans("BackToList").''; @@ -783,7 +783,7 @@ if ($resql) print ''; } // Warehouse - if (! empty($arrayfields['e.label']['checked'])) + if (! empty($arrayfields['e.ref']['checked'])) { print ''; //print ''; @@ -879,7 +879,7 @@ if ($resql) if (! empty($arrayfields['m.batch']['checked'])) print_liste_field_titre($arrayfields['m.batch']['label'],$_SERVER["PHP_SELF"],'m.batch','',$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['pl.eatby']['checked'])) print_liste_field_titre($arrayfields['pl.eatby']['label'],$_SERVER["PHP_SELF"],'pl.eatby','',$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['pl.sellby']['checked'])) print_liste_field_titre($arrayfields['pl.sellby']['label'],$_SERVER["PHP_SELF"],'pl.sellby','',$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['e.label']['checked'])) print_liste_field_titre($arrayfields['e.label']['label'],$_SERVER["PHP_SELF"], "e.label","",$param,"",$sortfield,$sortorder); // We are on a specific warehouse card, no filter on other should be possible + if (! empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'],$_SERVER["PHP_SELF"], "e.ref","",$param,"",$sortfield,$sortorder); // We are on a specific warehouse card, no filter on other should be possible if (! empty($arrayfields['m.fk_user_author']['checked'])) print_liste_field_titre($arrayfields['m.fk_user_author']['label'],$_SERVER["PHP_SELF"], "m.fk_user_author","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['m.inventorycode']['checked'])) print_liste_field_titre($arrayfields['m.inventorycode']['label'],$_SERVER["PHP_SELF"], "m.inventorycode","",$param,"",$sortfield,$sortorder); if (! empty($arrayfields['m.label']['checked'])) print_liste_field_titre($arrayfields['m.label']['label'],$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder); @@ -982,7 +982,7 @@ if ($resql) print ''. dol_print_date($objp->sellby,'day') .''; } // Warehouse - if (! empty($arrayfields['e.label']['checked'])) + if (! empty($arrayfields['e.ref']['checked'])) { print ''; print $warehousestatic->getNomUrl(1); diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index faee4d05a6a..665940b8083 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -813,7 +813,7 @@ if ((! empty($conf->productbatch->enabled)) && $object->hasbatch()) print ''; } -$sql = "SELECT e.rowid, e.label, e.lieu, ps.reel, ps.rowid as product_stock_id, p.pmp"; +$sql = "SELECT e.rowid, e.ref as label, e.lieu, ps.reel, ps.rowid as product_stock_id, p.pmp"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql.= " ".MAIN_DB_PREFIX."product_stock as ps"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = ps.fk_product"; @@ -821,7 +821,7 @@ $sql.= " WHERE ps.reel != 0"; $sql.= " AND ps.fk_entrepot = e.rowid"; $sql.= " AND e.entity IN (".getEntity('stock').")"; $sql.= " AND ps.fk_product = ".$object->id; -$sql.= " ORDER BY e.label"; +$sql.= " ORDER BY e.ref"; $entrepotstatic=new Entrepot($db); $product_lot_static=new Productlot($db); diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index b959eebeb2d..c41577193ca 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -263,7 +263,7 @@ $formproduct = new FormProduct($db); $title = $langs->trans('Status'); -if(!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { +if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE) && $fk_entrepot > 0) { $sqldesiredtock=$db->ifsql("pse.desiredstock IS NULL", "p.desiredstock", "pse.desiredstock"); $sqlalertstock=$db->ifsql("pse.seuil_stock_alerte IS NULL", "p.seuil_stock_alerte", "pse.seuil_stock_alerte"); } else { @@ -427,9 +427,12 @@ print ''; print ''; print ''; print ''; -print '
'; -print $langs->trans('Warehouse').' '.$formproduct->selectWarehouses($fk_entrepot, 'fk_entrepot', '', 1); -print '
'; +if (!empty($conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE)) +{ + print '
'; + print $langs->trans('Warehouse').' '.$formproduct->selectWarehouses($fk_entrepot, 'fk_entrepot', '', 1); + print '
'; +} print '
'; print $langs->trans('Supplier').' '.$form->select_company($fk_supplier, 'fk_supplier', 'fournisseur=1', 1); print '
'; diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php index a1d68394bb0..7e6aca17f67 100644 --- a/htdocs/product/stock/valo.php +++ b/htdocs/product/stock/valo.php @@ -37,7 +37,7 @@ $sall=GETPOST('sall', 'alphanohtml'); $sortfield = GETPOST("sortfield"); $sortorder = GETPOST("sortorder"); -if (! $sortfield) $sortfield="e.label"; +if (! $sortfield) $sortfield="e.ref"; if (! $sortorder) $sortorder="ASC"; $page = $_GET["page"]; if ($page < 0) $page = 0; @@ -51,25 +51,22 @@ $year = strftime("%Y",time()); * View */ -$sql = "SELECT e.rowid, e.label as ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays,"; +$sql = "SELECT e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays,"; $sql.= " SUM(ps.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue"; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; $sql.= " WHERE e.entity IN (".getEntity('stock').")"; -if ($sref) -{ - $sql.= " AND e.label LIKE '%".$db->escape($sref)."%'"; -} +if ($sref) $sql.= natural_search("e.ref", $sref); if ($sall) { - $sql.= " AND (e.label LIKE '%".$db->escape($sall)."%'"; + $sql.= " AND (e.ref LIKE '%".$db->escape($sall)."%'"; $sql.= " OR e.description LIKE '%".$db->escape($sall)."%'"; $sql.= " OR e.lieu LIKE '%".$db->escape($sall)."%'"; $sql.= " OR e.address LIKE '%".$db->escape($sall)."%'"; $sql.= " OR e.town LIKE '%".$db->escape($sall)."%')"; } -$sql.= " GROUP BY e.rowid, e.label, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays"; +$sql.= " GROUP BY e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays"; $sql.= $db->order($sortfield,$sortorder); $sql.= $db->plimit($limit + 1, $offset); @@ -87,7 +84,7 @@ if ($result) print ''; print ""; - print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "e.label","","","",$sortfield,$sortorder); + print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "e.ref","","","",$sortfield,$sortorder); print_liste_field_titre("LocationSummary", $_SERVER["PHP_SELF"], "e.lieu","","","",$sortfield,$sortorder); print_liste_field_titre("EstimatedStockValue", $_SERVER["PHP_SELF"], "e.valo_pmp",'','','align="right"',$sortfield,$sortorder); print_liste_field_titre("EstimatedStockValueSell", $_SERVER["PHP_SELF"], "",'','','align="right"',$sortfield,$sortorder); From 5ee85821fca9ea503c79fdd79a00402711239696 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Nov 2017 15:47:38 +0100 Subject: [PATCH 16/19] Debug modulebuilder --- .../modulebuilder/template/myobject_list.php | 68 ++-- .../inventory/class/inventory.class.php | 21 +- htdocs/product/inventory/list.php | 378 +++++++++--------- 3 files changed, 238 insertions(+), 229 deletions(-) diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index cd99c94f969..a70308eaf42 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -388,8 +388,8 @@ print ''; foreach($object->fields as $key => $val) { $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; - if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align=($align?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; if ($key == 'status') $align.=($align?' ':'').'center'; if (! empty($arrayfields['t.'.$key]['checked'])) print ''; } @@ -434,24 +434,24 @@ print ''; foreach($object->fields as $key => $val) { $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; - if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align=($align?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; if ($key == 'status') $align.=($align?' ':'').'center'; if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { $align=$extrafields->getAlignFlag($key); $sortonfield = "ef.".$key; if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder)."\n"; - } - } + } + } } // Hook fields $parameters=array('arrayfields'=>$arrayfields); @@ -479,40 +479,40 @@ while ($i < min($num, $limit)) if (empty($obj)) break; // Should not happen // Store properties in $object - $object->id = $obj->rowid; - foreach($object->fields as $key => $val) - { - if (isset($obj->$key)) $object->$key = $obj->$key; - } + $object->id = $obj->rowid; + foreach($object->fields as $key => $val) + { + if (isset($obj->$key)) $object->$key = $obj->$key; + } // Show here line of result print ''; foreach($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; - if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) + { + print ''; + print $object->showOutputField($val, $key, $obj->$key, ''); + print ''; + if (! $i) $totalarray['nbfield']++; + if (! empty($val['isameasure'])) { - print ''; - print $object->showOutputField($val, $key, $obj->$key, ''); - print ''; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) - { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; - $totalarray['val']['t.'.$key] += $obj->$key; - } + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + $totalarray['val']['t.'.$key] += $obj->$key; } + } } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) - { + foreach($extrafields->attribute_label as $key => $val) + { if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); @@ -529,7 +529,7 @@ while ($i < min($num, $limit)) $totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey; } } - } + } } // Fields from hook $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index a83602132e3..cea53f610c0 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -76,14 +76,19 @@ class Inventory extends CommonObject 'title' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>25, 'css'=>'minwidth300'), 'fk_warehouse' => array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Warehouse', 'visible'=>1, 'enabled'=>1, 'index'=>1, 'help'=>'LinkToThirparty'), 'date_inventory' => array('type'=>'date', 'label'=>'DateValue', 'visible'=>1, 'enabled'=>1,), - 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'index'=>1,), - 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-1, 'enabled'=>1, 'position'=>500,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>501, 'notnull'=>1,), - 'date_validation' => array('type'=>'datetime', 'label'=>'DateValidation', 'visible'=>-1, 'enabled'=>1, 'position'=>502,), - 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-1, 'enabled'=>1, 'position'=>510,), - 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'visible'=>-1, 'enabled'=>1, 'position'=>511,), - 'fk_user_valid' => array('type'=>'integer', 'label'=>'UserValidation', 'visible'=>-1, 'enabled'=>1, 'position'=>512,), - 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-1, 'enabled'=>1, 'position'=>1000, 'index'=>1,), + + 'date_validation' => array('type'=>'datetime', 'label'=>'DateValidation', 'visible'=>-2, 'enabled'=>1, 'position'=>502,), + 'fk_user_valid' => array('type'=>'integer', 'label'=>'UserValidation', 'visible'=>-2, 'enabled'=>1, 'position'=>512,), + + 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>500), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), + //'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), + 'fk_user_creat' =>array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>510), + 'fk_user_modif' =>array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>511), + //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'index'=>0, 'position'=>1000), + + 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'arrayofkeyval'=>array(0=>'Todo', 1=>'Done', -1=>'Cancel')), ); public $rowid; diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index 4a7f0038662..17f60f22944 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -69,7 +69,7 @@ if (! $sortorder) $sortorder="ASC"; $socid=0; if ($user->societe_id > 0) { - //$socid = $user->societe_id; + //$socid = $user->societe_id; accessforbidden(); } @@ -78,14 +78,14 @@ $search_all=trim(GETPOST("search_all",'alpha')); $search=array(); foreach($object->fields as $key => $val) { - if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); + if (GETPOST('search_'.$key,'alpha')) $search[$key]=GETPOST('search_'.$key,'alpha'); } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); foreach($object->fields as $key => $val) { - if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; + if ($val['searchall']) $fieldstosearchall['t.'.$key]=$val['label']; } // Definition of fields for list @@ -93,15 +93,15 @@ $arrayfields=array(); foreach($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field - if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']); + if (! empty($val['visible'])) $arrayfields['t.'.$key]=array('label'=>$val['label'], 'checked'=>(($val['visible']<0)?0:1), 'enabled'=>$val['enabled']); } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) - { + foreach($extrafields->attribute_label as $key => $val) + { if (! empty($extrafields->attribute_list[$key])) $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>(($extrafields->attribute_list[$key]<0)?0:1), 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>(abs($extrafields->attribute_list[$key])!=3 && $extrafields->attribute_perms[$key])); - } + } } @@ -172,29 +172,31 @@ $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Inventorys")); $sql = 'SELECT '; foreach($object->fields as $key => $val) { - $sql.='t.'.$key.', '; + $sql.='t.'.$key.', '; } // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); // Add fields from hooks $parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook +$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters, $object); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql=preg_replace('/, $/','', $sql); -$sql.= " FROM ".MAIN_DB_PREFIX."inventory as t"; -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."inventory_extrafields as ef on (t.rowid = ef.fk_object)"; -$sql.= " WHERE t.entity IN (".getEntity('inventory').")"; +$sql.= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."myobject_extrafields as ef on (t.rowid = ef.fk_object)"; +if ($object->ismultientitymanaged == 1) $sql.= " WHERE t.entity IN (".getEntity('inventory').")"; +else $sql.=" WHERE 1 = 1"; foreach($search as $key => $val) { - if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:($object->fields[$key]['type'] == 'integer'?1:0))); + $mode_search=(($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key]))?1:0); + if ($search[$key] != '') $sql.=natural_search($key, $search[$key], (($key == 'status')?2:$mode_search)); } if ($search_all) $sql.= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $typ=$extrafields->attribute_type[$tmpkey]; + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $typ=$extrafields->attribute_type[$tmpkey]; $mode_search=0; if (in_array($typ, array('int','double','real'))) $mode_search=1; // Search on a numeric if (in_array($typ, array('sellist','link')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int @@ -205,7 +207,7 @@ foreach ($search_array_options as $key => $val) } // Add where from hooks $parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook +$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.=$db->order($sortfield,$sortorder); @@ -223,8 +225,8 @@ dol_syslog($script_file, LOG_DEBUG); $resql=$db->query($sql); if (! $resql) { - dol_print_error($db); - exit; + dol_print_error($db); + exit; } $num = $db->num_rows($resql); @@ -232,10 +234,10 @@ $num = $db->num_rows($resql); // Direct jump if only one record found if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all) { - $obj = $db->fetch_object($resql); - $id = $obj->rowid; - header("Location: ".DOL_URL_ROOT.'/inventory/card.php?id='.$id); - exit; + $obj = $db->fetch_object($resql); + $id = $obj->rowid; + header("Location: ".DOL_URL_ROOT.'/inventory/card.php?id='.$id); + exit; } @@ -262,24 +264,24 @@ jQuery(document).ready(function() { $arrayofselected=is_array($toselect)?$toselect:array(); $param=''; -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; -if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; +if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); +if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); foreach($search as $key => $val) { - $param.= '&search_'.$key.'='.urlencode($search[$key]); + $param.= '&search_'.$key.'='.urlencode($search[$key]); } -if ($optioncss != '') $param.='&optioncss='.$optioncss; +if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); // Add $param from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } $arrayofmassactions = array( - 'presend'=>$langs->trans("SendByMail"), - 'builddoc'=>$langs->trans("PDFMerge"), + 'presend'=>$langs->trans("SendByMail"), + 'builddoc'=>$langs->trans("PDFMerge"), ); if ($user->rights->inventory->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); @@ -295,8 +297,9 @@ print ''; print ''; print ''; -print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); +print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, '', '', $limit); +// Add code for pre mass action (confirmation or email presend form) $topicmail="Information"; $modelmail="inventory"; $objecttmp=new Inventory($db); @@ -305,17 +308,17 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($sall) { - foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); + foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); + print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall); } $moreforfilter = ''; -$moreforfilter.='
'; +/*$moreforfilter.='
'; $moreforfilter.= $langs->trans('MyFilter') . ': '; -$moreforfilter.= '
'; +$moreforfilter.= '
';*/ $parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook +$reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; @@ -323,14 +326,14 @@ if (! empty($moreforfilter)) { print '
'; print $moreforfilter; - print '
'; + print ''; } $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields -$selectedfields.=$form->showCheckAddButtons('checkforselect', 1); +$selectedfields.=(count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : ''); -print '
'; +print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table print '
'."\n"; @@ -339,37 +342,38 @@ print '
'; foreach($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; - if (in_array($val['type'], array('timestamp'))) $align.=' nowrap'; - if (! empty($arrayfields['t.'.$key]['checked'])) print ''; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align=($align?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) print ''; } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - $align=$extrafields->getAlignFlag($key); - $typeofextrafield=$extrafields->attribute_type[$key]; - print ''; - } - } + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + $typeofextrafield=$extrafields->attribute_type[$key]; + print ''; + } + } } // Fields from hook $parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook +$reshook=$hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Action column print ''."\n"; print ''; foreach($object->fields as $key => $val) { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; - if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; - if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align=($align?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; } // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { $align=$extrafields->getAlignFlag($key); $sortonfield = "ef.".$key; if (! empty($extrafields->attribute_computed[$key])) $sortonfield=''; print getTitleFieldOfList($langs->trans($extralabels[$key]), 0, $_SERVER["PHP_SELF"], $sortonfield, "", $param, ($align?'align="'.$align.'"':''), $sortfield, $sortorder)."\n"; - } - } + } + } } // Hook fields $parameters=array('arrayfields'=>$arrayfields); -$reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook +$reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ')."\n"; print ''."\n"; @@ -415,7 +420,7 @@ print ''."\n"; $needToFetchEachLine=0; foreach ($extrafields->attribute_computed as $key => $val) { - if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object + if (preg_match('/\$object/',$val)) $needToFetchEachLine++; // There is at least one compute field that use $object } @@ -425,118 +430,117 @@ $i=0; $totalarray=array(); while ($i < min($num, $limit)) { - $obj = $db->fetch_object($resql); - if ($obj) - { - // Store properties in $object - $object->id = $obj->rowid; - foreach($object->fields as $key => $val) - { - if (isset($obj->$key)) $object->$key = $obj->$key; - } + $obj = $db->fetch_object($resql); + if (empty($obj)) break; // Should not happen - // Show here line of result - print ''; - foreach($object->fields as $key => $val) - { - $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; - if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; - if ($key == 'status') $align.=($align?' ':'').'center'; - if (! empty($arrayfields['t.'.$key]['checked'])) - { - print ''; - if (in_array($val['type'], array('date','datetime','timestamp'))) print dol_print_date($db->jdate($obj->$key), 'dayhour'); - elseif ($key == 'ref') print $object->getNomUrl(1); - elseif ($key == 'status') print $object->getLibStatut(3); - else print $obj->$key; - print ''; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) - { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; - $totalarray['val']['t.'.$key] += $obj->$key; - } - } - } - // Extra fields - if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + // Store properties in $object + $object->id = $obj->rowid; + foreach($object->fields as $key => $val) + { + if (isset($obj->$key)) $object->$key = $obj->$key; + } + + // Show here line of result + print ''; + foreach($object->fields as $key => $val) + { + $align=''; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; + if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; + if ($key == 'status') $align.=($align?' ':'').'center'; + if (! empty($arrayfields['t.'.$key]['checked'])) { - foreach($extrafields->attribute_label as $key => $val) - { - if (! empty($arrayfields["ef.".$key]['checked'])) - { - print 'getAlignFlag($key); - if ($align) print ' align="'.$align.'"'; - print '>'; - $tmpkey='options_'.$key; - print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1); - print ''; - if (! $i) $totalarray['nbfield']++; - if (! empty($val['isameasure'])) - { - if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey; - $totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey; - } - } - } + print ''; + print $object->showOutputField($val, $key, $obj->$key, ''); + print ''; + if (! $i) $totalarray['nbfield']++; + if (! empty($val['isameasure'])) + { + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.'.$key; + $totalarray['val']['t.'.$key] += $obj->$key; + } } - // Fields from hook - $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - // Action column - print ''; - if (! $i) $totalarray['nbfield']++; - - print ''; - } - $i++; + } + // Extra fields + if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key => $val) + { + if (! empty($arrayfields["ef.".$key]['checked'])) + { + $align=$extrafields->getAlignFlag($key); + print ''; + $tmpkey='options_'.$key; + print $extrafields->showOutputField($key, $obj->$tmpkey, ''); + print ''; + if (! $i) $totalarray['nbfield']++; + if (! empty($val['isameasure'])) + { + if (! $i) $totalarray['pos'][$totalarray['nbfield']]='ef.'.$tmpkey; + $totalarray['val']['ef.'.$tmpkey] += $obj->$tmpkey; + } + } + } + } + // Fields from hook + $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj); + $reshook=$hookmanager->executeHooks('printFieldListValue', $parameters, $object); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + // Action column + print ''; + if (! $i) $totalarray['nbfield']++; + + print ''; + + $i++; } // Show total line if (isset($totalarray['pos'])) { - print ''; - $i=0; - while ($i < $totalarray['nbfield']) - { - $i++; - if (! empty($totalarray['pos'][$i])) print ''; - else - { - if ($i == 1) - { - if ($num < $limit) print ''; - else print ''; - } - print ''; - } - } - print ''; + print ''; + $i=0; + while ($i < $totalarray['nbfield']) + { + $i++; + if (! empty($totalarray['pos'][$i])) print ''; + else + { + if ($i == 1) + { + if ($num < $limit) print ''; + else print ''; + } + else print ''; + } + } + print ''; } // If no record found if ($num == 0) { - $colspan=1; - foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } - print ''; + $colspan=1; + foreach($arrayfields as $key => $val) { if (! empty($val['checked'])) $colspan++; } + print ''; } $db->free($resql); $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql); -$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook +$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters, $object); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; - if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) - { - $crit=$val; - $tmpkey=preg_replace('/search_options_/','',$key); - $searchclass=''; - if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; - if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; - print ''; - } - print ''; + if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')) && empty($extrafields->attribute_computed[$key])) + { + $crit=$val; + $tmpkey=preg_replace('/search_options_/','',$key); + $searchclass=''; + if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring'; + if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum'; + print ''; + } + print ''; @@ -384,28 +388,29 @@ print '
'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { - $selected=0; - if (in_array($obj->rowid, $arrayofselected)) $selected=1; - print ''; - } - print '
'; + if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined + { + $selected=0; + if (in_array($obj->rowid, $arrayofselected)) $selected=1; + print ''; + } + print '
'.price($totalarray['val'][$totalarray['pos'][$i]]).''.$langs->trans("Total").''.$langs->trans("Totalforthispage").'
'.price($totalarray['val'][$totalarray['pos'][$i]]).''.$langs->trans("Total").''.$langs->trans("Totalforthispage").'
'.$langs->trans("NoRecordFound").'
'.$langs->trans("NoRecordFound").'
'."\n"; @@ -544,27 +548,27 @@ print '
'."\n"; print ''."\n"; -if ($nbtotalofrecords === '' || $nbtotalofrecords) +if (in_array('builddoc',$arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) - { - require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); - $formfile = new FormFile($db); + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) + { + require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'); + $formfile = new FormFile($db); - // Show list of available documents - $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource.=str_replace('&','&',$param); + // Show list of available documents + $urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource.=str_replace('&','&',$param); - $filedir=$diroutputmassaction; - $genallowed=$user->rights->inventory->read; - $delallowed=$user->rights->inventory->create; + $filedir=$diroutputmassaction; + $genallowed=$user->rights->mymodule->read; + $delallowed=$user->rights->mymodule->create; - print $formfile->showdocuments('massfilesarea_inventory','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); - } - else - { - print '
'.$langs->trans("ShowTempMassFilesArea").''; - } + print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,''); + } + else + { + print '
'.$langs->trans("ShowTempMassFilesArea").''; + } } // End of page From 831099fef829a144f937bed94520d877cfc98872 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Nov 2017 16:24:42 +0100 Subject: [PATCH 17/19] Debug modulebuilder --- htdocs/core/class/commonobject.class.php | 9 +- .../install/mysql/migration/6.0.0-7.0.0.sql | 2 + .../install/mysql/tables/llx_entrepot.key.sql | 2 +- .../mysql/tables/llx_inventory.key.sql | 2 + .../modulebuilder/template/myobject_list.php | 8 +- htdocs/product/inventory/card.php | 35 +-- .../inventory/class/inventory.class.php | 240 +++++++++++++++--- htdocs/product/inventory/list.php | 76 +++--- 8 files changed, 289 insertions(+), 85 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5741d3dcc81..93031ef9725 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6147,8 +6147,9 @@ abstract class CommonObject // Clean and check mandatory foreach($keys as $key) { - if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key]=''; // This is an implicit foreign key field - if (! empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key]=''; // This is an explicit foreign key field + // If field is an implicit foreign key field + if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key]=''; + if (! empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key]=''; //var_dump($key.'-'.$values[$key].'-'.($this->fields[$key]['notnull'] == 1)); if ($this->fields[$key]['notnull'] == 1 && empty($values[$key])) @@ -6156,6 +6157,10 @@ abstract class CommonObject $error++; $this->errors[]=$langs->trans("ErrorFieldRequired", $this->fields[$key]['label']); } + + // If field is an implicit foreign key field + if (preg_match('/^integer:/i', $this->fields[$key]['type']) && empty($values[$key])) $values[$key]='null'; + if (! empty($this->fields[$key]['foreignkey']) && empty($values[$key])) $values[$key]='null'; } if ($error) return -1; diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql index 2112e457a39..dbbc382acf3 100644 --- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql +++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql @@ -68,6 +68,8 @@ ALTER TABLE llx_website_page ADD COLUMN fk_user_modif integer; -- For 7.0 +ALTER TABLE llx_inventory ADD UNIQUE INDEX uk_inventory_ref (ref, entity); + ALTER table llx_entrepot CHANGE COLUMN label ref varchar(255); UPDATE llx_paiementfourn SET ref = rowid WHERE ref IS NULL; diff --git a/htdocs/install/mysql/tables/llx_entrepot.key.sql b/htdocs/install/mysql/tables/llx_entrepot.key.sql index 724afa027d2..3f9137e57ee 100644 --- a/htdocs/install/mysql/tables/llx_entrepot.key.sql +++ b/htdocs/install/mysql/tables/llx_entrepot.key.sql @@ -17,4 +17,4 @@ -- ============================================================================ -ALTER TABLE llx_entrepot ADD UNIQUE INDEX uk_entrepot_label (label, entity); +ALTER TABLE llx_entrepot ADD UNIQUE INDEX uk_entrepot_label (ref, entity); diff --git a/htdocs/install/mysql/tables/llx_inventory.key.sql b/htdocs/install/mysql/tables/llx_inventory.key.sql index bf76381e108..b6c41f8aef1 100644 --- a/htdocs/install/mysql/tables/llx_inventory.key.sql +++ b/htdocs/install/mysql/tables/llx_inventory.key.sql @@ -17,5 +17,7 @@ -- -- =================================================================== +ALTER TABLE llx_inventory ADD UNIQUE INDEX uk_inventory_ref (ref, entity); + ALTER TABLE llx_inventory ADD INDEX idx_inventory_tms (tms); ALTER TABLE llx_inventory ADD INDEX idx_inventory_datec (datec); diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index a70308eaf42..a2278f0030f 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -388,7 +388,7 @@ print ''; foreach($object->fields as $key => $val) { $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align=($align?' ':'').'center'; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; if ($key == 'status') $align.=($align?' ':'').'center'; if (! empty($arrayfields['t.'.$key]['checked'])) print ''; @@ -434,7 +434,7 @@ print ''; foreach($object->fields as $key => $val) { $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align=($align?' ':'').'center'; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; if ($key == 'status') $align.=($align?' ':'').'center'; if (! empty($arrayfields['t.'.$key]['checked'])) print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($align?'class="'.$align.'"':''), $sortfield, $sortorder, $align.' ')."\n"; @@ -490,8 +490,8 @@ while ($i < min($num, $limit)) foreach($object->fields as $key => $val) { $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; - if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; if ($key == 'status') $align.=($align?' ':'').'center'; if (! empty($arrayfields['t.'.$key]['checked'])) { diff --git a/htdocs/product/inventory/card.php b/htdocs/product/inventory/card.php index 97fa5140fba..9e9435ac67c 100644 --- a/htdocs/product/inventory/card.php +++ b/htdocs/product/inventory/card.php @@ -24,6 +24,7 @@ require '../../main.inc.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; include_once DOL_DOCUMENT_ROOT.'/product/inventory/class/inventory.class.php'; +include_once DOL_DOCUMENT_ROOT.'/product/inventory/lib/inventory.lib.php'; // Load traductions files requiredby by page $langs->loadLangs(array("inventory","other")); @@ -38,7 +39,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); // Initialize technical objects $object=new Inventory($db); $extrafields = new ExtraFields($db); -$diroutputmassaction=$conf->inventory->dir_output . '/temp/massgeneration/'.$user->id; +$diroutputmassaction=$conf->stock->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('inventorycard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('inventory'); @@ -79,16 +80,16 @@ if (empty($reshook)) { $error=0; - $permissiontoadd = $user->rights->inventory->create; - $permissiontodelete = $user->rights->inventory->delete; - $backurlforlist = dol_buildpath('/inventory/inventory_list.php',1); + $permissiontoadd = $user->rights->stock->creer; + $permissiontodelete = $user->rights->stock->supprimer; + $backurlforlist = DOL_URL_ROOT.'/product/inventory/list.php'; // Actions cancel, add, update or delete include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; - + // Actions when printing a doc from card include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php'; - + // Actions to send emails /*$trigger_name='MYOBJECT_SENTBYMAIL'; $autocopy='MAIN_MAIL_AUTOCOPY_MYOBJECT_TO'; @@ -136,10 +137,10 @@ if ($action == 'create') dol_fiche_head(array(), ''); print ''."\n"; - + // Common attributes include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php'; - + // Other attributes include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php'; @@ -170,10 +171,10 @@ if (($id || $ref) && $action == 'edit') dol_fiche_head(); print '
'."\n"; - + // Common attributes include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php'; - + // Other attributes include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php'; @@ -193,7 +194,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { $res = $object->fetch_optionals($object->id, $extralabels); - $head = inventory_prepare_head($object); + $head = inventoryPrepareHead($object); dol_fiche_head($head, 'inventory', $langs->trans("Inventory"), -1, 'inventory'); $formconfirm = ''; @@ -288,7 +289,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Common attributes include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; - + // Other attributes include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; @@ -303,7 +304,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; print '
';*/ - + print ''; print ''; @@ -332,7 +333,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { print ''.$langs->trans('Modify').''."\n"; } - + if ($user->rights->inventory->delete) { print ''.$langs->trans('Delete').''."\n"; @@ -355,7 +356,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { print '
'; print ''; // ancre - + // Documents /*$objref = dol_sanitizeFileName($object->ref); $relativepath = $comref . '/' . $comref . '.pdf'; @@ -374,11 +375,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'; $MAXEVENT = 10; - + $morehtmlright = ''; $morehtmlright.= $langs->trans("SeeAll"); $morehtmlright.= ''; - + // List of actions on element include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php'; $formactions = new FormActions($db); diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index cea53f610c0..d0097a11647 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -51,18 +51,24 @@ class Inventory extends CommonObject /** * @var string String with name of icon for inventory */ - public $picto = 'inventory'; + public $picto = 'stock'; /** - * 'type' if the field format, 'label' the translation key, 'enabled' is a condition when the filed must be managed, - * 'visible' says if field is visible in list (-1 means not shown by default but can be aded into list to be viewed) - * 'notnull' if not null in database - * 'index' if we want an index in database - * 'position' is the sort order of field - * 'searchall' is 1 if we want to search in this field when making a search from the quick search button - * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). - * 'comment' is not used. You can store here any text of your choice. + * 'type' if the field format. + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed. + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'position' is the sort order of field. + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'help' is a string visible as a tooltip on field + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * 'default' is a default value for creation (can still be replaced by the global setup of default values) + * 'showoncombobox' if field must be shown into the label of combobox */ // BEGIN MODULEBUILDER PROPERTIES @@ -150,16 +156,130 @@ class Inventory extends CommonObject } + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + return $this->createCommon($user, $notrigger); + } + + /** + * Clone and object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $hookmanager, $langs; + $error = 0; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $object = new self($this->db); + + $this->db->begin(); + + // Load source object + $object->fetchCommon($fromid); + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); + + // Clear fields + $object->ref = "copy_of_".$object->ref; + $object->title = $langs->trans("CopyOf")." ".$object->title; + // ... + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } + + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + return $result; + } + + /** + * Load object lines in memory from the database + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + /*public function fetchLines() + { + $this->lines=array(); + + // Load lines with object MyObjectLine + + return count($this->lines)?1:0; + }*/ + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + } + /** * Return a link to the object card (with optionaly the picto) * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @return string String with URL + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL */ - function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='') + function getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1) { global $db, $conf, $langs; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -174,7 +294,7 @@ class Inventory extends CommonObject $label.= '
'; $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; - $url = $url = dol_buildpath('/inventory/m_card.php',1).'?id='.$this->id; + $url = dol_buildpath('/product/inventory/card.php',1).'?id='.$this->id; $linkclose=''; if (empty($notooltip)) @@ -193,12 +313,12 @@ class Inventory extends CommonObject $linkstart.=$linkclose.'>'; $linkend=''; - if ($withpicto) - { - $result.=($linkstart.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend); - if ($withpicto != 2) $result.=' '; - } - $result.= $linkstart . $this->ref . $linkend; + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + return $result; } @@ -217,7 +337,7 @@ class Inventory extends CommonObject * Return the status * * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto, 6=Long label + Picto * @return string Label of status */ static function LibStatut($status,$mode=0) @@ -227,41 +347,101 @@ class Inventory extends CommonObject if ($mode == 0) { $prefix=''; + if ($status == 0) return $langs->trans('Draft'); if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + if ($status == -1) return $langs->trans('Canceled'); } if ($mode == 1) { + if ($status == 0) return $langs->trans('Draft'); if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + if ($status == -1) return $langs->trans('Canceled'); } if ($mode == 2) { + if ($status == 0) return img_picto($langs->trans('Draft'),'statut5').' '.$langs->trans('Draft'); if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + if ($status == -1) return img_picto($langs->trans('Canceled'),'statut6').' '.$langs->trans('Canceled'); } if ($mode == 3) { + if ($status == 0) return img_picto($langs->trans('Draft'),'statut5'); if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5'); + if ($status == -1) return img_picto($langs->trans('Canceled'),'statut6'); } if ($mode == 4) { + if ($status == 0) return img_picto($langs->trans('Draft'),'statut5').' '.$langs->trans('Draft'); if ($status == 1) return img_picto($langs->trans('Enabled'),'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'),'statut5').' '.$langs->trans('Disabled'); + if ($status == -1) return img_picto($langs->trans('Canceled'),'statut6').' '.$langs->trans('Canceled'); } if ($mode == 5) { + if ($status == 0) return $langs->trans('Draft').' '.img_picto($langs->trans('Draft'),'statut5'); if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + if ($status == -1) return $langs->trans('Canceled').' '.img_picto($langs->trans('Canceled'),'statut6'); } if ($mode == 6) { + if ($status == 0) return $langs->trans('Draft').' '.img_picto($langs->trans('Draft'),'statut5'); if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'),'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'),'statut5'); + if ($status == -1) return $langs->trans('Canceled').' '.img_picto($langs->trans('Canceled'),'statut6'); } } + /** + * Charge les informations d'ordre info dans l'objet commande + * + * @param int $id Id of order + * @return void + */ + function info($id) + { + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql.= ' fk_user_creat, fk_user_modif'; + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql.= ' WHERE t.rowid = '.$id; + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + + if ($obj->fk_user_valid) + { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) + { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } + + $this->db->free($result); + + } + else + { + dol_print_error($this->db); + } + } /** * Initialise object with example values diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php index 17f60f22944..7496ae18078 100644 --- a/htdocs/product/inventory/list.php +++ b/htdocs/product/inventory/list.php @@ -117,37 +117,37 @@ if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } $parameters=array(); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if (empty($reshook)) { - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - // Purge search criteria - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers - { - foreach($object->fields as $key => $val) - { - $search[$key]=''; - } - $toselect=''; - $search_array_options=array(); - } - if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') - || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) - { - $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation - } + // Purge search criteria + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') ||GETPOST('button_removefilter','alpha')) // All tests are required to be compatible with all browsers + { + foreach($object->fields as $key => $val) + { + $search[$key]=''; + } + $toselect=''; + $search_array_options=array(); + } + if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha') + || GETPOST('button_search_x','alpha') || GETPOST('button_search.x','alpha') || GETPOST('button_search','alpha')) + { + $massaction=''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } - // Mass actions - $objectclass='Inventory'; - $objectlabel='Inventory'; - $permtoread = $user->rights->inventory->read; - $permtodelete = $user->rights->inventory->delete; - $uploaddir = $conf->inventory->dir_output; - //include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; // TODO to fix for product module + // Mass actions + $objectclass='Inventory'; + $objectlabel='Inventory'; + $permtoread = $user->rights->stock->lire; + $permtodelete = $user->rights->stock->supprimer; + $uploaddir = $conf->stock->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -209,6 +209,21 @@ foreach ($search_array_options as $key => $val) $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; + +/* If a group by is required + $sql.= " GROUP BY " + foreach($object->fields as $key => $val) + { + $sql.='t.'.$key.', '; + } + // Add fields from extrafields + foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key : ''); + // Add where from hooks + $parameters=array(); + $reshook=$hookmanager->executeHooks('printFieldListGroupBy',$parameters); // Note that $action and $object may have been modified by hook + $sql.=$hookmanager->resPrint; + */ + $sql.=$db->order($sortfield,$sortorder); // Count total nb of records @@ -221,7 +236,6 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql.= $db->plimit($limit+1, $offset); -dol_syslog($script_file, LOG_DEBUG); $resql=$db->query($sql); if (! $resql) { @@ -283,7 +297,7 @@ $arrayofmassactions = array( 'presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"), ); -if ($user->rights->inventory->delete) $arrayofmassactions['predelete']=$langs->trans("Delete"); +if ($user->rights->stock->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); $massactionbutton=$form->selectMassAction('', $arrayofmassactions); @@ -445,8 +459,8 @@ while ($i < min($num, $limit)) foreach($object->fields as $key => $val) { $align=''; - if (in_array($val['type'], array('date','datetime','timestamp'))) $align='center'; - if (in_array($val['type'], array('timestamp'))) $align.='nowrap'; + if (in_array($val['type'], array('date','datetime','timestamp'))) $align.=($align?' ':'').'center'; + if (in_array($val['type'], array('timestamp'))) $align.=($align?' ':'').'nowrap'; if ($key == 'status') $align.=($align?' ':'').'center'; if (! empty($arrayfields['t.'.$key]['checked'])) { @@ -500,9 +514,9 @@ while ($i < min($num, $limit)) } print ''; if (! $i) $totalarray['nbfield']++; - + print ''; - + $i++; } From 438a68968fffd8459a4614591d370fbf04e01bca Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Nov 2017 16:28:24 +0100 Subject: [PATCH 18/19] Fix regression --- htdocs/core/modules/modStock.class.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index e31b15d81dd..a130c784ef8 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -168,9 +168,9 @@ class modStock extends DolibarrModules $this->export_code[$r]=$this->rights_class; $this->export_label[$r]="WarehousesAndProducts"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("stock","lire")); - $this->export_fields_array[$r]=array('e.rowid'=>'IdWarehouse','e.label'=>'LocationSummary','e.description'=>'DescWareHouse','e.lieu'=>'LieuWareHouse','e.address'=>'Address','e.zip'=>'Zip','e.town'=>'Town','p.rowid'=>"ProductId",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",'p.note'=>"Note",'p.price'=>"Price",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell",'p.tobuy'=>'OnBuy','p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification','ps.reel'=>'Stock'); - $this->export_TypeFields_array[$r]=array('e.rowid'=>'List:entrepot:label','e.label'=>'Text','e.lieu'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text','p.rowid'=>"List:product:label",'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text",'p.price'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date','ps.reel'=>'Numeric'); - $this->export_entities_array[$r]=array('e.rowid'=>'warehouse','e.label'=>'warehouse','e.description'=>'warehouse','e.lieu'=>'warehouse','e.address'=>'warehouse','e.zip'=>'warehouse','e.town'=>'warehouse','p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",'p.note'=>"product",'p.price'=>"product",'p.tva_tx'=>'product','p.tosell'=>"product",'p.tobuy'=>"product",'p.duration'=>"product",'p.datec'=>'product','p.tms'=>'product','ps.reel'=>'stock'); + $this->export_fields_array[$r]=array('e.rowid'=>'IdWarehouse','e.ref'=>'LocationSummary','e.description'=>'DescWareHouse','e.lieu'=>'LieuWareHouse','e.address'=>'Address','e.zip'=>'Zip','e.town'=>'Town','p.rowid'=>"ProductId",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",'p.note'=>"Note",'p.price'=>"Price",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell",'p.tobuy'=>'OnBuy','p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification','ps.reel'=>'Stock'); + $this->export_TypeFields_array[$r]=array('e.rowid'=>'List:entrepot:ref','e.ref'=>'Text','e.lieu'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text','p.rowid'=>"List:product:label",'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text",'p.price'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date','ps.reel'=>'Numeric'); + $this->export_entities_array[$r]=array('e.rowid'=>'warehouse','e.ref'=>'warehouse','e.description'=>'warehouse','e.lieu'=>'warehouse','e.address'=>'warehouse','e.zip'=>'warehouse','e.town'=>'warehouse','p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",'p.note'=>"product",'p.price'=>"product",'p.tva_tx'=>'product','p.tosell'=>"product",'p.tobuy'=>"product",'p.duration'=>"product",'p.datec'=>'product','p.tms'=>'product','ps.reel'=>'stock'); $this->export_aggregate_array[$r]=array('ps.reel'=>'SUM'); // TODO Not used yet $this->export_dependencies_array[$r]=array('stock'=>array('p.rowid','e.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them. $this->export_sql_start[$r]='SELECT DISTINCT '; @@ -188,9 +188,9 @@ class modStock extends DolibarrModules $this->export_code[$r]=$this->rights_class.'_lot'; $this->export_label[$r]="WarehousesAndProductsBatchDetail"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("stock","lire")); - $this->export_fields_array[$r]=array('e.rowid'=>'IdWarehouse','e.label'=>'LocationSummary','e.description'=>'DescWareHouse','e.lieu'=>'LieuWareHouse','e.address'=>'Address','e.zip'=>'Zip','e.town'=>'Town','p.rowid'=>"ProductId",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",'p.note'=>"Note",'p.price'=>"Price",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell",'p.tobuy'=>'OnBuy','p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification','pb.rowid'=>'Id','pb.batch'=>'Batch','pb.eatby'=>'EatByDate','pb.sellby'=>'SellByDate','pb.qty'=>'Qty'); - $this->export_TypeFields_array[$r]=array('e.rowid'=>'List:entrepot:label','e.label'=>'Text','e.lieu'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text','p.rowid'=>"List:product:label",'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text",'p.price'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date','pb.batch'=>'Text','pb.eatby'=>'Date','pb.sellby'=>'Date','pb.qty'=>'Numeric'); - $this->export_entities_array[$r]=array('e.rowid'=>'warehouse','e.label'=>'warehouse','e.description'=>'warehouse','e.lieu'=>'warehouse','e.address'=>'warehouse','e.zip'=>'warehouse','e.town'=>'warehouse','p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",'p.note'=>"product",'p.price'=>"product",'p.tva_tx'=>'product','p.tosell'=>"product",'p.tobuy'=>"product",'p.duration'=>"product",'p.datec'=>'product','p.tms'=>'product','pb.rowid'=>'batch','pb.batch'=>'batch','pb.eatby'=>'batch','pb.sellby'=>'batch','pb.qty'=>'batch'); + $this->export_fields_array[$r]=array('e.rowid'=>'IdWarehouse','e.ref'=>'LocationSummary','e.description'=>'DescWareHouse','e.lieu'=>'LieuWareHouse','e.address'=>'Address','e.zip'=>'Zip','e.town'=>'Town','p.rowid'=>"ProductId",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",'p.note'=>"Note",'p.price'=>"Price",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell",'p.tobuy'=>'OnBuy','p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification','pb.rowid'=>'Id','pb.batch'=>'Batch','pb.eatby'=>'EatByDate','pb.sellby'=>'SellByDate','pb.qty'=>'Qty'); + $this->export_TypeFields_array[$r]=array('e.rowid'=>'List:entrepot:ref','e.ref'=>'Text','e.lieu'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text','p.rowid'=>"List:product:label",'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text",'p.price'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date','pb.batch'=>'Text','pb.eatby'=>'Date','pb.sellby'=>'Date','pb.qty'=>'Numeric'); + $this->export_entities_array[$r]=array('e.rowid'=>'warehouse','e.ref'=>'warehouse','e.description'=>'warehouse','e.lieu'=>'warehouse','e.address'=>'warehouse','e.zip'=>'warehouse','e.town'=>'warehouse','p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",'p.note'=>"product",'p.price'=>"product",'p.tva_tx'=>'product','p.tosell'=>"product",'p.tobuy'=>"product",'p.duration'=>"product",'p.datec'=>'product','p.tms'=>'product','pb.rowid'=>'batch','pb.batch'=>'batch','pb.eatby'=>'batch','pb.sellby'=>'batch','pb.qty'=>'batch'); $this->export_aggregate_array[$r]=array('ps.reel'=>'SUM'); // TODO Not used yet $this->export_dependencies_array[$r]=array('batch'=>array('pb.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them. $this->export_sql_start[$r]='SELECT DISTINCT '; @@ -203,9 +203,9 @@ class modStock extends DolibarrModules $this->export_code[$r]=$this->rights_class.'_movement'; $this->export_label[$r]="StockMovements"; // Translation key (used only if key ExportDataset_xxx_z not found) $this->export_permission[$r]=array(array("stock","lire")); - $this->export_fields_array[$r]=array('e.rowid'=>'IdWarehouse','e.label'=>'LocationSummary','e.description'=>'DescWareHouse','e.lieu'=>'LieuWareHouse','e.address'=>'Address','e.zip'=>'Zip','e.town'=>'Town','p.rowid'=>"ProductId",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",'p.note'=>"Note",'p.price'=>"Price",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell",'p.tobuy'=>'OnBuy','p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification','sm.rowid'=>'MovementId','sm.value'=>'Qty','sm.datem'=>'DateMovement','sm.label'=>'LabelMovement','sm.inventorycode'=>'InventoryCode'); - $this->export_TypeFields_array[$r]=array('e.rowid'=>'List:entrepot:label','e.label'=>'Text','e.lieu'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text','p.rowid'=>"List:product:label",'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text",'p.price'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date','sm.rowid'=>'Numeric','sm.value'=>'Numeric','sm.datem'=>'Date','sm.batch'=>'Text','sm.label'=>'Text','sm.inventorycode'=>'Text'); - $this->export_entities_array[$r]=array('e.rowid'=>'warehouse','e.label'=>'warehouse','e.description'=>'warehouse','e.lieu'=>'warehouse','e.address'=>'warehouse','e.zip'=>'warehouse','e.town'=>'warehouse','p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",'p.note'=>"product",'p.price'=>"product",'p.tva_tx'=>'product','p.tosell'=>"product",'p.tobuy'=>"product",'p.duration'=>"product",'p.datec'=>'product','p.tms'=>'product','sm.rowid'=>'movement','sm.value'=>'movement','sm.datem'=>'movement','sm.label'=>'movement','sm.inventorycode'=>'movement'); + $this->export_fields_array[$r]=array('e.rowid'=>'IdWarehouse','e.ref'=>'LocationSummary','e.description'=>'DescWareHouse','e.lieu'=>'LieuWareHouse','e.address'=>'Address','e.zip'=>'Zip','e.town'=>'Town','p.rowid'=>"ProductId",'p.ref'=>"Ref",'p.fk_product_type'=>"Type",'p.label'=>"Label",'p.description'=>"Description",'p.note'=>"Note",'p.price'=>"Price",'p.tva_tx'=>'VAT','p.tosell'=>"OnSell",'p.tobuy'=>'OnBuy','p.duration'=>"Duration",'p.datec'=>'DateCreation','p.tms'=>'DateModification','sm.rowid'=>'MovementId','sm.value'=>'Qty','sm.datem'=>'DateMovement','sm.label'=>'LabelMovement','sm.inventorycode'=>'InventoryCode'); + $this->export_TypeFields_array[$r]=array('e.rowid'=>'List:entrepot:ref','e.ref'=>'Text','e.lieu'=>'Text','e.address'=>'Text','e.zip'=>'Text','e.town'=>'Text','p.rowid'=>"List:product:label",'p.ref'=>"Text",'p.fk_product_type'=>"Text",'p.label'=>"Text",'p.description'=>"Text",'p.note'=>"Text",'p.price'=>"Numeric",'p.tva_tx'=>'Numeric','p.tosell'=>"Boolean",'p.tobuy'=>"Boolean",'p.duration'=>"Duree",'p.datec'=>'Date','p.tms'=>'Date','sm.rowid'=>'Numeric','sm.value'=>'Numeric','sm.datem'=>'Date','sm.batch'=>'Text','sm.label'=>'Text','sm.inventorycode'=>'Text'); + $this->export_entities_array[$r]=array('e.rowid'=>'warehouse','e.ref'=>'warehouse','e.description'=>'warehouse','e.lieu'=>'warehouse','e.address'=>'warehouse','e.zip'=>'warehouse','e.town'=>'warehouse','p.rowid'=>"product",'p.ref'=>"product",'p.fk_product_type'=>"product",'p.label'=>"product",'p.description'=>"product",'p.note'=>"product",'p.price'=>"product",'p.tva_tx'=>'product','p.tosell'=>"product",'p.tobuy'=>"product",'p.duration'=>"product",'p.datec'=>'product','p.tms'=>'product','sm.rowid'=>'movement','sm.value'=>'movement','sm.datem'=>'movement','sm.label'=>'movement','sm.inventorycode'=>'movement'); if ($conf->productbatch->enabled) { $this->export_fields_array[$r]['sm.batch']='Batch'; @@ -232,7 +232,7 @@ class modStock extends DolibarrModules $this->import_entities_array[$r]=array(); // We define here only fields that use another icon that the one defined into import_icon $this->import_tables_array[$r]=array('e'=>MAIN_DB_PREFIX.'entrepot'); $this->import_tables_creator_array[$r]=array('e'=>'fk_user_author'); - $this->import_fields_array[$r]=array('e.label'=>"LocationSummary*", + $this->import_fields_array[$r]=array('e.ref'=>"LocationSummary*", 'e.description'=>"DescWareHouse",'e.lieu'=>"LieuWareHouse", 'e.address'=>"Address",'e.zip'=>'Zip','e.fk_pays'=>'CountryCode', 'e.statut'=>'Status' @@ -242,7 +242,7 @@ class modStock extends DolibarrModules 'e.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry') ); $this->import_regex_array[$r]=array('e.statut'=>'^[0|1]'); - $this->import_examplevalues_array[$r]=array('e.label'=>"ALM001", + $this->import_examplevalues_array[$r]=array('e.ref'=>"ALM001", 'e.description'=>"Central Warehouse",'e.lieu'=>"Central", 'e.address'=>"Route 66",'e.zip'=>'28080','e.fk_pays'=>'US', 'e.statut'=>'1'); @@ -258,7 +258,7 @@ class modStock extends DolibarrModules $this->import_convertvalue_array[$r]=array( 'ps.fk_product'=>array('rule'=>'fetchidfromref','classfile'=>'/product/class/product.class.php','class'=>'Product','method'=>'fetch','element'=>'product'), - 'ps.fk_entrepot'=>array('rule'=>'fetchidfromref','classfile'=>'/product/stock/class/entrepot.class.php','class'=>'Entrepot','method'=>'fetch','element'=>'label') + 'ps.fk_entrepot'=>array('rule'=>'fetchidfromref','classfile'=>'/product/stock/class/entrepot.class.php','class'=>'Entrepot','method'=>'fetch','element'=>'ref') ); $this->import_examplevalues_array[$r]=array( 'ps.fk_product'=>"PREF123456",'ps.fk_entrepot'=>"ALM001",'ps.reel'=>"10" From 06de67cb8a0f6b61a8261f6c2ab17814fe9f3a4c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 24 Nov 2017 16:37:19 +0100 Subject: [PATCH 19/19] Update purchasesjournal.php --- htdocs/accountancy/journal/purchasesjournal.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index aa185b5c897..ac9955608c1 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -58,11 +58,16 @@ if ($user->societe_id > 0) $hookmanager->initHooks(array('purchasesjournal')); $parameters=array(); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$user,$action); // Note that $action and $object may have been modified by some hooks /* * Actions */ +$reshook=$hookmanager->executeHooks('doActions',$parameters,$user,$action); // Note that $action and $object may have been modified by some hooks + + +/* + * Views + */ // Get informations of journal $accountingjournalstatic = new AccountingJournal($db);