'.$langs->trans("ClosePaidInvoicesAutomatically");
+ print '
'.$langs->trans("ClosePaidInvoicesAutomatically");
print '
';
}
diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql
index 6c70b73030f..c8b2ad9a057 100644
--- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql
+++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql
@@ -520,3 +520,14 @@ create table llx_c_price_global_variable_updater
ALTER TABLE llx_adherent CHANGE COLUMN note note_private text DEFAULT NULL;
ALTER TABLE llx_adherent ADD COLUMN note_public text DEFAULT NULL after note_private;
+CREATE TABLE IF NOT EXISTS llx_propal_merge_pdf_product (
+ rowid integer NOT NULL auto_increment PRIMARY KEY,
+ fk_product integer NOT NULL,
+ file_name varchar(200) NOT NULL,
+ lang varchar(5) DEFAULT NULL,
+ fk_user_author integer DEFAULT NULL,
+ fk_user_mod integer NOT NULL,
+ datec datetime NOT NULL,
+ tms timestamp NOT NULL,
+ import_key varchar(14) DEFAULT NULL
+) ENGINE=InnoDB;
\ No newline at end of file
diff --git a/htdocs/install/mysql/tables/llx_propal_merge_pdf_product.sql b/htdocs/install/mysql/tables/llx_propal_merge_pdf_product.sql
new file mode 100644
index 00000000000..93af93c9190
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_propal_merge_pdf_product.sql
@@ -0,0 +1,28 @@
+--
+-- Copyright (C) 2013 Florian HENRY
+--
+-- 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
+-- the Free Software Foundation, either version 3 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License
+-- along with this program. If not, see .
+
+CREATE TABLE IF NOT EXISTS llx_propal_merge_pdf_product (
+ rowid integer NOT NULL auto_increment PRIMARY KEY,
+ fk_product integer NOT NULL,
+ file_name varchar(200) NOT NULL,
+ lang varchar(5) DEFAULT NULL,
+ fk_user_author integer DEFAULT NULL,
+ fk_user_mod integer NOT NULL,
+ datec datetime NOT NULL,
+ tms timestamp NOT NULL,
+ import_key varchar(14) DEFAULT NULL
+) ENGINE=InnoDB;
+
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index cd57a4d5a16..06b18dfbc27 100755
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -1384,6 +1384,7 @@ NumberOfProductShowInSelect=Max number of products in combos select lists (0=no
ConfirmDeleteProductLineAbility=Confirmation when removing product lines in forms
ModifyProductDescAbility=Personalization of product descriptions in forms
ViewProductDescInFormAbility=Visualization of product descriptions in the forms (otherwise as popup tooltip)
+MergePropalProductCard=Activate in product/service Attached Files tab an option to merge product PDF document to proposal PDF azur if product/service is in the proposal
ViewProductDescInThirdpartyLanguageAbility=Visualization of products descriptions in the thirdparty language
UseSearchToSelectProductTooltip=Also if you have a large number of product (> 100 000), you can increase speed by setting constant PRODUCT_DONOTSEARCH_ANYWHERE to 1 in Setup->Other. Search will then be limited to start of string.
UseSearchToSelectProduct=Use a search form to choose a product (rather than a drop-down list).
diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang
index 781f867b5fe..c261b6ff6da 100644
--- a/htdocs/langs/en_US/products.lang
+++ b/htdocs/langs/en_US/products.lang
@@ -267,3 +267,5 @@ GlobalVariableUpdaterHelpFormat1=format is {"URL": "http://example.com/urlofws",
UpdateInterval=Update interval (minutes)
LastUpdated=Last updated
CorrectlyUpdated=Correctly updated
+PropalMergePdfProductActualFile=Files use to add into PDF Azur are/is
+PropalMergePdfProductChooseFile=Select PDF files
diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php
index e50fb9c8ea8..f4f46e263c2 100644
--- a/htdocs/livraison/card.php
+++ b/htdocs/livraison/card.php
@@ -394,7 +394,7 @@ if ($action == 'create')
*/
print '';
$quantite_livree = $commande->livraisons[$line->id];
- print $quantite_livree;;
+ print $quantite_livree;
print ' ';
$quantite_commandee = $line->qty;
diff --git a/htdocs/opensurvey/card.php b/htdocs/opensurvey/card.php
index cf4034308ef..a217f34d939 100644
--- a/htdocs/opensurvey/card.php
+++ b/htdocs/opensurvey/card.php
@@ -367,7 +367,7 @@ if ($comments) {
}
else
{
- print $langs->trans("NoCommentYet").' ';;
+ print $langs->trans("NoCommentYet").' ';
}
print ' ';
diff --git a/htdocs/product/admin/product.php b/htdocs/product/admin/product.php
index c3de8edd468..05f77597cb2 100644
--- a/htdocs/product/admin/product.php
+++ b/htdocs/product/admin/product.php
@@ -159,6 +159,10 @@ else if ($action == 'viewProdTextsInThirdpartyLanguage')
$view = GETPOST('activate_viewProdTextsInThirdpartyLanguage','alpha');
$res = dolibarr_set_const($db, "PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE", $view,'chaine',0,'',$conf->entity);
}
+elseif ($action == 'mergePropalProductCard') {
+ $view = GETPOST('activate_mergePropalProductCard','alpha');
+ $res = dolibarr_set_const($db, "PRODUIT_PDF_MERGE_PROPAL", $view,'chaine',0,'',$conf->entity);
+}
else if ($action == 'usesearchtoselectproduct')
{
$usesearch = GETPOST('activate_usesearchtoselectproduct','alpha');
@@ -428,6 +432,21 @@ print '';
print '';
print '';
+// Activate propal merge produt card
+$var=!$var;
+print '';
+
// View product description in thirdparty language
if (! empty($conf->global->MAIN_MULTILANGS))
{
diff --git a/htdocs/product/class/propalmergepdfproduct.class.php b/htdocs/product/class/propalmergepdfproduct.class.php
new file mode 100644
index 00000000000..b2b7296d311
--- /dev/null
+++ b/htdocs/product/class/propalmergepdfproduct.class.php
@@ -0,0 +1,656 @@
+
+ * Copyright (C) 2015 Florian HENRY
+ *
+ * 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
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/product/class/propalmergepdfproduct.class.php
+ * \ingroup product
+ * \brief This file is an CRUD class file (Create/Read/Update/Delete)
+ */
+
+require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
+
+
+
+/**
+ * Put here description of your class
+ */
+class Propalmergepdfproduct extends CommonObject
+{
+ var $db; //!< To store db handler
+ var $error; //!< To return error code (or message)
+ var $errors=array(); //!< To return several error codes (or messages)
+ var $element='propal_merge_pdf_product'; //!< Id that identify managed objects
+ var $table_element='propal_merge_pdf_product'; //!< Name of table without prefix where object is stored
+
+ var $id;
+
+ var $fk_product;
+ var $file_name;
+ var $fk_user_author;
+ var $fk_user_mod;
+ var $datec='';
+ var $tms='';
+ var $import_key;
+ var $lang;
+
+ var $lines=array();
+
+
+
+
+ /**
+ * Constructor
+ *
+ * @param DoliDb $db Database handler
+ */
+ function __construct($db)
+ {
+ $this->db = $db;
+ return 1;
+ }
+
+
+ /**
+ * Create object into database
+ *
+ * @param User $user User that creates
+ * @param int $notrigger 0=launch triggers after, 1=disable triggers
+ * @return int <0 if KO, Id of created object if OK
+ */
+ function create($user, $notrigger=0)
+ {
+ global $conf, $langs;
+ $error=0;
+
+ // Clean parameters
+
+ if (isset($this->fk_product)) $this->fk_product=trim($this->fk_product);
+ if (isset($this->file_name)) $this->file_name=trim($this->file_name);
+ if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author);
+ if (isset($this->fk_user_mod)) $this->fk_user_mod=trim($this->fk_user_mod);
+ if (isset($this->lang)) $this->lang=trim($this->lang);
+ if (isset($this->import_key)) $this->import_key=trim($this->import_key);
+
+
+
+ // Check parameters
+ // Put here code to add control on parameters values
+
+ // Insert request
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."propal_merge_pdf_product(";
+
+ $sql.= "fk_product,";
+ $sql.= "file_name,";
+ if ($conf->global->MAIN_MULTILANGS) {
+ $sql.= "lang,";
+ }
+ $sql.= "fk_user_author,";
+ $sql.= "fk_user_mod,";
+ $sql.= "datec";
+
+
+ $sql.= ") VALUES (";
+
+ $sql.= " ".(! isset($this->fk_product)?'NULL':"'".$this->fk_product."'").",";
+ $sql.= " ".(! isset($this->file_name)?'NULL':"'".$this->db->escape($this->file_name)."'").",";
+ if ($conf->global->MAIN_MULTILANGS) {
+ $sql.= " ".(! isset($this->lang)?'NULL':"'".$this->db->escape($this->lang)."'").",";
+ }
+ $sql.= " ".$user->id.",";
+ $sql.= " ".$user->id.",";
+ $sql.= " '".$this->db->idate(dol_now())."'";
+
+
+ $sql.= ")";
+
+ $this->db->begin();
+
+ dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+
+ if (! $error)
+ {
+ $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."propal_merge_pdf_product");
+
+ if (! $notrigger)
+ {
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action calls a trigger.
+
+ //// Call triggers
+ //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ //$interface=new Interfaces($this->db);
+ //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
+ //if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ //// End call triggers
+ }
+ }
+
+ // Commit or rollback
+ if ($error)
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->db->commit();
+ return $this->id;
+ }
+ }
+
+
+ /**
+ * Load object in memory from the database
+ *
+ * @param int $id Id object
+ * @return int <0 if KO, >0 if OK
+ */
+ function fetch($id)
+ {
+ global $langs,$conf;
+
+ $sql = "SELECT";
+ $sql.= " t.rowid,";
+
+ $sql.= " t.fk_product,";
+ $sql.= " t.file_name,";
+ $sql.= " t.lang,";
+ $sql.= " t.fk_user_author,";
+ $sql.= " t.fk_user_mod,";
+ $sql.= " t.datec,";
+ $sql.= " t.tms,";
+ $sql.= " t.import_key";
+
+
+ $sql.= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t";
+ $sql.= " WHERE t.rowid = ".$id;
+
+ dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ if ($this->db->num_rows($resql))
+ {
+ $obj = $this->db->fetch_object($resql);
+
+ $this->id = $obj->rowid;
+
+ $this->fk_product = $obj->fk_product;
+ $this->file_name = $obj->file_name;
+ if ($conf->global->MAIN_MULTILANGS) {
+ $this->lang = $obj->lang;
+ }
+ $this->fk_user_author = $obj->fk_user_author;
+ $this->fk_user_mod = $obj->fk_user_mod;
+ $this->datec = $this->db->jdate($obj->datec);
+ $this->tms = $this->db->jdate($obj->tms);
+ $this->import_key = $obj->import_key;
+
+
+ }
+ $this->db->free($resql);
+
+ return 1;
+ }
+ else
+ {
+ $this->error="Error ".$this->db->lasterror();
+ dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
+ return -1;
+ }
+ }
+
+ /**
+ * Load object in memory from the database
+ *
+ * @param int $id Id object
+ * @param string $lang lang string id
+ * @return int <0 if KO, >0 if OK
+ */
+ function fetch_by_product($product_id, $lang='')
+ {
+ global $langs,$conf;
+
+ $sql = "SELECT";
+ $sql.= " t.rowid,";
+
+ $sql.= " t.fk_product,";
+ $sql.= " t.file_name,";
+ $sql.= " t.lang,";
+ $sql.= " t.fk_user_author,";
+ $sql.= " t.fk_user_mod,";
+ $sql.= " t.datec,";
+ $sql.= " t.tms,";
+ $sql.= " t.import_key";
+
+
+ $sql.= " FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product as t";
+ $sql.= " WHERE t.fk_product = ".$product_id;
+ if ($conf->global->MAIN_MULTILANGS && !empty($lang)) {
+ $sql.= " AND t.lang = '".$lang."'";
+ }
+
+ dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
+ $resql=$this->db->query($sql);
+ if ($resql)
+ {
+ if ($this->db->num_rows($resql))
+ {
+ while($obj = $this->db->fetch_object($resql)) {
+
+ $line = new PropalmergepdfproductLine();
+
+ $line->id = $obj->rowid;
+
+ $line->fk_product = $obj->fk_product;
+ $line->file_name = $obj->file_name;
+ if ($conf->global->MAIN_MULTILANGS) {
+ $line->lang = $obj->lang;
+ }
+ $line->fk_user_author = $obj->fk_user_author;
+ $line->fk_user_mod = $obj->fk_user_mod;
+ $line->datec = $this->db->jdate($obj->datec);
+ $line->tms = $this->db->jdate($obj->tms);
+ $line->import_key = $obj->import_key;
+
+
+ if ($conf->global->MAIN_MULTILANGS) {
+ $this->lines[$obj->file_name.'_'.$obj->lang]=$line;
+ }else {
+ $this->lines[$obj->file_name]=$line;
+ }
+
+
+ }
+
+
+ }
+ $this->db->free($resql);
+
+ return 1;
+ }
+ else
+ {
+ $this->error="Error ".$this->db->lasterror();
+ dol_syslog(get_class($this)."::fetch_by_product ".$this->error, LOG_ERR);
+ return -1;
+ }
+ }
+
+
+ /**
+ * Update object into database
+ *
+ * @param User $user User that modifies
+ * @param int $notrigger 0=launch triggers after, 1=disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function update($user=0, $notrigger=0)
+ {
+ global $conf, $langs;
+ $error=0;
+
+ // Clean parameters
+
+ if (isset($this->fk_product)) $this->fk_product=trim($this->fk_product);
+ if (isset($this->file_name)) $this->file_name=trim($this->file_name);
+ if (isset($this->fk_user_mod)) $this->fk_user_mod=trim($this->fk_user_mod);
+ if (isset($this->lang)) $this->lang=trim($this->lang);
+
+
+
+
+ // Check parameters
+ // Put here code to add a control on parameters values
+
+ // Update request
+ $sql = "UPDATE ".MAIN_DB_PREFIX."propal_merge_pdf_product SET";
+
+ $sql.= " fk_product=".(isset($this->fk_product)?$this->fk_product:"null").",";
+ $sql.= " file_name=".(isset($this->file_name)?"'".$this->db->escape($this->file_name)."'":"null").",";
+ if ($conf->global->MAIN_MULTILANGS) {
+ $sql.= " lang=".(isset($this->lang)?"'".$this->db->escape($this->lang)."'":"null").",";
+ }
+ $sql.= " fk_user_mod=".$user->id;
+
+
+ $sql.= " WHERE rowid=".$this->id;
+
+ $this->db->begin();
+
+ dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+
+ if (! $error)
+ {
+ if (! $notrigger)
+ {
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action calls a trigger.
+
+ //// Call triggers
+ //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ //$interface=new Interfaces($this->db);
+ //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
+ //if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ //// End call triggers
+ }
+ }
+
+ // Commit or rollback
+ if ($error)
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->db->commit();
+ return 1;
+ }
+ }
+
+
+ /**
+ * Delete object in database
+ *
+ * @param User $user User that deletes
+ * @param int $notrigger 0=launch triggers after, 1=disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function delete($user, $notrigger=0)
+ {
+ global $conf, $langs;
+ $error=0;
+
+ $this->db->begin();
+
+ if (! $error)
+ {
+ if (! $notrigger)
+ {
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action calls a trigger.
+
+ //// Call triggers
+ //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ //$interface=new Interfaces($this->db);
+ //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
+ //if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ //// End call triggers
+ }
+ }
+
+ if (! $error)
+ {
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product";
+ $sql.= " WHERE rowid=".$this->id;
+
+ dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+ }
+
+ // Commit or rollback
+ if ($error)
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->db->commit();
+ return 1;
+ }
+ }
+
+ /**
+ * Delete object in database
+ *
+ * @param User $user User that deletes
+ * @param int $product_id product_id
+ * @param string $lang_id language
+ * @param int $notrigger 0=launch triggers after, 1=disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ function delete_by_product($user, $product_id, $lang_id='', $notrigger=0)
+ {
+ global $conf, $langs;
+ $error=0;
+
+ $this->db->begin();
+
+ if (! $error)
+ {
+ if (! $notrigger)
+ {
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action calls a trigger.
+
+ //// Call triggers
+ //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ //$interface=new Interfaces($this->db);
+ //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
+ //if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ //// End call triggers
+ }
+ }
+
+ if (! $error)
+ {
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product";
+ $sql.= " WHERE fk_product=".$product_id;
+
+ if ($conf->global->MAIN_MULTILANGS && !empty($lang_id)) {
+ $sql.= " AND lang='".$lang_id."'";
+ }
+
+ dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+ }
+
+ // Commit or rollback
+ if ($error)
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->db->commit();
+ return 1;
+ }
+ }
+
+ /**
+ * Delete object in database
+ *
+ * @param User $user User that deletes
+ * @return int <0 if KO, >0 if OK
+ */
+ function delete_by_file($user)
+ {
+ global $conf, $langs;
+ $error=0;
+
+ $this->db->begin();
+
+ if (! $error)
+ {
+ if (! $notrigger)
+ {
+ // Uncomment this and change MYOBJECT to your own tag if you
+ // want this action calls a trigger.
+
+ //// Call triggers
+ //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ //$interface=new Interfaces($this->db);
+ //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
+ //if ($result < 0) { $error++; $this->errors=$interface->errors; }
+ //// End call triggers
+ }
+ }
+
+ if (! $error)
+ {
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."propal_merge_pdf_product";
+ $sql.= " WHERE fk_product=".$this->fk_product." AND file_name='".$this->db->escape($this->file_name)."'";
+
+ dol_syslog(get_class($this)."::".__METHOD__, LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
+ }
+
+ // Commit or rollback
+ if ($error)
+ {
+ foreach($this->errors as $errmsg)
+ {
+ dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
+ $this->error.=($this->error?', '.$errmsg:$errmsg);
+ }
+ $this->db->rollback();
+ return -1*$error;
+ }
+ else
+ {
+ $this->db->commit();
+ return 1;
+ }
+ }
+
+
+
+ /**
+ * Load an object from its id and create a new one in database
+ *
+ * @param int $fromid Id of object to clone
+ * @return int New id of clone
+ */
+ function createFromClone($fromid)
+ {
+ global $user,$langs;
+
+ $error=0;
+
+ $object=new Propalmergepdfproduct($this->db);
+
+ $this->db->begin();
+
+ // Load source object
+ $object->fetch($fromid);
+ $object->id=0;
+ $object->statut=0;
+
+ // Clear fields
+ // ...
+
+ // Create clone
+ $result=$object->create($user);
+
+ // Other options
+ if ($result < 0)
+ {
+ $this->error=$object->error;
+ $error++;
+ }
+
+ if (! $error)
+ {
+
+
+ }
+
+ // End
+ if (! $error)
+ {
+ $this->db->commit();
+ return $object->id;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
+ }
+ }
+
+
+ /**
+ * Initialise object with example values
+ * Id must be 0 if object instance is a specimen
+ *
+ * @return void
+ */
+ function initAsSpecimen()
+ {
+ $this->id=0;
+
+ $this->fk_product='';
+ $this->file_name='';
+ $this->fk_user_author='';
+ $this->fk_user_mod='';
+ $this->datec='';
+ $this->tms='';
+ $this->import_key='';
+
+
+ }
+
+}
+
+class PropalmergepdfproductLine{
+ var $id;
+
+ var $fk_product;
+ var $file_name;
+ var $lang;
+ var $fk_user_author;
+ var $fk_user_mod;
+ var $datec='';
+ var $tms='';
+ var $import_key;
+
+ function __construct() {
+ return 1;
+ }
+
+}
diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php
index fc3a41a8861..773d08fae72 100644
--- a/htdocs/product/composition/card.php
+++ b/htdocs/product/composition/card.php
@@ -268,7 +268,7 @@ if ($id > 0 || ! empty($ref))
$productstatic->type=$value["fk_product_type"];
$productstatic->ref=$value['label'];
print '';
- print ''.$productstatic->getNomUrl(1,'composition').' ';;
+ print ''.$productstatic->getNomUrl(1,'composition').' ';
print ' ';
}
print '';
diff --git a/htdocs/product/document.php b/htdocs/product/document.php
index 810a131be60..615f4accf70 100644
--- a/htdocs/product/document.php
+++ b/htdocs/product/document.php
@@ -33,6 +33,8 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
+ require_once DOL_DOCUMENT_ROOT.'/product/class/propalmergepdfproduct.class.php';
$langs->load("other");
$langs->load("products");
@@ -84,8 +86,70 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook))
{
+ //Delete line if product propal merge is linked to a file
+ if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) {
+ if ($action == 'confirm_deletefile' && $confirm == 'yes')
+ {
+ print 'toto';
+ //extract file name
+ $urlfile = GETPOST('urlfile', 'alpha');
+ $filename = basename($urlfile);
+ $filetomerge = new Propalmergepdfproduct($db);
+ $filetomerge->fk_product=$object->id;
+ $filetomerge->file_name=$filename;
+ $result=$filetomerge->delete_by_file($user);
+ if ($result<0) {
+ setEventMessage($filetomerge->error,'errors');
+ }
+ }
+ }
+
// Action sending file
include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_pre_headers.tpl.php';
+
+}
+
+if ($action=='filemerge') {
+ $is_refresh = GETPOST('refresh');
+ if (empty($is_refresh)) {
+
+ $filetomerge_file_array = GETPOST('filetoadd');
+
+ $filetomerge_file_array = GETPOST('filetoadd');
+
+ if ($conf->global->MAIN_MULTILANGS) {
+ $lang_id = GETPOST('lang_id');
+ }
+
+ // Delete all file already associated
+ $filetomerge = new Propalmergepdfproduct($db);
+
+ if ($conf->global->MAIN_MULTILANGS) {
+ $result=$filetomerge->delete_by_product($user, $object->id, $lang_id);
+ } else {
+ $result=$filetomerge->delete_by_product($user, $object->id);
+ }
+ if ($result<0) {
+ setEventMessage($filetomerge->error,'errors');
+ }
+
+ // for each file checked add it to the product
+ if (is_array($filetomerge_file_array)) {
+ foreach ( $filetomerge_file_array as $filetomerge_file ) {
+ $filetomerge->fk_product = $object->id;
+ $filetomerge->file_name = $filetomerge_file;
+
+ if ($conf->global->MAIN_MULTILANGS) {
+ $filetomerge->lang = $lang_id;
+ }
+
+ $result=$filetomerge->create($user);
+ if ($result<0) {
+ setEventMessage($filetomerge->error,'errors');
+ }
+ }
+ }
+ }
}
@@ -142,13 +206,139 @@ if ($object->id)
print ''.$langs->trans("NbOfAttachedFiles").' '.count($filearray).' ';
print ''.$langs->trans("TotalSizeOfAttachedFiles").' '.$totalsize.' '.$langs->trans("bytes").' ';
print '';
-
+
print ' ';
$modulepart = 'produit';
$permission = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer));
$param = '&id=' . $object->id;
include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
+
+
+ //Merge propal PDF docuemnt PDF files
+ if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
+ {
+ $filetomerge = new Propalmergepdfproduct($db);
+
+ if ($conf->global->MAIN_MULTILANGS) {
+ $lang_id = GETPOST('lang_id');
+ $result = $filetomerge->fetch_by_product($object->id, $lang_id);
+ } else {
+ $result = $filetomerge->fetch_by_product($object->id);
+ }
+
+ $form = new Form($db);
+
+ $filearray = dol_dir_list($upload_dir, "files", 0, '', '\.meta$', 'name', SORT_ASC, 1);
+
+ // For each file build select list with PDF extention
+ if (count($filearray) > 0) {
+ print '