Merge remote-tracking branch 'origin/3.3' into develop

Conflicts:
	COPYRIGHT
This commit is contained in:
Laurent Destailleur 2012-12-30 18:00:07 +01:00
commit 4fe1ba33f9
13 changed files with 231 additions and 193 deletions

View File

@ -58,6 +58,7 @@ Copyright (C) 2012
- Florian Henry <florian.henry@open-concept.pro>
- Jean-François Ferry <jfefe@aternatik.fr>
- Maxime Kohlhaas <mko@atm-consulting.fr>
- Nicolas Péré <nicolas@amarok2.net>
Copyright (C) 2011
- Laurent Destailleur <eldy@users.sourceforge.net>

View File

@ -101,6 +101,9 @@ For developers:
- New: Add PRODUCT_PRICE_MODIFY trigger.
- New: Created function to retrieve total amount of discount of an invoice/proposal...
- New: We can use a dynamic value ($conf->global->XXX for example) into titles of menus.
- Qual: Renamed SUPPLIER_INVOICE_BUILDDOC trigger to BILL_SUPPLIER_BUILDDOC
- Qual: Renamed INVOICE_SUPPLIER_DELETE trigger to BILL_SUPPLIER_DELETE
- Qual: Renamed SUPLLIER_ORDER_BUILDDOC trigger to ORDER_SUPPLIER_BUILDDOC
For translators:
- New: Update language files (de, tr, pt, ca, es, en, fr).

View File

@ -198,199 +198,209 @@ else if ($action == 'add' && $user->rights->commande->creer)
$datecommande = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
$datelivraison = dol_mktime(12, 0, 0, GETPOST('liv_month'),GETPOST('liv_day'),GETPOST('liv_year'));
$object->socid=$socid;
$object->fetch_thirdparty();
$db->begin();
$object->date_commande = $datecommande;
$object->note = GETPOST('note');
$object->note_public = GETPOST('note_public');
$object->source = GETPOST('source_id');
$object->fk_project = GETPOST('projectid');
$object->ref_client = GETPOST('ref_client');
$object->modelpdf = GETPOST('model');
$object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->availability_id = GETPOST('availability_id');
$object->demand_reason_id = GETPOST('demand_reason_id');
$object->date_livraison = $datelivraison;
$object->fk_delivery_address = GETPOST('fk_address');
$object->contactid = GETPOST('contactidp');
// If creation from another object of another module (Example: origin=propal, originid=1)
if (! empty($origin) && ! empty($originid))
if ($datecommande == '')
{
// Parse element/subelement (ex: project_task)
$element = $subelement = $origin;
if (preg_match('/^([^_]+)_([^_]+)/i',$origin,$regs))
$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Date')).'</div>';
$action='create';
$error++;
}
if (! $error)
{
$object->socid=$socid;
$object->fetch_thirdparty();
$db->begin();
$object->date_commande = $datecommande;
$object->note = GETPOST('note');
$object->note_public = GETPOST('note_public');
$object->source = GETPOST('source_id');
$object->fk_project = GETPOST('projectid');
$object->ref_client = GETPOST('ref_client');
$object->modelpdf = GETPOST('model');
$object->cond_reglement_id = GETPOST('cond_reglement_id');
$object->mode_reglement_id = GETPOST('mode_reglement_id');
$object->availability_id = GETPOST('availability_id');
$object->demand_reason_id = GETPOST('demand_reason_id');
$object->date_livraison = $datelivraison;
$object->fk_delivery_address = GETPOST('fk_address');
$object->contactid = GETPOST('contactidp');
// If creation from another object of another module (Example: origin=propal, originid=1)
if (! empty($origin) && ! empty($originid))
{
$element = $regs[1];
$subelement = $regs[2];
}
// For compatibility
if ($element == 'order') {
$element = $subelement = 'commande';
}
if ($element == 'propal') {
$element = 'comm/propal'; $subelement = 'propal';
}
if ($element == 'contract') {
$element = $subelement = 'contrat';
}
$object->origin = $origin;
$object->origin_id = $originid;
// Possibility to add external linked objects with hooks
$object->linked_objects[$object->origin] = $object->origin_id;
$other_linked_objects=GETPOST('other_linked_objects','array');
if (! empty($other_linked_objects))
{
$object->linked_objects = array_merge($object->linked_objects, $other_linked_objects);
}
$object_id = $object->create($user);
if ($object_id > 0)
{
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
$classname = ucfirst($subelement);
$srcobject = new $classname($db);
dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines");
$result=$srcobject->fetch($object->origin_id);
if ($result > 0)
// Parse element/subelement (ex: project_task)
$element = $subelement = $origin;
if (preg_match('/^([^_]+)_([^_]+)/i',$origin,$regs))
{
$lines = $srcobject->lines;
if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines();
$fk_parent_line=0;
$num=count($lines);
for ($i=0;$i<$num;$i++)
$element = $regs[1];
$subelement = $regs[2];
}
// For compatibility
if ($element == 'order') {
$element = $subelement = 'commande';
}
if ($element == 'propal') {
$element = 'comm/propal'; $subelement = 'propal';
}
if ($element == 'contract') {
$element = $subelement = 'contrat';
}
$object->origin = $origin;
$object->origin_id = $originid;
// Possibility to add external linked objects with hooks
$object->linked_objects[$object->origin] = $object->origin_id;
$other_linked_objects=GETPOST('other_linked_objects','array');
if (! empty($other_linked_objects))
{
$object->linked_objects = array_merge($object->linked_objects, $other_linked_objects);
}
$object_id = $object->create($user);
if ($object_id > 0)
{
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
$classname = ucfirst($subelement);
$srcobject = new $classname($db);
dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines");
$result=$srcobject->fetch($object->origin_id);
if ($result > 0)
{
$label=(! empty($lines[$i]->label)?$lines[$i]->label:'');
$desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle);
$product_type=(! empty($lines[$i]->product_type)?$lines[$i]->product_type:0);
// Dates
// TODO mutualiser
$date_start=$lines[$i]->date_debut_prevue;
if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
$date_end=$lines[$i]->date_fin_prevue;
if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
// Reset fk_parent_line for no child products and special product
if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
$fk_parent_line = 0;
}
$result = $object->addline(
$object_id,
$desc,
$lines[$i]->subprice,
$lines[$i]->qty,
$lines[$i]->tva_tx,
$lines[$i]->localtax1_tx,
$lines[$i]->localtax2_tx,
$lines[$i]->fk_product,
$lines[$i]->remise_percent,
$lines[$i]->info_bits,
$lines[$i]->fk_remise_except,
'HT',
0,
$datestart,
$dateend,
$product_type,
$lines[$i]->rang,
$lines[$i]->special_code,
$fk_parent_line,
$lines[$i]->fk_fournprice,
$lines[$i]->pa_ht,
$label
);
if ($result < 0)
$lines = $srcobject->lines;
if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines();
$fk_parent_line=0;
$num=count($lines);
for ($i=0;$i<$num;$i++)
{
$error++;
break;
}
// Defined the new fk_parent_line
if ($result > 0 && $lines[$i]->product_type == 9) {
$fk_parent_line = $result;
$label=(! empty($lines[$i]->label)?$lines[$i]->label:'');
$desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle);
$product_type=(! empty($lines[$i]->product_type)?$lines[$i]->product_type:0);
// Dates
// TODO mutualiser
$date_start=$lines[$i]->date_debut_prevue;
if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
$date_end=$lines[$i]->date_fin_prevue;
if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
// Reset fk_parent_line for no child products and special product
if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
$fk_parent_line = 0;
}
$result = $object->addline(
$object_id,
$desc,
$lines[$i]->subprice,
$lines[$i]->qty,
$lines[$i]->tva_tx,
$lines[$i]->localtax1_tx,
$lines[$i]->localtax2_tx,
$lines[$i]->fk_product,
$lines[$i]->remise_percent,
$lines[$i]->info_bits,
$lines[$i]->fk_remise_except,
'HT',
0,
$datestart,
$dateend,
$product_type,
$lines[$i]->rang,
$lines[$i]->special_code,
$fk_parent_line,
$lines[$i]->fk_fournprice,
$lines[$i]->pa_ht,
$label
);
if ($result < 0)
{
$error++;
break;
}
// Defined the new fk_parent_line
if ($result > 0 && $lines[$i]->product_type == 9) {
$fk_parent_line = $result;
}
}
// Hooks
$parameters=array('objFrom'=>$srcobject);
$reshook=$hookmanager->executeHooks('createFrom',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) $error++;
}
else
{
$mesg=$srcobject->error;
$error++;
}
// Hooks
$parameters=array('objFrom'=>$srcobject);
$reshook=$hookmanager->executeHooks('createFrom',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
if ($reshook < 0) $error++;
}
else
{
$mesg=$srcobject->error;
$mesg=$object->error;
$error++;
}
}
else
{
$mesg=$object->error;
$error++;
}
}
else
{
$object_id = $object->create($user);
// If some invoice's lines already known
$NBLINES=8;
for ($i = 1 ; $i <= $NBLINES ; $i++)
{
if ($_POST['idprod'.$i])
$object_id = $object->create($user);
// If some invoice's lines already known
$NBLINES=8;
for ($i = 1 ; $i <= $NBLINES ; $i++)
{
$xid = 'idprod'.$i;
$xqty = 'qty'.$i;
$xremise = 'remise_percent'.$i;
$object->add_product($_POST[$xid],$_POST[$xqty],$_POST[$xremise]);
if ($_POST['idprod'.$i])
{
$xid = 'idprod'.$i;
$xqty = 'qty'.$i;
$xremise = 'remise_percent'.$i;
$object->add_product($_POST[$xid],$_POST[$xqty],$_POST[$xremise]);
}
}
}
}
// Insert default contacts if defined
if ($object_id > 0)
{
if (GETPOST('contactidp'))
// Insert default contacts if defined
if ($object_id > 0)
{
$result=$object->add_contact(GETPOST('contactidp'),'CUSTOMER','external');
if ($result < 0)
if (GETPOST('contactidp'))
{
$mesg = '<div class="error">'.$langs->trans("ErrorFailedToAddContact").'</div>';
$error++;
$result=$object->add_contact(GETPOST('contactidp'),'CUSTOMER','external');
if ($result < 0)
{
$mesg = '<div class="error">'.$langs->trans("ErrorFailedToAddContact").'</div>';
$error++;
}
}
$id = $object_id;
$action = '';
}
// End of object creation, we show it
if ($object_id > 0 && ! $error)
{
$db->commit();
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object_id);
exit;
}
else
{
$db->rollback();
$action='create';
if (! $mesg) $mesg='<div class="error">'.$object->error.'</div>';
}
$id = $object_id;
$action = '';
}
// End of object creation, we show it
if ($object_id > 0 && ! $error)
{
$db->commit();
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object_id);
exit;
}
else
{
$db->rollback();
$action='create';
if (! $mesg) $mesg='<div class="error">'.$object->error.'</div>';
}
}

View File

@ -227,7 +227,7 @@ function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails=0, $
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($db);
$result=$interface->run_triggers('FICHEINTER_BUILDDOC',$object,$user,$langs,$conf);
$result=$interface->run_triggers('FICHINTER_BUILDDOC',$object,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -247,4 +247,4 @@ function fichinter_create($db, $object, $modele, $outputlangs, $hidedetails=0, $
}
}
?>
?>

View File

@ -311,7 +311,7 @@ class InterfaceActionsAuto
$object->sendtoid=0;
$ok=1;
}
elseif ($action == 'FICHEINTER_VALIDATE')
elseif ($action == 'FICHINTER_VALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other");
@ -328,7 +328,7 @@ class InterfaceActionsAuto
$object->elementtype='';
$ok=1;
}
elseif ($action == 'FICHEINTER_SENTBYMAIL')
elseif ($action == 'FICHINTER_SENTBYMAIL')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
$langs->load("other");

View File

@ -29,8 +29,14 @@
class InterfaceNotification
{
var $db;
var $listofmanagedevents=array('BILL_VALIDATE','ORDER_VALIDATE','PROPAL_VALIDATE',
'FICHEINTER_VALIDATE','ORDER_SUPPLIER_APPROVE','ORDER_SUPPLIER_REFUSE');
var $listofmanagedevents=array(
'BILL_VALIDATE',
'ORDER_VALIDATE',
'PROPAL_VALIDATE',
'FICHINTER_VALIDATE',
'ORDER_SUPPLIER_APPROVE',
'ORDER_SUPPLIER_REFUSE'
);
/**
* Constructor
@ -146,7 +152,7 @@ class InterfaceNotification
$notify->send($action, $object->socid, $mesg, 'propal', $object->id, $filepdf);
}
elseif ($action == 'FICHEINTER_VALIDATE')
elseif ($action == 'FICHINTER_VALIDATE')
{
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);

View File

@ -164,18 +164,27 @@ class Fichinter extends CommonObject
if (! $ret) dol_print_error($this->db);
}
$this->db->commit();
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('FICHEINTER_CREATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('FICHINTER_CREATE',$this,$user,$langs,$conf);
if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
// Fin appel triggers
return $this->id;
if (! $error)
{
$this->db->commit();
return $this->id;
}
else
{
$this->db->rollback();
$this->error=join(',',$this->errors);
dol_syslog(get_class($this)."::create ".$this->error,LOG_ERR);
return -1;
}
}
else
{
@ -213,7 +222,7 @@ class Fichinter extends CommonObject
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('FICHEINTER_MODIFY',$this,$user,$langs,$conf);
$result=$interface->run_triggers('FICHINTER_MODIFY',$this,$user,$langs,$conf);
if ($result < 0) {
$error++; $this->errors=$interface->errors;
}
@ -357,14 +366,14 @@ class Fichinter extends CommonObject
$sql.= " AND entity = ".$conf->entity;
$sql.= " AND fk_statut = 0";
dol_syslog("Fichinter::setValid sql=".$sql);
dol_syslog(get_class($this)."::setValid sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('FICHEINTER_VALIDATE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('FICHINTER_VALIDATE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -377,7 +386,7 @@ class Fichinter extends CommonObject
{
$this->db->rollback();
$this->error=join(',',$this->errors);
dol_syslog("Fichinter::setValid ".$this->error,LOG_ERR);
dol_syslog(get_class($this)."::setValid ".$this->error,LOG_ERR);
return -1;
}
}
@ -385,7 +394,7 @@ class Fichinter extends CommonObject
{
$this->db->rollback();
$this->error=$this->db->lasterror();
dol_syslog("Fichinter::setValid ".$this->error,LOG_ERR);
dol_syslog(get_class($this)."::setValid ".$this->error,LOG_ERR);
return -1;
}
}
@ -675,7 +684,7 @@ class Fichinter extends CommonObject
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($this->db);
$result=$interface->run_triggers('FICHEINTER_DELETE',$this,$user,$langs,$conf);
$result=$interface->run_triggers('FICHINTER_DELETE',$this,$user,$langs,$conf);
if ($result < 0) {
$error++; $this->errors=$interface->errors;
}

View File

@ -719,7 +719,7 @@ if ($action == 'send' && ! GETPOST('cancel','alpha') && (empty($conf->global->MA
// Appel des triggers
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
$interface=new Interfaces($db);
$result=$interface->run_triggers('FICHEINTER_SENTBYMAIL',$object,$user,$langs,$conf);
$result=$interface->run_triggers('FICHINTER_SENTBYMAIL',$object,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
@ -1387,7 +1387,7 @@ else if ($id > 0 || ! empty($ref))
else print '<a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("CreateBill").'</a>';
}
if (! empty($conf->global->FICHEINTER_CLASSIFY_BILLED))
if (! empty($conf->global->FICHINTER_CLASSIFY_BILLED))
{
if ($object->statut != 2)
{

View File

@ -181,4 +181,4 @@ if ($id > 0 || ! empty($ref))
llxFooter();
$db->close();
?>
?>

View File

@ -175,4 +175,4 @@ if ($id > 0 || ! empty($ref))
llxFooter();
$db->close();
?>
?>

View File

@ -230,6 +230,13 @@ elseif ($action == 'add' && $user->rights->fournisseur->facture->creer)
$datefacture=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']);
$datedue=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']);
if (GETPOST('socid','int')<1)
{
$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('Supplier')).'</div>';
$action='create';
$error++;
}
if ($datefacture == '')
{
$mesg='<div class="error">'.$langs->trans('ErrorFieldRequired',$langs->transnoentities('DateInvoice')).'</div>';

View File

@ -30,7 +30,7 @@
-- List of all managed triggered events (used for trigger agenda and for notification)
--
delete from llx_c_action_trigger;
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (1,'FICHEINTER_VALIDATE','Intervention validated','Executed when a intervention is validated','ficheinter',18);
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (1,'FICHINTER_VALIDATE','Intervention validated','Executed when a intervention is validated','ficheinter',18);
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (2,'BILL_VALIDATE','Customer invoice validated','Executed when a customer invoice is approved','facture',6);
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (3,'ORDER_SUPPLIER_APPROVE','Supplier order request approved','Executed when a supplier order is approved','order_supplier',11);
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (4,'ORDER_SUPPLIER_REFUSE','Supplier order request refused','Executed when a supplier order is refused','order_supplier',12);

View File

@ -905,3 +905,5 @@ ALTER TABLE llx_element_lock ADD COLUMN sessionid varchar(255) AFTER datem;
ALTER TABLE llx_element_lock MODIFY COLUMN elementtype varchar(32) NOT NULL;
ALTER TABLE llx_element_lock DROP COLUMN fk_user_modif;
ALTER TABLE llx_element_lock DROP COLUMN status;
DELETE FROM llx_c_action_trigger WHERE elementtype='withdraw';