diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php
index 8269d75b961..244b9951f54 100644
--- a/htdocs/admin/workflow.php
+++ b/htdocs/admin/workflow.php
@@ -28,7 +28,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page
-$langs->loadLangs(array("admin","workflow","propal","workflow","orders","supplier_proposals"));
+$langs->loadLangs(array("admin","workflow","propal","workflow","orders","supplier_proposals","receptions"));
if (! $user->admin) accessforbidden();
@@ -87,7 +87,7 @@ $workflowcodes=array(
// Automatic classification supplier order
'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_SUPPLIER_ORDER'=>array('family'=>'classify_supplier_order', 'position'=>62, 'enabled'=>'! empty($conf->fournisseur->enabled)', 'picto'=>'order','warning'=>''),
//Automatic classification reception
- 'WORKFLOW_BILL_ON_RECEPTION'=>array('family'=>'classify', 'position'=>30, 'enabled'=>'! empty($conf->reception->enabled) && ! empty($conf->fournisseur->enabled)', 'picto'=>'bill'),
+ 'WORKFLOW_BILL_ON_RECEPTION'=>array('family'=>'classify_reception', 'position'=>30, 'enabled'=>'! empty($conf->reception->enabled) && ! empty($conf->fournisseur->enabled)', 'picto'=>'bill'),
);
if (! empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['workflow']))
@@ -140,6 +140,7 @@ foreach($workflowcodes as $key => $params)
if ($reg[1] == 'order') print ' - '.$langs->trans('Order');
if ($reg[1] == 'supplier_proposal') print ' - '.$langs->trans('SupplierProposal');
if ($reg[1] == 'supplier_order') print ' - '.$langs->trans('SupplierOrder');
+ if ($reg[1] == 'reception') print ' - '.$langs->trans('Reception');
}
else
{
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index cbf9f127fb7..7dfaf590178 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -4225,6 +4225,7 @@ abstract class CommonObject
}else {
$this->tpl['label'].= ($line->label ? ' '.$line->label : '');
}
+
// Dates
if ($line->product_type == 1 && ($date_start || $date_end))
{
diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php
index 1c8cfd45900..77557a41bff 100644
--- a/htdocs/core/modules/modReception.class.php
+++ b/htdocs/core/modules/modReception.class.php
@@ -44,14 +44,14 @@ class modReception extends DolibarrModules
$this->db = $db;
$this->numero = 104160;
- $this->family = "crm";
+ $this->family = "srm";
$this->module_position = 40;
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "Gestion des réceptions fournisseurs";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
- $this->version = 'dolibarr';
+ $this->version = 'experimental';
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->special = 0;
diff --git a/htdocs/filefunc.inc.php b/htdocs/filefunc.inc.php
index 18c5dd4962a..0c9a6d39e0f 100644
--- a/htdocs/filefunc.inc.php
+++ b/htdocs/filefunc.inc.php
@@ -31,7 +31,7 @@
*/
if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr');
-if (! defined('DOL_VERSION')) define('DOL_VERSION','9.0.0-alpha'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
+if (! defined('DOL_VERSION')) define('DOL_VERSION','9.0.1'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
if (! defined('EURO')) define('EURO',chr(128));
diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php
index d3e927c8173..8cd453836fb 100644
--- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php
@@ -25,6 +25,7 @@
// Put here all includes required by your class file
require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php";
+require_once DOL_DOCUMENT_ROOT."/reception/class/reception.class.php";
//require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php";
//require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php";
@@ -185,10 +186,10 @@ class CommandeFournisseurDispatch extends CommonObject
$sql.= " ".(! isset($this->status)?'NULL':"'".$this->db->escape($this->status)."'").",";
$sql.= " ".(! isset($this->batch)?'NULL':"'".$this->db->escape($this->batch)."'").",";
$sql.= " ".(! isset($this->eatby) || dol_strlen($this->eatby)==0?'NULL':"'".$this->db->idate($this->eatby)."'").",";
- $sql.= " ".(! isset($this->sellby) || dol_strlen($this->sellby)==0?'NULL':"'".$this->db->idate($this->sellby)."'")."";
+ $sql.= " ".(! isset($this->sellby) || dol_strlen($this->sellby)==0?'NULL':"'".$this->db->idate($this->sellby)."'").",";
$sql.= " ".(! isset($this->fk_reception)?'NULL':"'".$this->fk_reception."'")."";
$sql.= ")";
-
+
$this->db->begin();
dol_syslog(__METHOD__, LOG_DEBUG);
@@ -221,6 +222,7 @@ class CommandeFournisseurDispatch extends CommonObject
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
$result=$this->insertExtraFields();
+
if ($result < 0)
{
$error++;
diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php
index 125bee1850c..780aac3aba6 100644
--- a/htdocs/fourn/commande/dispatch.php
+++ b/htdocs/fourn/commande/dispatch.php
@@ -889,8 +889,8 @@ if ($id > 0 || ! empty($ref)) {
}else if(!empty($conf->reception->enabled)){
print '
';
if(!empty($reception->id)){
-
print $reception->getLibStatut(5);
+ }
}
print ' | ';
print '';
diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql
index 09908ac86f5..41698a1a614 100644
--- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql
+++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql
@@ -129,3 +129,89 @@ CREATE TABLE llx_takepos_floor_tables(
UPDATE llx_c_payment_term SET decalage = nbjour, nbjour = 0 where decalage IS NULL AND type_cdr = 2;
+
+-- Reception
+
+ALTER TABLE llx_commande_fournisseur_dispatch ADD COLUMN fk_reception integer DEFAULT NULL;
+ALTER TABLE llx_commande_fournisseur_dispatch CHANGE comment comment TEXT;
+insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECEPTION_VALIDATE','Reception validated','Executed when a reception is validated','reception',22);
+insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECEPTION_SENTBYMAIL','Reception sent by mail','Executed when a reception is sent by mail','reception',22);
+
+create table llx_commande_fournisseur_dispatch_extrafields
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ tms timestamp,
+ fk_object integer NOT NULL, -- object id
+ import_key varchar(14) -- import key
+)ENGINE=innodb;
+
+ALTER TABLE llx_commande_fournisseur_dispatch_extrafields ADD INDEX idx_commande_fournisseur_dispatch_extrafields (fk_object);
+
+
+create table llx_reception
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ tms timestamp,
+ ref varchar(30) NOT NULL,
+ entity integer DEFAULT 1 NOT NULL, -- multi company id
+ fk_soc integer NOT NULL,
+ fk_projet integer DEFAULT NULL,
+
+ ref_ext varchar(30), -- reference into an external system (not used by dolibarr)
+ ref_int varchar(30), -- reference into an internal system (used by dolibarr to store extern id like paypal info)
+ ref_supplier varchar(30), -- customer number
+
+ date_creation datetime, -- date de creation
+ fk_user_author integer, -- author of creation
+ fk_user_modif integer, -- author of last change
+ date_valid datetime, -- date de validation
+ fk_user_valid integer, -- valideur
+ date_delivery datetime DEFAULT NULL, -- date planned of delivery
+ date_reception datetime,
+ fk_shipping_method integer,
+ tracking_number varchar(50),
+ fk_statut smallint DEFAULT 0, -- 0 = draft, 1 = validated, 2 = billed or closed depending on WORKFLOW_BILL_ON_SHIPMENT option
+ billed smallint DEFAULT 0,
+
+ height float, -- height
+ width float, -- with
+ size_units integer, -- unit of all sizes (height, width, depth)
+ size float, -- depth
+ weight_units integer, -- unit of weight
+ weight float, -- weight
+ note_private text,
+ note_public text,
+ model_pdf varchar(255),
+ fk_incoterms integer, -- for incoterms
+ location_incoterms varchar(255), -- for incoterms
+
+ import_key varchar(14),
+ extraparams varchar(255) -- for other parameters with json format
+)ENGINE=innodb;
+
+ALTER TABLE llx_reception ADD UNIQUE INDEX idx_reception_uk_ref (ref, entity);
+
+ALTER TABLE llx_reception ADD INDEX idx_reception_fk_soc (fk_soc);
+ALTER TABLE llx_reception ADD INDEX idx_reception_fk_user_author (fk_user_author);
+ALTER TABLE llx_reception ADD INDEX idx_reception_fk_user_valid (fk_user_valid);
+ALTER TABLE llx_reception ADD INDEX idx_reception_fk_shipping_method (fk_shipping_method);
+
+ALTER TABLE llx_reception ADD CONSTRAINT fk_reception_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid);
+ALTER TABLE llx_reception ADD CONSTRAINT fk_reception_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid);
+ALTER TABLE llx_reception ADD CONSTRAINT fk_reception_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid);
+ALTER TABLE llx_reception ADD CONSTRAINT fk_reception_fk_shipping_method FOREIGN KEY (fk_shipping_method) REFERENCES llx_c_shipment_mode (rowid);
+
+create table llx_reception_extrafields
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ tms timestamp,
+ fk_object integer NOT NULL,
+ import_key varchar(14) -- import key
+) ENGINE=innodb;
+
+ALTER TABLE llx_reception_extrafields ADD INDEX idx_reception_extrafields (fk_object);
+
+ALTER TABLE llx_commande_fournisseur_dispatch ADD INDEX idx_commande_fournisseur_dispatch_fk_reception (fk_reception);
+ALTER TABLE llx_commande_fournisseur_dispatch ADD CONSTRAINT fk_commande_fournisseur_dispatch_fk_reception FOREIGN KEY (fk_reception) REFERENCES llx_reception (rowid);
+
+
diff --git a/htdocs/langs/fr_FR/receptions.lang b/htdocs/langs/fr_FR/receptions.lang
index 2102e282668..8e766344d94 100644
--- a/htdocs/langs/fr_FR/receptions.lang
+++ b/htdocs/langs/fr_FR/receptions.lang
@@ -30,7 +30,7 @@ ReceptionsAndReceivingForSameOrder=Réceptions et réceptions pour cette command
ReceptionsToValidate=Réceptions à valider
StatusReceptionCanceled=Annulée
StatusReceptionDraft=Brouillon
-StatusReceptionValidated=Validée (produits à envoyer ou envoyés)
+StatusReceptionValidated=Validée
StatusReceptionProcessed=Traitée
StatusReceptionDraftShort=Brouillon
StatusReceptionValidatedShort=Validée
diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php
index bb0875c0cbf..0610430ba13 100644
--- a/htdocs/reception/card.php
+++ b/htdocs/reception/card.php
@@ -348,7 +348,7 @@ if (empty($reshook))
$sellbydate = str_replace('/','-',$sellby);
- $ret = $object->addline($entrepot_id, GETPOST($idl, 'int'), GETPOST($qty, 'int'), $array_options[$i], GETPOST($comment, 'alpha'), strtotime($eatbydate),strtotime($sellbydate), GETPOST($batch, 'alpha'));
+ $ret = $object->addline($entrepot_id, GETPOST($idl, 'int'), GETPOST($qty, 'int'), $array_options[$i], GETPOST($comment, 'alpha'), strtotime($eatbydate),strtotime($sellbydate), GETPOST($batch, 'alpha'));
if ($ret < 0)
{
setEventMessages($object->error, $object->errors, 'errors');
@@ -2248,7 +2248,7 @@ else if ($id || $ref)
$formmail->withdeliveryreceipt=1;
$formmail->withcancel=1;
// Tableau des substitutions
- $formmail->setSubstitFromObject($object);
+ $formmail->setSubstitFromObject($object,$langs);
$formmail->substit['__RECEPTIONREF__']=$object->ref;
$formmail->substit['__RECEPTIONTRACKNUM__']=$object->tracking_number;
$formmail->substit['__RECEPTIONTRACKNUMURL__']=$object->tracking_url;
diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php
index 67ee854ec30..06b35efd940 100644
--- a/htdocs/reception/class/reception.class.php
+++ b/htdocs/reception/class/reception.class.php
@@ -264,7 +264,7 @@ class Reception extends CommonObject
for ($i = 0; $i < $num; $i++)
{
$this->lines[$i]->fk_reception = $this->id;
-
+
if (! $this->lines[$i]->create($user) > 0)
{
$error++;
@@ -1025,7 +1025,7 @@ class Reception extends CommonObject
}
}
-
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Load lines
*
@@ -1033,6 +1033,7 @@ class Reception extends CommonObject
*/
function fetch_lines()
{
+ // phpcs:enable
global $db;
dol_include_once('/fourn/class/fournisseur.commande.dispatch.class.php');
$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'commande_fournisseur_dispatch WHERE fk_reception='.$this->id;
@@ -1056,9 +1057,8 @@ class Reception extends CommonObject
$line->subprice = $obj->subprice;
$line->multicurrency_subprice = $obj->multicurrency_subprice;
$line->remise_percent = $obj->remise_percent;
- $line->label = $obj->label;
+ $line->label = !empty($obj->label)?$obj->label:$line->product->label;
$line->ref_supplier = $obj->ref;
-
}else {
$line->qty_asked = 0;
$line->description = '';
@@ -1260,7 +1260,8 @@ class Reception extends CommonObject
}
}
-
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set the planned delivery date
*
@@ -1270,6 +1271,7 @@ class Reception extends CommonObject
*/
function set_date_livraison($user, $date_livraison)
{
+ // phpcs:enable
if ($user->rights->reception->creer)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."reception";
@@ -1294,7 +1296,7 @@ class Reception extends CommonObject
return -2;
}
}
-
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Fetch deliveries method and return an array. Load array this->meths(rowid=>label).
*
@@ -1302,6 +1304,7 @@ class Reception extends CommonObject
*/
function fetch_delivery_methods()
{
+ // phpcs:enable
global $langs;
$this->meths = array();
@@ -1320,7 +1323,7 @@ class Reception extends CommonObject
}
}
}
-
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Fetch all deliveries method and return an array. Load array this->listmeths.
*
@@ -1329,6 +1332,7 @@ class Reception extends CommonObject
*/
function list_delivery_methods($id='')
{
+ // phpcs:enable
global $langs;
$this->listmeths = array();
@@ -1355,6 +1359,7 @@ class Reception extends CommonObject
}
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Update/create delivery method.
*
@@ -1364,6 +1369,7 @@ class Reception extends CommonObject
*/
function update_delivery_method($id='')
{
+ // phpcs:enable
if ($id=='')
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (code, libelle, description, tracking)";
@@ -1382,7 +1388,8 @@ class Reception extends CommonObject
}
if ($resql < 0) dol_print_error($this->db,'');
}
-
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Activate delivery method.
*
@@ -1392,13 +1399,15 @@ class Reception extends CommonObject
*/
function activ_delivery_method($id)
{
+ // phpcs:enable
$sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=1';
$sql.= ' WHERE rowid='.$id;
$resql = $this->db->query($sql);
}
-
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* DesActivate delivery method.
*
@@ -1408,6 +1417,7 @@ class Reception extends CommonObject
*/
function disable_delivery_method($id)
{
+ // phpcs:enable
$sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=0';
$sql.= ' WHERE rowid='.$id;
@@ -1598,7 +1608,7 @@ class Reception extends CommonObject
return -1;
}
}
-
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Classify the reception as invoiced (used when WORKFLOW_BILL_ON_RECEPTION is on)
*
@@ -1606,6 +1616,7 @@ class Reception extends CommonObject
*/
function set_billed()
{
+ // phpcs:enable
global $user;
$error=0;
@@ -1768,6 +1779,7 @@ class Reception extends CommonObject
}
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Set draft status
*
@@ -1776,6 +1788,7 @@ class Reception extends CommonObject
*/
function set_draft($user)
{
+ // phpcs:enable
global $conf,$langs;
$error=0;
diff --git a/htdocs/reception/create-table.php b/htdocs/reception/create-table.php
deleted file mode 100644
index f311fd49d4d..00000000000
--- a/htdocs/reception/create-table.php
+++ /dev/null
@@ -1,316 +0,0 @@
-query($sql);
-if(empty($resql)){
- var_dump($db->error);
-}
-
-$sql=" insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECEPTION_VALIDATE','Reception validated','Executed when a reception is validated','reception',22);";
-
-$resql = $db->query($sql);
-if(empty($resql)){
- print '';
- var_dump($db->error);
- print ' ';
-}
-
-$sql="insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('RECEPTION_SENTBYMAIL','Reception sent by mail','Executed when a reception is sent by mail','reception',22); ";
-
-$resql = $db->query($sql);
-if(empty($resql)){
- print '';
- var_dump($db->error);
- print ' ';
-}
-
-
-$sql=" ALTER TABLE ".MAIN_DB_PREFIX."commande_fournisseur_dispatch CHANGE comment comment TEXT;";
-$resql = $db->query($sql);
-if(empty($resql)){
- var_dump($db->error);
-}
-
-
-
-
-$ok = 0;
-$handle = opendir($dir);
-$tablefound = 0;
-$tabledata = array();
-if (is_resource($handle))
-{
- while (($file = readdir($handle)) !== false)
- {
- if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && !preg_match('/\.key\.sql$/i', $file))
- {
- if (strpos($file, 'reception') !== false || strpos($file, 'commande_fournisseur_dispatch') !== false){
- $tablefound++;
- $tabledata[] = $file;
- }
- }
- }
-
- closedir($handle);
-}
-
-
-
-// Sort list of sql files on alphabetical order (load order is important)
-sort($tabledata);
-foreach ($tabledata as $file)
-{
- $name = substr($file, 0, dol_strlen($file) - 4);
- $buffer = '';
- $fp = fopen($dir.$file, "r");
- if ($fp)
- {
- while (!feof($fp))
- {
- $buf = fgets($fp, 4096);
- if (substr($buf, 0, 2) <> '--')
- {
- $buf = preg_replace('/--(.+)*/', '', $buf);
- $buffer .= $buf;
- }
- }
- fclose($fp);
-
- $buffer = trim($buffer);
- if ($conf->db->type == 'mysql' || $conf->db->type == 'mysqli') // For Mysql 5.5+, we must replace type=innodb with ENGINE=innodb
- {
- $buffer = preg_replace('/type=innodb/i', 'ENGINE=innodb', $buffer);
- }
- else if ($conf->db->type == 'mssql')
- {
- $buffer = preg_replace('/type=innodb/i', '', $buffer);
- $buffer = preg_replace('/ENGINE=innodb/i', '', $buffer);
- }
-
- // Replace the prefix tables
- if ($dolibarr_main_db_prefix != 'llx_')
- {
- $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer);
- }
-
- //print " | | Creation de la table $name/td>";
- $requestnb++;
-
- $resql = $db->query($buffer, 0, 'dml');
- if ($resql)
- {
- // print " | OK requete ==== $buffer |
";
- $db->free($resql);
- }
- else
- {
- if ($db->errno() == 'DB_ERROR_TABLE_ALREADY_EXISTS' ||
- $db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS')
- {
- //print "Deja existante | ";
- }
- else
- {
- print "".$langs->trans("CreateTableAndPrimaryKey", $name);
- print " \n".$langs->trans("Request").' '.$requestnb.' : '.$buffer.' Executed query : '.$db->lastquery;
- print "\n | ";
- print ''.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().' |
';
- $error++;
- }
- }
- }
- else
- {
- print "| ".$langs->trans("CreateTableAndPrimaryKey", $name);
- print " | ";
- print ''.$langs->trans("Error").' Failed to open file '.$dir.$file.' |
';
- $error++;
- }
-}
-
-if ($tablefound)
-{
- if ($error == 0)
- {
- print '| ';
- print $langs->trans("TablesAndPrimaryKeysCreation").' |  |
';
- $ok = 1;
- }
-}
-else
-{
- print '| '.$langs->trans("ErrorFailedToFindSomeFiles", $dir).' |  |
';
-}
-
-
-
-// We always choose in mysql directory (Conversion is done by driver to translate SQL syntax)
-
-
-$okkeys = 0;
-$handle = opendir($dir);
-$tablefound = 0;
-$tabledata = array();
-if (is_resource($handle))
-{
- while (($file = readdir($handle)) !== false)
- {
- if (preg_match('/\.sql$/i', $file) && preg_match('/^llx_/i', $file) && preg_match('/\.key\.sql$/i', $file))
- {
- if (strpos($file, 'reception') !== false || strpos($file, 'commande_fournisseur_dispatch') !== false){
- $tablefound++;
- $tabledata[] = $file;
- }
- }
- }
- closedir($handle);
-}
-
-// Sort list of sql files on alphabetical order (load order is important)
-sort($tabledata);
-foreach ($tabledata as $file)
-{
- $name = substr($file, 0, dol_strlen($file) - 4);
- //print "| Creation de la table $name | ";
- $buffer = '';
- $fp = fopen($dir.$file, "r");
- if ($fp)
- {
- while (!feof($fp))
- {
- $buf = fgets($fp, 4096);
-
- // Cas special de lignes autorisees pour certaines versions uniquement
- if ($choix == 1 && preg_match('/^--\sV([0-9\.]+)/i', $buf, $reg))
- {
- $versioncommande = explode('.', $reg[1]);
- //print var_dump($versioncommande);
- //print var_dump($versionarray);
- if (count($versioncommande) && count($versionarray) && versioncompare($versioncommande, $versionarray) <= 0)
- {
- // Version qualified, delete SQL comments
- $buf = preg_replace('/^--\sV([0-9\.]+)/i', '', $buf);
- //print "Ligne $i qualifiee par version: ".$buf.'
';
- }
- }
- if ($choix == 2 && preg_match('/^--\sPOSTGRESQL\sV([0-9\.]+)/i', $buf, $reg))
- {
- $versioncommande = explode('.', $reg[1]);
- //print var_dump($versioncommande);
- //print var_dump($versionarray);
- if (count($versioncommande) && count($versionarray) && versioncompare($versioncommande, $versionarray) <= 0)
- {
- // Version qualified, delete SQL comments
- $buf = preg_replace('/^--\sPOSTGRESQL\sV([0-9\.]+)/i', '', $buf);
- //print "Ligne $i qualifiee par version: ".$buf.'
';
- }
- }
-
- // Ajout ligne si non commentaire
- if (!preg_match('/^--/i', $buf))
- $buffer .= $buf;
- }
- fclose($fp);
-
- // Si plusieurs requetes, on boucle sur chaque
- $listesql = explode(';', $buffer);
- foreach ($listesql as $req)
- {
- $buffer = trim($req);
- if ($buffer)
- {
- // Replace the prefix tables
- if ($dolibarr_main_db_prefix != 'llx_')
- {
- $buffer = preg_replace('/llx_/i', $dolibarr_main_db_prefix, $buffer);
- }
-
- //print "
| Creation des cles et index de la table $name: '$buffer' | ";
- $requestnb++;
-
- $resql = $db->query($buffer, 0, 'dml');
- if ($resql)
- {
- //print "OK requete ==== $buffer |
";
- $db->free($resql);
- }
- else
- {
- if ($db->errno() == 'DB_ERROR_KEY_NAME_ALREADY_EXISTS' ||
- $db->errno() == 'DB_ERROR_CANNOT_CREATE' ||
- $db->errno() == 'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS' ||
- $db->errno() == 'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS' ||
- preg_match('/duplicate key name/i', $db->error()))
- {
- //print "Deja existante | ";
- $key_exists = 1;
- }
- else
- {
- print "".$langs->trans("CreateOtherKeysForTable", $name);
- print " \n".$langs->trans("Request").' '.$requestnb.' : '.$db->lastqueryerror();
- print "\n | ";
- print ''.$langs->trans("ErrorSQL")." ".$db->errno()." ".$db->error().' |
';
- $error++;
- }
- }
- }
- }
- }
- else
- {
- print "| ".$langs->trans("CreateOtherKeysForTable", $name);
- print " | ";
- print ''.$langs->trans("Error")." Failed to open file ".$dir.$file." |
";
- $error++;
- }
-}
-
-if ($tablefound && $error == 0)
-{
- print '| ';
- print $langs->trans("OtherKeysCreation").' |  |
';
- $okkeys = 1;
-}
-
-
-
-
diff --git a/htdocs/reception/tpl/linkedobjectblock.tpl.php b/htdocs/reception/tpl/linkedobjectblock.tpl.php
index d6dd383ccc8..50069f0a14f 100644
--- a/htdocs/reception/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/reception/tpl/linkedobjectblock.tpl.php
@@ -54,7 +54,7 @@ foreach($linkedObjectBlock as $key => $objectlink)
// For now, receptions must stay linked to order, so link is not deletable
if($object->element != 'order_supplier') {
?>
- id.'&action=dellink&dellinkid='.$key; ?>">transnoentitiesnoconv("RemoveLink")); ?>
+ id.'&action=dellink&dellinkid='.$key; ?>">transnoentitiesnoconv("RemoveLink"), 'unlink'); ?>