";
- }
- }
-
- // third party
- foreach ( $tabtp[$key] as $k => $mt ) {
- if ($k != 'type') {
- print "
";
-
- print "
" . $date . "
";
- print "
" . $val["soclib"] . "
";
-
- print "
" . length_accounta($k) . "
";
- print '
' . ($mt < 0 ? price(- $mt) : '') . "
";
- print '
' . ($mt >= 0 ? price($mt) : '') . "
";
- }
- }
-
- $var = ! $var;
- }
-
- print "
";
-
- // End of page
- llxFooter();
-}
-$db->close();
\ No newline at end of file
diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php
index d8a1a85debf..94f12a61f8b 100644
--- a/htdocs/adherents/card.php
+++ b/htdocs/adherents/card.php
@@ -302,6 +302,7 @@ if (empty($reshook))
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
+ if ($ret < 0) $error++;
// Check if we need to also synchronize user information
$nosyncuser=0;
@@ -471,6 +472,7 @@ if (empty($reshook))
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
+ if ($ret < 0) $error++;
// Check parameters
if (empty($morphy) || $morphy == "-1") {
diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php
index 96e13561825..ea39a200c97 100644
--- a/htdocs/adherents/type.php
+++ b/htdocs/adherents/type.php
@@ -89,6 +89,7 @@ if ($action == 'add' && $user->rights->adherent->configurer)
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$adht);
+ if ($ret < 0) $error++;
if ($adht->libelle)
{
@@ -126,6 +127,7 @@ if ($action == 'update' && $user->rights->adherent->configurer)
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$adht);
+ if ($ret < 0) $error++;
$adht->update($user);
diff --git a/htdocs/admin/notification.php b/htdocs/admin/notification.php
index 14aeba65c29..695174f3303 100644
--- a/htdocs/admin/notification.php
+++ b/htdocs/admin/notification.php
@@ -33,6 +33,7 @@ $langs->load("orders");
$langs->load("propal");
$langs->load("bills");
$langs->load("errors");
+$langs->load("mails");
// Security check
if (!$user->admin)
@@ -76,7 +77,9 @@ if ($action == 'setvalue' && $user->admin)
* View
*/
-llxHeader();
+$form=new Form($db);
+
+llxHeader('',$langs->trans("NotificationSetup"));
$linkback=''.$langs->trans("BackToModuleList").'';
print_fiche_titre($langs->trans("NotificationSetup"),$linkback,'setup');
@@ -132,9 +135,19 @@ foreach($listofnotifiedevents as $notifiedevent)
print '
';
- if (! empty($conf->global->$param) && ! isValidEmail($conf->global->$param)) print ' '.img_warning($langs->trans("ErrorBadEMail"));
+ $value=GETPOST($param)?GETPOST($param,'alpha'):$conf->global->$param;
+ $s=''; // Do not use type="email" here, we must be able to enter a list of email with , separator.
+ $arrayemail=explode(',',$value);
+ $showwarning=0;
+ foreach($arrayemail as $key=>$valuedet)
+ {
+ $valuedet=trim($valuedet);
+ if (! empty($valuedet) && ! isValidEmail($valuedet)) $showwarning++;
+ }
+ if ((! empty($conf->global->$param)) && $showwarning) $s.=' '.img_warning($langs->trans("ErrorBadEMail"));
+ print $form->textwithpicto($s,$langs->trans("YouCanUseCommaSeparatorForSeveralRecipients"));
print '
';
print '';
}
diff --git a/htdocs/admin/supplierinvoice_extrafields.php b/htdocs/admin/supplierinvoice_extrafields.php
index 79dc0637b46..755a68b338e 100644
--- a/htdocs/admin/supplierinvoice_extrafields.php
+++ b/htdocs/admin/supplierinvoice_extrafields.php
@@ -31,6 +31,7 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
+$langs->load("orders");
if (!$user->admin)
accessforbidden();
diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php
index 672c92b9508..8a587d7de32 100644
--- a/htdocs/categories/card.php
+++ b/htdocs/categories/card.php
@@ -127,6 +127,7 @@ if ($action == 'add' && $user->rights->categorie->creer)
if ($parent != "-1") $object->fk_parent = $parent;
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
+ if ($ret < 0) $error++;
if (! $object->label)
{
diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php
index aa82fdb455d..a105d104036 100644
--- a/htdocs/categories/edit.php
+++ b/htdocs/categories/edit.php
@@ -90,7 +90,8 @@ if ($action == 'update' && $user->rights->categorie->creer)
if (empty($categorie->error))
{
$ret = $extrafields->setOptionalsFromPost($extralabels,$categorie);
-
+ if ($ret < 0) $error++;
+
if ($categorie->update($user) > 0)
{
header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$categorie->id.'&type='.$type);
diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php
index 0a4b255884a..c15b1fe4f32 100644
--- a/htdocs/comm/action/card.php
+++ b/htdocs/comm/action/card.php
@@ -274,6 +274,7 @@ if ($action == 'add')
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
+ if ($ret < 0) $error++;
if (! $error)
{
@@ -429,6 +430,7 @@ if ($action == 'update')
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
+ if ($ret < 0) $error++;
if (! $error)
{
diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php
index c879f50b346..9a9417a4dac 100644
--- a/htdocs/comm/action/class/actioncomm.class.php
+++ b/htdocs/comm/action/class/actioncomm.class.php
@@ -184,12 +184,12 @@ class ActionComm extends CommonObject
$now=dol_now();
// Check parameters
- if (empty($this->userownerid))
+ if (empty($this->userownerid))
{
$this->errors[]='ErrorPropertyUserowneridNotDefined';
return -1;
}
-
+
// Clean parameters
$this->label=dol_trunc(trim($this->label),128);
$this->location=dol_trunc(trim($this->location),128);
@@ -214,7 +214,7 @@ class ActionComm extends CommonObject
$userdoneid=$this->userdoneid;
// Be sure assigned user is defined as an array of array('id'=>,'mandatory'=>,...).
- if (empty($this->userassigned) || count($this->userassigned) == 0 || ! is_array($this->userassigned))
+ if (empty($this->userassigned) || count($this->userassigned) == 0 || ! is_array($this->userassigned))
$this->userassigned = array($userownerid=>array('id'=>$userownerid));
if (! $this->type_id || ! $this->type_code)
@@ -306,9 +306,9 @@ class ActionComm extends CommonObject
{
$val=array('id'=>$val);
}
-
+
$sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
- $sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".($val['mandatory']?$val['mandatory']:'0').", ".($val['transparency']?$val['transparency']:'0').", ".($val['answer_status']?$val['answer_status']:'0').")";
+ $sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['mandatory'])?'0':$val['mandatory']).", ".(empty($val['transparency'])?'0':$val['transparency']).", ".(empty($val['answer_status'])?'0':$val['answer_status']).")";
$resql = $this->db->query($sql);
if (! $resql)
@@ -672,7 +672,7 @@ class ActionComm extends CommonObject
foreach($this->userassigned as $key => $val)
{
$sql ="INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources(fk_actioncomm, element_type, fk_element, mandatory, transparency, answer_status)";
- $sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".($val['manadatory']?$val['manadatory']:'0').", ".($val['transparency']?$val['transparency']:'0').", ".($val['answer_status']?$val['answer_status']:'0').")";
+ $sql.=" VALUES(".$this->id.", 'user', ".$val['id'].", ".(empty($val['manadatory'])?'0':$val['manadatory']).", ".(empty($val['transparency'])?'0':$val['transparency']).", ".(empty($val['answer_status'])?'0':$val['answer_status']).")";
$resql = $this->db->query($sql);
if (! $resql)
diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php
index 2f8f7f18e4e..69a3520d1e8 100644
--- a/htdocs/comm/mailing/class/mailing.class.php
+++ b/htdocs/comm/mailing/class/mailing.class.php
@@ -57,7 +57,7 @@ class Mailing extends CommonObject
var $date_creat;
var $date_valid;
-
+
var $extraparams=array();
public $statut_dest=array();
@@ -78,12 +78,12 @@ class Mailing extends CommonObject
$this->statuts[1] = 'MailingStatusValidated';
$this->statuts[2] = 'MailingStatusSentPartialy';
$this->statuts[3] = 'MailingStatusSentCompletely';
-
+
$this->statut_dest[-1] = 'MailingStatusError';
$this->statut_dest[1] = 'MailingStatusSent';
$this->statut_dest[2] = 'MailingStatusRead';
$this->statut_dest[3] = 'MailingStatusNotContact';
-
+
}
/**
@@ -186,7 +186,7 @@ class Mailing extends CommonObject
function fetch($rowid)
{
global $conf;
-
+
$sql = "SELECT m.rowid, m.titre, m.sujet, m.body, m.bgcolor, m.bgimage";
$sql.= ", m.email_from, m.email_replyto, m.email_errorsto";
$sql.= ", m.statut, m.nbemail";
@@ -211,14 +211,14 @@ class Mailing extends CommonObject
$this->statut = $obj->statut;
$this->nbemail = $obj->nbemail;
$this->titre = $obj->titre;
-
- $this->sujet = $obj->sujet;
+
+ $this->sujet = $obj->sujet;
if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML401))) {
$this->body = dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML401);
}else {
$this->body = $obj->body;
}
-
+
$this->bgcolor = $obj->bgcolor;
$this->bgimage = $obj->bgimage;
@@ -232,7 +232,7 @@ class Mailing extends CommonObject
$this->date_creat = $this->db->jdate($obj->date_creat);
$this->date_valid = $this->db->jdate($obj->date_valid);
$this->date_envoi = $this->db->jdate($obj->date_envoi);
-
+
$this->extraparams = (array) json_decode($obj->extraparams, true);
return 1;
@@ -267,6 +267,8 @@ class Mailing extends CommonObject
$object=new Mailing($this->db);
+ $object->context['createfromclone']='createfromclone';
+
$this->db->begin();
// Load source object
@@ -313,13 +315,13 @@ class Mailing extends CommonObject
{
//Clone target
if (!empty($option2)) {
-
+
require_once DOL_DOCUMENT_ROOT .'/core/modules/mailings/modules_mailings.php';
-
+
$mailing_target = new MailingTargets($this->db);
-
+
$target_array=array();
-
+
$sql = "SELECT fk_contact, ";
$sql.=" lastname, ";
$sql.=" firstname,";
@@ -330,7 +332,7 @@ class Mailing extends CommonObject
$sql.=" source_type ";
$sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles ";
$sql.= " WHERE fk_mailing = ".$fromid;
-
+
dol_syslog(get_class($this)."::createFromClone", LOG_DEBUG);
$result=$this->db->query($sql);
if ($result)
@@ -338,17 +340,17 @@ class Mailing extends CommonObject
if ($this->db->num_rows($result))
{
while ($obj = $this->db->fetch_object($result)) {
-
+
$target_array[]=array('fk_contact'=>$obj->fk_contact,
'lastname'=>$obj->lastname,
'firstname'=>$obj->firstname,
- 'email'=>$obj->email,
+ 'email'=>$obj->email,
'other'=>$obj->other,
'source_url'=>$obj->source_url,
'source_id'=>$obj->source_id,
'source_type'=>$obj->source_type);
}
-
+
}
}
else
@@ -356,12 +358,14 @@ class Mailing extends CommonObject
$this->error=$this->db->lasterror();
return -1;
}
-
+
$mailing_target->add_to_target($object->id, $target_array);
}
}
+ unset($object->context['createfromclone']);
+
// End
if (! $error)
{
@@ -514,7 +518,7 @@ class Mailing extends CommonObject
}
}
-
+
/**
* Renvoi le libelle d'un statut donne
*
@@ -526,7 +530,7 @@ class Mailing extends CommonObject
{
global $langs;
$langs->load('mails');
-
+
if ($mode == 0)
{
return $langs->trans($this->statut_dest[$statut]);
@@ -563,10 +567,10 @@ class Mailing extends CommonObject
if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"),'statut6');
if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"),'statut8');
}
-
-
-
-
+
+
+
+
}
}
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 030aff46434..3739b59c338 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -1080,10 +1080,10 @@ if (empty($reshook))
// Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
- if ($ret < 0)
- $error ++;
+ if ($ret < 0) $error++;
- if (! $error) {
+ if (! $error)
+ {
// Actions on extra fields (by external module or standard code)
// FIXME le hook fait double emploi avec le trigger !!
$hookmanager->initHooks(array('propaldao'));
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index ca4c51c3f4c..b18ff15331f 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -239,27 +239,30 @@ class Propal extends CommonObject
return -5;
}
- $propalligne=new PropaleLigne($this->db);
- $propalligne->fk_propal=$this->id;
- $propalligne->fk_remise_except=$remise->id;
- $propalligne->desc=$remise->description; // Description ligne
- $propalligne->tva_tx=$remise->tva_tx;
- $propalligne->subprice=-$remise->amount_ht;
- $propalligne->fk_product=0; // Id produit predefini
- $propalligne->qty=1;
- $propalligne->remise=0;
- $propalligne->remise_percent=0;
- $propalligne->rang=-1;
- $propalligne->info_bits=2;
+ $line=new PropaleLigne($this->db);
+
+ $this->line->context = $this->context;
+
+ $line->fk_propal=$this->id;
+ $line->fk_remise_except=$remise->id;
+ $line->desc=$remise->description; // Description ligne
+ $line->tva_tx=$remise->tva_tx;
+ $line->subprice=-$remise->amount_ht;
+ $line->fk_product=0; // Id produit predefini
+ $line->qty=1;
+ $line->remise=0;
+ $line->remise_percent=0;
+ $line->rang=-1;
+ $line->info_bits=2;
// TODO deprecated
- $propalligne->price=-$remise->amount_ht;
+ $line->price=-$remise->amount_ht;
- $propalligne->total_ht = -$remise->amount_ht;
- $propalligne->total_tva = -$remise->amount_tva;
- $propalligne->total_ttc = -$remise->amount_ttc;
+ $line->total_ht = -$remise->amount_ht;
+ $line->total_tva = -$remise->amount_tva;
+ $line->total_ttc = -$remise->amount_ttc;
- $result=$propalligne->insert();
+ $result=$line->insert();
if ($result > 0)
{
$result=$this->update_price(1);
@@ -276,7 +279,7 @@ class Propal extends CommonObject
}
else
{
- $this->error=$propalligne->error;
+ $this->error=$line->error;
$this->db->rollback();
return -2;
}
@@ -393,6 +396,8 @@ class Propal extends CommonObject
// Insert line
$this->line=new PropaleLigne($this->db);
+ $this->line->context = $this->context;
+
$this->line->fk_propal=$this->id;
$this->line->label=$label;
$this->line->desc=$desc;
@@ -545,6 +550,8 @@ class Propal extends CommonObject
// Update line
$this->line=new PropaleLigne($this->db);
+ $this->line->context = $this->context;
+
// Stock previous line records
$staticline=new PropaleLigne($this->db);
$staticline->fetch($rowid);
@@ -953,6 +960,8 @@ class Propal extends CommonObject
{
global $user,$langs,$conf,$hookmanager;
+ $this->context['createfromclone']='createfromclone';
+
$error=0;
$now=dol_now();
@@ -1046,6 +1055,8 @@ class Propal extends CommonObject
// End call triggers
}
+ unset($this->context['createfromclone']);
+
// End
if (! $error)
{
@@ -3088,6 +3099,7 @@ class PropaleLigne extends CommonObject
if (empty($this->special_code)) $this->special_code=0;
if (empty($this->fk_parent_line)) $this->fk_parent_line=0;
if (empty($this->fk_fournprice)) $this->fk_fournprice=0;
+ if (empty($this->subprice)) $this->subprice=0;
if (empty($this->pa_ht)) $this->pa_ht=0;
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 5b76dd59323..eb5767b173a 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -271,8 +271,7 @@ if (empty($reshook))
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
- if ($ret < 0)
- $error ++;
+ if ($ret < 0) $error++;
if (! $error)
{
@@ -365,10 +364,10 @@ if (empty($reshook))
} else {
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
- if ($ret < 0)
- $error ++;
+ if ($ret < 0) $error++;
- if (! $error) {
+ if (! $error)
+ {
$object_id = $object->create($user);
// If some invoice's lines already known
@@ -1124,8 +1123,7 @@ if (empty($reshook))
// Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
- if ($ret < 0)
- $error ++;
+ if ($ret < 0) $error++;
if (! $error) {
// Actions on extra fields (by external module or standard code)
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 35834419a74..1cdd57b1b6a 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -878,6 +878,8 @@ class Commande extends CommonOrder
$error=0;
+ $this->context['createfromclone'] = 'createfromclone';
+
$this->db->begin();
// get extrafields so they will be clone
@@ -942,6 +944,8 @@ class Commande extends CommonOrder
// End call triggers
}
+ unset($this->context['createfromclone']);
+
// End
if (! $error)
{
@@ -1201,6 +1205,8 @@ class Commande extends CommonOrder
// Insert line
$this->line=new OrderLine($this->db);
+ $this->line->context = $this->context;
+
$this->line->fk_commande=$this->id;
$this->line->label=$label;
$this->line->desc=$desc;
@@ -1315,6 +1321,8 @@ class Commande extends CommonOrder
$line=new OrderLine($this->db);
+ $line->context = $this->context;
+
$line->fk_product=$idproduct;
$line->desc=$prod->description;
$line->qty=$qty;
@@ -2397,6 +2405,8 @@ class Commande extends CommonOrder
// Update line
$this->line=new OrderLine($this->db);
+ $this->line->context = $this->context;
+
// Stock previous line records
$staticline=new OrderLine($this->db);
$staticline->fetch($rowid);
diff --git a/htdocs/compta/bank/class/bankcateg.class.php b/htdocs/compta/bank/class/bankcateg.class.php
index fb796b219ee..5004d13caf1 100644
--- a/htdocs/compta/bank/class/bankcateg.class.php
+++ b/htdocs/compta/bank/class/bankcateg.class.php
@@ -300,7 +300,9 @@ class BankCateg // extends CommonObject
$object=new BankCateg($this->db);
- $this->db->begin();
+ $object->context['createfromclone'] = 'createfromclone';
+
+ $this->db->begin();
// Load source object
$object->fetch($fromid);
@@ -327,6 +329,8 @@ class BankCateg // extends CommonObject
}
+ unset($object->context['createfromclone']);
+
// End
if (! $error)
{
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 5f1f3998b5d..3d7a71f8133 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -585,7 +585,7 @@ if (empty($reshook))
$discount->fk_facture_source = $object->id;
$error = 0;
-
+
foreach ($amount_ht as $tva_tx => $xxx) {
$discount->amount_ht = abs($amount_ht [$tva_tx]);
$discount->amount_tva = abs($amount_tva [$tva_tx]);
@@ -636,7 +636,7 @@ if (empty($reshook))
// Fill array 'array_options' with data from add form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
- if ($ret < 0) $error ++;
+ if ($ret < 0) $error++;
// Replacement invoice
if ($_POST['type'] == Facture::TYPE_REPLACEMENT)
@@ -1676,8 +1676,7 @@ if (empty($reshook))
// Fill array 'array_options' with data from add form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
- if ($ret < 0)
- $error ++;
+ if ($ret < 0) $error++;
if (! $error) {
// Actions on extra fields (by external module or standard code)
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index d50079f78c8..ec41b0a99c2 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -607,6 +607,8 @@ class Facture extends CommonInvoice
$error=0;
+ $this->context['createfromclone'] = 'createfromclone';
+
$this->db->begin();
// get extrafields so they will be clone
@@ -693,6 +695,8 @@ class Facture extends CommonInvoice
// End call triggers
}
+ unset($this->context['createfromclone']);
+
// End
if (! $error)
{
@@ -2043,6 +2047,9 @@ class Facture extends CommonInvoice
// Insert line
$this->line=new FactureLigne($this->db);
+
+ $this->line->context = $this->context;
+
$this->line->fk_facture=$this->id;
$this->line->label=$label; // deprecated
$this->line->desc=$desc;
@@ -2181,7 +2188,9 @@ class Facture extends CommonInvoice
// Update line into database
$this->line=new FactureLigne($this->db);
- // Stock previous line records
+ $this->line->context = $this->context;
+
+ // Stock previous line records
$staticline=new FactureLigne($this->db);
$staticline->fetch($rowid);
$this->line->oldline = $staticline;
@@ -2294,6 +2303,8 @@ class Facture extends CommonInvoice
$line=new FactureLigne($this->db);
+ $line->context = $this->context;
+
// For triggers
$line->fetch($rowid);
diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php
index b75bb056e03..d524c501698 100644
--- a/htdocs/compta/facture/class/paymentterm.class.php
+++ b/htdocs/compta/facture/class/paymentterm.class.php
@@ -33,6 +33,7 @@ class PaymentTerm // extends CommonObject
var $errors=array(); //!< To return several error codes (or messages)
//public $element='c_payment_term'; //!< Id that identify managed objects
//public $table_element='c_payment_term'; //!< Name of table without prefix where object is stored
+ var $context =array();
var $id;
@@ -409,6 +410,8 @@ class PaymentTerm // extends CommonObject
$object=new PaymentTerm($this->db);
+ $object->context['createfromclone'] = 'createfromclone';
+
$this->db->begin();
// Load source object
@@ -436,6 +439,8 @@ class PaymentTerm // extends CommonObject
}
+ unset($this->context['createfromclone']);
+
// End
if (! $error)
{
diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php
index 395932de69f..10f856cf858 100644
--- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php
+++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php
@@ -384,6 +384,8 @@ class PaymentSocialContribution extends CommonObject
$object=new PaymentSocialContribution($this->db);
+ $object->context['createfromclone'] = 'createfromclone';
+
$this->db->begin();
// Load source object
@@ -411,6 +413,8 @@ class PaymentSocialContribution extends CommonObject
}
+ unset($this->context['createfromclone']);
+
// End
if (! $error)
{
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index af07cbb9a62..248352dfee3 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -200,6 +200,7 @@ if (empty($reshook))
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
+ if ($ret < 0) $error++;
if (! GETPOST("lastname"))
{
@@ -303,6 +304,7 @@ if (empty($reshook))
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
+ if ($ret < 0) $error++;
$result = $object->update($contactid, $user);
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index fdd0acfec74..6d10442caf7 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -355,6 +355,7 @@ if ($action == 'add' && $user->rights->contrat->creer)
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels, $object);
+ if ($ret < 0) $error++;
$result = $object->create($user);
if ($result > 0)
@@ -702,19 +703,20 @@ else if ($action == 'confirm_move' && $confirm == 'yes' && $user->rights->contra
// Fill array 'array_options' with data from update form
$extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
$ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute'));
- if ($ret < 0)
- $error ++;
+ if ($ret < 0) $error++;
- if (! $error) {
+ if (! $error)
+ {
+ $result = $object->insertExtraFields();
+ if ($result < 0)
+ {
+ $error++;
+ }
+ }
+ else if ($reshook < 0) $error++;
- $result = $object->insertExtraFields();
- if ($result < 0) {
- $error ++;
- }
- } else if ($reshook < 0)
- $error ++;
-
- if ($error) {
+ if ($error)
+ {
$action = 'edit_extras';
setEventMessage($object->error,'errors');
}
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 8a8258ca641..46d280f8763 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -38,6 +38,7 @@ abstract class CommonObject
public $error;
public $errors;
public $canvas; // Contains canvas name if it is
+ public $context=array(); // Use to pass context information
public $name;
public $lastname;
@@ -3456,7 +3457,8 @@ abstract class CommonObject
/**
* Add/Update all extra fields values for the current object.
- * All data to describe values to insert are stored into $this->array_options=array('keyextrafield'=>'valueextrafieldtoadd')
+ * Data to describe values to insert/update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...)
+ * This function delte record with all extrafields and insert them again from the array $this->array_options.
*
* @return int -1=error, O=did nothing, 1=OK
*/
diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php
index 027dda53dd3..c7894c7c848 100644
--- a/htdocs/core/class/ctypent.class.php
+++ b/htdocs/core/class/ctypent.class.php
@@ -148,9 +148,10 @@ class Ctypent // extends CommonObject
*
* @param int $id Id object
* @param string $code Code
+ * @param string $label Label
* @return int <0 if KO, >0 if OK
*/
- function fetch($id,$code='')
+ function fetch($id,$code='',$label='')
{
global $langs;
$sql = "SELECT";
@@ -163,8 +164,8 @@ class Ctypent // extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."c_typent as t";
if ($id) $sql.= " WHERE t.id = ".$id;
elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'";
+ elseif ($label) $sql.= " WHERE t.libelle = '".$this->db->escape($label)."'";
- dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index 544619892b5..cc602d08ed5 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -1061,9 +1061,9 @@ class ExtraFields
* Fill array_options property of object by extrafields value (using for data sent by forms)
*
* @param array $extralabels $array of extrafields
- * @param object $object Object
- * @param string $onlykey Only following key is filled
- * @return int 1 if array_options set / 0 if no value
+ * @param object $object Object
+ * @param string $onlykey Only following key is filled. When we make update of only one extrafield ($action = 'update_extras'), calling page must must set this to avoid to have other extrafields being reset.
+ * @return int 1 if array_options set, 0 if no value, -1 if error (field required missing for example)
*/
function setOptionalsFromPost($extralabels,&$object,$onlykey='')
{
diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php
index 14de889d9ce..cd3a35e4060 100644
--- a/htdocs/core/modules/import/import_csv.modules.php
+++ b/htdocs/core/modules/import/import_csv.modules.php
@@ -354,6 +354,7 @@ class ImportCsv extends ModeleImports
}
else
{
+ $last_insert_id_array = array(); // store the last inserted auto_increment id for each table, so that dependent tables can be inserted with the appropriate id (eg: extrafields fk_object will be set with the last inserted object's id)
// For each table to insert, me make a separate insert
foreach($objimport->array_import_tables[0] as $alias => $tablename)
{
@@ -414,21 +415,34 @@ class ImportCsv extends ModeleImports
if (! empty($objimport->array_import_convertvalue[0][$val]))
{
//print 'Must convert '.$newval.' with rule '.join(',',$objimport->array_import_convertvalue[0][$val]).'. ';
- if ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeid' || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromref')
+ if ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeid'
+ || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromref'
+ || $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel'
+ )
{
if (! is_numeric($newval) && $newval != '') // If value into input import file is not a numeric, we apply the function defined into descriptor
{
$file=$objimport->array_import_convertvalue[0][$val]['classfile'];
$class=$objimport->array_import_convertvalue[0][$val]['class'];
$method=$objimport->array_import_convertvalue[0][$val]['method'];
- if (empty($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]))
+ if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval] != '')
{
+ $newval=$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval];
+ }
+ else
+ {
dol_include_once($file);
$classinstance=new $class($this->db);
+ // Try the fetch from code or ref
call_user_func_array(array($classinstance, $method),array('', $newval));
+ // If not found, try the fetch from label
+ if (! ($classinstance->id != '') && $objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeorlabel')
+ {
+ call_user_func_array(array($classinstance, $method),array('', '', $newval));
+ }
$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval]=$classinstance->id;
//print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. ';
- if (! empty($classinstance->id))
+ if ($classinstance->id != '') // id may be 0, it is a found value
{
$newval=$classinstance->id;
}
@@ -442,10 +456,6 @@ class ImportCsv extends ModeleImports
$error++;
}
}
- else
- {
- $newval=$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'][$newval];
- }
}
}
@@ -581,7 +591,7 @@ class ImportCsv extends ModeleImports
elseif (preg_match('/^lastrowid-/',$val))
{
$tmp=explode('-',$val);
- $lastinsertid=$this->db->last_insert_id($tmp[1]);
+ $lastinsertid=(isset($last_insert_id_array[$tmp[1]]))?$last_insert_id_array[$tmp[1]]:0;
$listfields.=preg_replace('/^'.preg_quote($alias).'\./','',$key);
$listvalues.=$lastinsertid;
//print $key."-".$val."-".$listfields."-".$listvalues." ";exit;
@@ -623,6 +633,7 @@ class ImportCsv extends ModeleImports
if ($sql)
{
$resql=$this->db->query($sql);
+ $last_insert_id_array[$tablename] = $this->db->last_insert_id($tablename); // store the last inserted auto_increment id for each table, so that dependent tables can be inserted with the appropriate id. This must be done just after the INSERT request, else we risk losing the id (because another sql query will be issued somewhere in Dolibarr).
if ($resql)
{
//print '.';
diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php
index 63cb9c610b4..3a2bcefe8b2 100644
--- a/htdocs/core/modules/modSociete.class.php
+++ b/htdocs/core/modules/modSociete.class.php
@@ -382,7 +382,7 @@ class modSociete extends DolibarrModules
$this->import_icon[$r]='company';
$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('s'=>MAIN_DB_PREFIX.'societe','extra'=>MAIN_DB_PREFIX.'societe_extrafields'); // List of tables to insert into (insert done in same order)
- $this->import_fields_array[$r]=array('s.nom'=>"Name*",'s.status'=>"Status",'s.client'=>"Customer*",'s.fournisseur'=>"Supplier*",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.code_compta'=>"CustomerAccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode",'s.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town",'s.fk_departement'=>"StateId",'s.fk_pays'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.siren'=>"ProfId1",'s.siret'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic",'s.fk_typent'=>"ThirdPartyType",'s.fk_effectif'=>"Staff","s.fk_forme_juridique"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus','s.default_lang'=>'DefaultLanguage','s.barcode'=>'BarCode','s.datec'=>"DateCreation");
+ $this->import_fields_array[$r]=array('s.nom'=>"Name*",'s.status'=>"Status",'s.client'=>"Customer*",'s.fournisseur'=>"Supplier*",'s.code_client'=>"CustomerCode",'s.code_fournisseur'=>"SupplierCode",'s.code_compta'=>"CustomerAccountancyCode",'s.code_compta_fournisseur'=>"SupplierAccountancyCode",'s.address'=>"Address",'s.zip'=>"Zip",'s.town'=>"Town",'s.fk_departement'=>"StateId",'s.fk_pays'=>"CountryCode",'s.phone'=>"Phone",'s.fax'=>"Fax",'s.url'=>"Url",'s.email'=>"Email",'s.siren'=>"ProfId1",'s.siret'=>"ProfId2",'s.ape'=>"ProfId3",'s.idprof4'=>"ProfId4",'s.idprof5'=>"ProfId5",'s.idprof6'=>"ProfId6",'s.tva_intra'=>"VATIntraShort",'s.capital'=>"Capital",'s.note_private'=>"NotePrivate",'s.note_public'=>"NotePublic",'s.fk_typent'=>"ThirdPartyType",'s.fk_effectif'=>"Staff","s.fk_forme_juridique"=>"JuridicalStatus",'s.fk_prospectlevel'=>'ProspectLevel','s.fk_stcomm'=>'ProspectStatus','s.default_lang'=>'DefaultLanguage','s.barcode'=>'BarCode','s.datec'=>"DateCreation");
// Add extra fields
$sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe' AND entity = ".$conf->entity;
$resql=$this->db->query($sql);
@@ -398,7 +398,7 @@ class modSociete extends DolibarrModules
// End add extra fields
$this->import_fieldshidden_array[$r]=array('s.fk_user_creat'=>'user->id','extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'societe'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
$this->import_convertvalue_array[$r]=array(
- 's.fk_typent'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ctypent.class.php','class'=>'Ctypent','method'=>'fetch','dict'=>'DictionaryCompanyType'),
+ 's.fk_typent'=>array('rule'=>'fetchidfromcodeorlabel','classfile'=>'/core/class/ctypent.class.php','class'=>'Ctypent','method'=>'fetch','dict'=>'DictionaryCompanyType'),
's.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry'),
's.fk_stcomm'=>array('rule'=>'zeroifnull'),
's.code_client'=>array('rule'=>'getcustomercodeifauto'),
@@ -407,8 +407,8 @@ class modSociete extends DolibarrModules
's.code_compta_fournisseur'=>array('rule'=>'getsupplieraccountancycodeifauto')
);
//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
- $this->import_regex_array[$r]=array('s.status'=>'^[0|1]','s.client'=>'^[0|1|2|3]','s.fournisseur'=>'^[0|1]','s.fk_typent'=>'id@'.MAIN_DB_PREFIX.'c_typent','s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
- $this->import_examplevalues_array[$r]=array('s.nom'=>"MyBigCompany",'s.status'=>"0 (closed) or 1 (active)",'s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 or 1','s.datec'=>dol_print_date(dol_now(),'%Y-%m-%d'),'s.code_client'=>"CU01-0001 or empty or 'auto'",'s.code_fournisseur'=>"SU01-0001 or empty or 'auto'",'s.address'=>"61 jump street",'s.zip'=>"123456",'s.town'=>"Big town",'s.fk_pays'=>'US, FR, DE...','s.phone'=>"0101010101",'s.fax'=>"0101010102",'s.url'=>"http://mycompany.com",'s.email'=>"test@mycompany.com",'s.siret'=>"",'s.siren'=>"",'s.ape'=>"",'s.idprof4'=>"",'s.tva_intra'=>"FR0123456789",'s.capital'=>"10000",'s.note_private'=>"This is an example of private note for record",'s.note_public'=>"This is an example of public note for record",'s.fk_typent'=>"2",'s.fk_effectif'=>"3","s.fk_forme_juridique"=>"1",'s.fk_prospectlevel'=>'PL_MEDIUM','s.fk_stcomm'=>'0','s.default_lang'=>'en_US','s.barcode'=>'123456789');
+ $this->import_regex_array[$r]=array('s.status'=>'^[0|1]','s.client'=>'^[0|1|2|3]','s.fournisseur'=>'^[0|1]','s.fk_typent'=>'id@'.MAIN_DB_PREFIX.'c_typent','s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');
+ $this->import_examplevalues_array[$r]=array('s.nom'=>"MyBigCompany",'s.status'=>"0 (closed) or 1 (active)",'s.client'=>'0 (no customer no prospect)/1 (customer)/2 (prospect)/3 (customer and prospect)','s.fournisseur'=>'0 or 1','s.datec'=>dol_print_date(dol_now(),'%Y-%m-%d'),'s.code_client'=>"CU01-0001 or empty or 'auto'",'s.code_fournisseur'=>"SU01-0001 or empty or 'auto'",'s.address'=>"61 jump street",'s.zip'=>"123456",'s.town'=>"Big town",'s.fk_pays'=>'US, FR, DE...','s.phone'=>"0101010101",'s.fax'=>"0101010102",'s.url'=>"http://mycompany.com",'s.email'=>"test@mycompany.com",'s.siret'=>"",'s.siren'=>"",'s.ape'=>"",'s.idprof4'=>"",'s.idprof5'=>"",'s.idprof6'=>"",'s.tva_intra'=>"FR0123456789",'s.capital'=>"10000",'s.note_private'=>"This is an example of private note for record",'s.note_public'=>"This is an example of public note for record",'s.fk_typent'=>"2",'s.fk_effectif'=>"3","s.fk_forme_juridique"=>"1",'s.fk_prospectlevel'=>'PL_MEDIUM','s.fk_stcomm'=>'0','s.default_lang'=>'en_US','s.barcode'=>'123456789','s.datec'=>"2015-01-01 or 2015-01-01 12:30:00");
// Import list of contact and attributes
$r++;
@@ -437,7 +437,7 @@ class modSociete extends DolibarrModules
's.fk_pays'=>array('rule'=>'fetchidfromcodeid','classfile'=>'/core/class/ccountry.class.php','class'=>'Ccountry','method'=>'fetch','dict'=>'DictionaryCountry'),
);
//$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t');
- $this->import_regex_array[$r]=array('s.birthday'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$');
+ $this->import_regex_array[$r]=array('s.birthday'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');
$this->import_examplevalues_array[$r]=array('s.fk_soc'=>'MyBigCompany','s.civility'=>"MR",'s.lastname'=>"Smith",'s.firstname'=>'John','s.address'=>'61 jump street','s.zip'=>'75000','s.town'=>'Bigtown','s.fk_pays'=>'US, FR, DE...','s.datec'=>'1972-10-10','s.poste'=>"Director",'s.phone'=>"5551122",'s.phone_perso'=>"5551133",'s.phone_mobile'=>"5551144",'s.fax'=>"5551155",'s.email'=>"johnsmith@email.com",'s.note_private'=>"My private note",'s.note_public'=>"My public note");
// Import Bank Accounts
diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php
index 723660f1d9c..5f2ef68b194 100644
--- a/htdocs/cron/class/cronjob.class.php
+++ b/htdocs/cron/class/cronjob.class.php
@@ -718,6 +718,8 @@ class Cronjob extends CommonObject
$object=new Cronjob($this->db);
+ $object->context['createfromclone'] = 'createfromclone';
+
$this->db->begin();
// Load source object
@@ -744,6 +746,8 @@ class Cronjob extends CommonObject
}
+ unset($this->context['createfromclone']);
+
// End
if (! $error)
{
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 9051ab0bb27..95c8c1801a7 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -887,7 +887,7 @@ class CommandeFournisseur extends CommonOrder
$sql.= ", entity";
$sql.= ", fk_soc";
$sql.= ", date_creation";
- //$sql.= ", date_livraison";
+ $sql.= ", date_livraison";
$sql.= ", fk_user_author";
$sql.= ", fk_statut";
$sql.= ", source";
@@ -899,12 +899,12 @@ class CommandeFournisseur extends CommonOrder
$sql.= " VALUES (";
$sql.= "''";
$sql.= ", '".$this->ref_supplier."'";
- $sql.= ", '".$this->note_private."'";
- $sql.= ", '".$this->note_public."'";
+ $sql.= ", '".$this->db->escape($this->note_private)."'";
+ $sql.= ", '".$this->db->escape($this->note_public)."'";
$sql.= ", ".$conf->entity;
$sql.= ", ".$this->socid;
$sql.= ", '".$this->db->idate($now)."'";
- //$sql.= ", '".$this->db->idate($now)."'";
+ $sql.= ", ".($this->date_livraison?"'".$this->db->idate($this->date_livraison)."'":"null");
$sql.= ", ".$user->id;
$sql.= ", 0";
$sql.= ", " . $this->source;
@@ -1024,7 +1024,9 @@ class CommandeFournisseur extends CommonOrder
$error=0;
- $this->db->begin();
+ $this->context['createfromclone'] = 'createfromclone';
+
+ $this->db->begin();
// Load source object
$objFrom = dol_clone($this);
@@ -1060,7 +1062,9 @@ class CommandeFournisseur extends CommonOrder
// End call triggers
}
- // End
+ unset($this->context['createfromclone']);
+
+ // End
if (! $error)
{
$this->db->commit();
diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php
index 96e00aba182..7f2697d7c0c 100644
--- a/htdocs/fourn/class/fournisseur.facture.class.php
+++ b/htdocs/fourn/class/fournisseur.facture.class.php
@@ -1699,7 +1699,9 @@ class FactureFournisseur extends CommonInvoice
$object=new FactureFournisseur($this->db);
- $this->db->begin();
+ $object->context['createfromclone'] = 'createfromclone';
+
+ $this->db->begin();
// Load source object
$object->fetch($fromid);
@@ -1745,6 +1747,8 @@ class FactureFournisseur extends CommonInvoice
}
+ unset($object->context['createfromclone']);
+
// End
if (! $error)
{
diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php
index 75ac674e877..3d12352903f 100644
--- a/htdocs/fourn/class/fournisseur.product.class.php
+++ b/htdocs/fourn/class/fournisseur.product.class.php
@@ -447,12 +447,18 @@ class ProductFournisseur extends Product
*
* @param int $prodid Product id
* @param int $qty Minimum quantity
- * @return int <0 if KO, >0 if OK
+ * @return int <0 if KO, 0=Not found of no product id provided, >0 if OK
*/
function find_min_price_product_fournisseur($prodid, $qty=0)
{
global $conf;
+ if (empty($prodid))
+ {
+ dol_syslog("Warning function find_min_price_product_fournisseur were called with prodid empty. May be a bug.", LOG_WARNING);
+ return 0;
+ }
+
$this->product_fourn_price_id = '';
$this->product_fourn_id = '';
$this->fourn_ref = '';
@@ -500,7 +506,7 @@ class ProductFournisseur extends Product
return 1;
}
else
- {
+ {
$this->error=$this->db->error();
return -1;
}
diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php
index ef78a9981c1..0257b51c946 100644
--- a/htdocs/fourn/commande/card.php
+++ b/htdocs/fourn/commande/card.php
@@ -69,6 +69,8 @@ $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (!
$hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
$hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
+$datelivraison=dol_mktime(GETPOST('liv_hour','int'), GETPOST('liv_min','int'), GETPOST('liv_sec','int'), GETPOST('liv_month','int'), GETPOST('liv_day','int'),GETPOST('liv_year','int'));
+
// Security check
if ($user->societe_id) $socid=$user->societe_id;
@@ -144,8 +146,6 @@ if ($action == 'setbankaccount' && $user->rights->fournisseur->commande->creer)
// date de livraison
if ($action == 'setdate_livraison' && $user->rights->fournisseur->commande->creer)
{
- $datelivraison=dol_mktime(GETPOST('liv_hour','int'), GETPOST('liv_min','int'), GETPOST('liv_sec','int'), GETPOST('liv_month','int'), GETPOST('liv_day','int'),GETPOST('liv_year','int'));
-
$result=$object->set_date_livraison($user,$datelivraison);
if ($result < 0)
{
@@ -780,11 +780,10 @@ if ($action == 'update_extras')
{
// Fill array 'array_options' with data from add form
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
- $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
+ $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute'));
+ if ($ret < 0) $error++;
- if($ret < 0) $error++;
-
- if (!$error)
+ if (! $error)
{
// Actions on extra fields (by external module or standard code)
// FIXME le hook fait double emploi avec le trigger !!
@@ -797,7 +796,6 @@ if ($action == 'update_extras')
{
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
-
$result=$object->insertExtraFields();
if ($result < 0)
@@ -841,21 +839,29 @@ if ($action == 'add' && $user->rights->fournisseur->commande->creer)
$object->fk_account = GETPOST('fk_account', 'int');
$object->note_private = GETPOST('note_private');
$object->note_public = GETPOST('note_public');
+ $object->date_livraison = $datelivraison;
// Fill array 'array_options' with data from add form
- $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
+ if (! $error)
+ {
+ $ret = $extrafields->setOptionalsFromPost($extralabels,$object);
+ if ($ret < 0) $error++;
+ }
- $id = $object->create($user);
- if ($id < 0)
- {
- $error++;
- }
+ if (! $error)
+ {
+ $id = $object->create($user);
+ if ($id < 0)
+ {
+ $error++;
+ setEventMessage($langs->trans($object->error), 'errors');
+ }
+ }
if ($error)
{
$langs->load("errors");
$db->rollback();
- setEventMessage($langs->trans($object->error), 'errors');
$action='create';
$_GET['socid']=$_POST['socid'];
}
@@ -1272,6 +1278,16 @@ if ($action=="create")
$form->select_types_paiements(isset($_POST['mode_reglement_id'])?$_POST['mode_reglement_id']:$mode_reglement_id,'mode_reglement_id');
print '';
+ // Planned delivery date
+ print '
';
- if ($objp->minsellprice != '')
+ if ($objp->tobuy && $objp->minsellprice != '')
{
//print price($objp->minsellprice).' '.$langs->trans("HT");
if ($product_fourn->find_min_price_product_fournisseur($objp->rowid) > 0)
diff --git a/htdocs/projet/activity/list.php b/htdocs/projet/activity/list.php
index 692e4ab08b4..af569d3351f 100644
--- a/htdocs/projet/activity/list.php
+++ b/htdocs/projet/activity/list.php
@@ -125,7 +125,8 @@ if ($id)
$project->fetch_thirdparty();
}
-$tasksarray=$taskstatic->getTasksArray(0,0,($project->id?$project->id:$projectsListId),$socid,0); // We want to see all task of project i am allowed to see, not only mine. Later only mine will be editable later.
+$onlyopened=1; // or -1
+$tasksarray=$taskstatic->getTasksArray(0,0,($project->id?$project->id:$projectsListId),$socid,0,'',$onlyopened); // We want to see all task of opened project i am allowed to see, not only mine. Later only mine will be editable later.
$projectsrole=$taskstatic->getUserRolesForProjectsOrTasks($user,0,($project->id?$project->id:$projectsListId),0);
$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0,$user,($project->id?$project->id:$projectsListId),0);
//var_dump($tasksarray);
@@ -138,11 +139,11 @@ llxHeader("",$title,"");
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
// Show description of content
-if ($mine) print $langs->trans("MyTasksDesc").'