diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 51d9ca2bced..16f9aed618f 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -70,7 +70,7 @@ $hookmanager->initHooks(array('admin'));
// Put here declaration of dictionaries properties
// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
-$taborder=array(9,0,4,3,2,0,1,8,19,16,0,5,11,0,6,0,10,25,12,13,0,14,0,7,17,0,22,20,18,21,0,15,0,24,23);
+$taborder=array(9,0,4,3,2,0,1,8,19,16,0,5,11,0,6,0,10,25,12,13,0,14,0,7,17,0,22,20,18,21,0,15,0,24,23,0,26);
// Name of SQL tables of dictionaries
$tabname=array();
@@ -99,6 +99,7 @@ $tabname[22]= MAIN_DB_PREFIX."c_input_reason";
$tabname[23]= MAIN_DB_PREFIX."accountingaccount";
$tabname[24]= MAIN_DB_PREFIX."accounting_system";
$tabname[25]= MAIN_DB_PREFIX."c_revenuestamp";
+$tabname[26]= MAIN_DB_PREFIX."c_type_resource";
// Dictionary labels
$tablib=array();
@@ -127,6 +128,7 @@ $tablib[22]= "DictionarySource";
$tablib[23]= "DictionaryAccountancyplan";
$tablib[24]= "DictionaryAccountancysystem";
$tablib[25]= "DictionaryRevenueStamp";
+$tablib[26]= "DictionaryResourceType";
// Requete pour extraction des donnees des dictionnaires
$tabsql=array();
@@ -155,6 +157,7 @@ $tabsql[22]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX
$tabsql[23]= "SELECT rowid as rowid, fk_pcg_version, pcg_type, pcg_subtype, account_number as accountancy_code, account_parent, label, active FROM ".MAIN_DB_PREFIX."accountingaccount";
$tabsql[24]= "SELECT s.rowid as rowid, pcg_version, s.fk_pays as country_id, p.code as country_code, p.libelle as pays, s.label, s.active FROM ".MAIN_DB_PREFIX."accounting_system as s, ".MAIN_DB_PREFIX."c_pays as p WHERE s.fk_pays=p.rowid and p.active=1";
$tabsql[25]= "SELECT t.rowid, t.taux, p.libelle as country, p.code as country_code, t.fk_pays as country_id, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_revenuestamp as t, ".MAIN_DB_PREFIX."c_pays as p WHERE t.fk_pays=p.rowid";
+$tabsql[26]= "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource";
// Critere de tri du dictionnaire
$tabsqlsort=array();
@@ -183,6 +186,7 @@ $tabsqlsort[22]="code ASC, label ASC";
$tabsqlsort[23]="fk_pcg_version ASC, accountancy_code ASC";
$tabsqlsort[24]="pcg_version ASC";
$tabsqlsort[25]="country ASC, taux ASC";
+$tabsqlsort[26]="code ASC,label ASC";
// Nom des champs en resultat de select pour affichage du dictionnaire
$tabfield=array();
@@ -211,6 +215,7 @@ $tabfield[22]= "code,label";
$tabfield[23]= "fk_pcg_version,accountancy_code,account_parent,pcg_type,pcg_subtype,label";
$tabfield[24]= "pcg_version,country_id,country,label";
$tabfield[25]= "country_id,country,taux,accountancy_code_sell,accountancy_code_buy,note";
+$tabfield[26]= "code,label";
// Nom des champs d'edition pour modification d'un enregistrement
$tabfieldvalue=array();
@@ -239,6 +244,7 @@ $tabfieldvalue[22]= "code,label";
$tabfieldvalue[23]= "fk_pcg_version,accountancy_code,account_parent,pcg_type,pcg_subtype,label";
$tabfieldvalue[24]= "pcg_version,country,label";
$tabfieldvalue[25]= "country,taux,accountancy_code_sell,accountancy_code_buy,note";
+$tabfieldvalue[26]= "code,label";
// Nom des champs dans la table pour insertion d'un enregistrement
$tabfieldinsert=array();
@@ -267,6 +273,7 @@ $tabfieldinsert[22]= "code,label";
$tabfieldinsert[23]= "fk_pcg_version,account_number,account_parent,pcg_type,pcg_subtype,label";
$tabfieldinsert[24]= "pcg_version,fk_pays,label";
$tabfieldinsert[25]= "fk_pays,taux,accountancy_code_sell,accountancy_code_buy,note";
+$tabfieldinsert[26]= "code,label";
// Nom du rowid si le champ n'est pas de type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on
@@ -297,6 +304,7 @@ $tabrowid[22]= "rowid";
$tabrowid[23]= "";
$tabrowid[24]= "";
$tabrowid[25]= "";
+$tabrowid[25]= "";
// Condition to show dictionary in setup page
$tabcond=array();
@@ -325,6 +333,7 @@ $tabcond[22]= (! empty($conf->commande->enabled) || ! empty($conf->propal->enabl
$tabcond[23]= (! empty($conf->global->ACCOUNTING_USEDICTTOEDIT) && ! empty($conf->accounting->enabled)); // The accountancy plan should be edited with specific pages. You can set ACCOUNTING_USEDICTTOEDIT to 1 if you want to use dictionary editor.
$tabcond[24]= (! empty($conf->global->ACCOUNTING_USEDICTTOEDIT) && ! empty($conf->accounting->enabled)); // The accountancy system should be edited with specific pages. You can set ACCOUNTING_USEDICTTOEDIT to 1 if you want to use dictionary editor.
$tabcond[25]= true;
+$tabcond[26]= ! empty($conf->resource->enabled);
// List of help for fields
$tabhelp=array();
@@ -353,6 +362,7 @@ $tabhelp[22] = array();
$tabhelp[23] = array();
$tabhelp[24] = array();
$tabhelp[25] = array();
+$tabhelp[26] = array();
// Complete all arrays with entries found into modules
complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp);
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 2744c3eec4d..c843da68998 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -315,9 +315,8 @@ class Propal extends CommonObject
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=0, $pa_ht=0, $label='',$date_start='', $date_end='',$array_option=0)
{
global $mysoc;
- $propalid=$this->id;
- dol_syslog(get_class($this)."::addline propalid=$propalid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type");
+ dol_syslog(get_class($this)."::addline propalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type");
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Clean parameters
@@ -386,7 +385,7 @@ class Propal extends CommonObject
// Insert line
$this->line=new PropaleLigne($this->db);
- $this->line->fk_propal=$propalid;
+ $this->line->fk_propal=$this->id;
$this->line->label=$label;
$this->line->desc=$desc;
$this->line->qty=$qty;
@@ -435,7 +434,7 @@ class Propal extends CommonObject
if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
// Mise a jour informations denormalisees au niveau de la propale meme
- $result=$this->update_price(1);
+ $result=$this->update_price(1,'auto'); // This method is designed to add line from user input so total calculation must be done using 'auto' mode.
if ($result > 0)
{
$this->db->commit();
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index dd5bb59c678..b3d90fd562b 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -1052,9 +1052,7 @@ class Commande extends CommonOrder
{
global $mysoc, $conf, $langs;
- $commandeid=$this->id;
-
- dol_syslog(get_class($this)."::addline commandeid=$commandeid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end, type=$type", LOG_DEBUG);
+ dol_syslog(get_class($this)."::addline commandeid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, date_start=$date_start, date_end=$date_end, type=$type", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
@@ -1143,7 +1141,7 @@ class Commande extends CommonOrder
// Insert line
$this->line=new OrderLine($this->db);
- $this->line->fk_commande=$commandeid;
+ $this->line->fk_commande=$this->id;
$this->line->label=$label;
$this->line->desc=$desc;
$this->line->qty=$qty;
@@ -1190,8 +1188,7 @@ class Commande extends CommonOrder
if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
// Mise a jour informations denormalisees au niveau de la commande meme
- $this->id=$commandeid; // TODO A virer
- $result=$this->update_price(1);
+ $result=$this->update_price(1,'auto'); // This method is designed to add line from user input so total calculation must be done using 'auto' mode.
if ($result > 0)
{
$this->db->commit();
diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php
index f1c179719a0..2b326858c48 100644
--- a/htdocs/commande/fiche.php
+++ b/htdocs/commande/fiche.php
@@ -1364,8 +1364,10 @@ if ($action == 'create' && $user->rights->commande->creer) {
// Reference client
print '
' . $langs->trans('RefCustomer') . '
';
- // print '
';
- print ''; // We must not use ref_client of proposal for an order
+ if (!empty($conf->global->MAIN_USE_PROPAL_REFCLIENT_FOR_ORDER))
+ print '';
+ else
+ print '';
print '
';
// Client
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 65736e06097..5924b47dbd7 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -411,7 +411,7 @@ class Facture extends CommonInvoice
/*
* Insert lines of predefined invoices
- */
+ */
if (! $error && $this->fac_rec > 0)
{
foreach ($_facrec->lines as $i => $val)
@@ -2010,9 +2010,7 @@ class Facture extends CommonInvoice
{
global $mysoc, $conf, $langs;
- $facid=$this->id;
-
- dol_syslog(get_class($this)."::Addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type", LOG_DEBUG);
+ dol_syslog(get_class($this)."::addline facid=$this->id,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type", LOG_DEBUG);
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
// Clean parameters
@@ -2058,21 +2056,6 @@ class Facture extends CommonInvoice
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc);
- /*if (is_object($invoiceline) && $invoiceline->total_ttc && $invoiceline->total_ht) // We already have details calculated
- {
- $pu=($price_base_type=='HT'?price2num($invoiceline->total_ttc/$qty,'MU'):price2num($invoiceline->total_ht/$qty,'MU'));
-
- $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, '', $localtaxes_type);
- // Now overwrite already calculated fields
- $tabprice[0] = $array_calculated['total_ht'];
- $tabprice[1] = $array_calculated['total_vat'];
- $tabprice[2] = $array_calculated['total_ttc'];
- $tabprice[9] = $array_calculated['total_localtax1'];
- $tabprice[10] = $array_calculated['total_localtax2'];
- $tabprice[3] = $array_calculated['pu_ht'];
- }
- else*/
-
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, '', $localtaxes_type);
$total_ht = $tabprice[0];
@@ -2106,7 +2089,7 @@ class Facture extends CommonInvoice
// Insert line
$this->line=new FactureLigne($this->db);
- $this->line->fk_facture=$facid;
+ $this->line->fk_facture=$this->id;
$this->line->label=$label; // deprecated
$this->line->desc=$desc;
$this->line->qty= ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative
@@ -2150,8 +2133,7 @@ class Facture extends CommonInvoice
if (! empty($fk_parent_line)) $this->line_order(true,'DESC');
// Mise a jour informations denormalisees au niveau de la facture meme
- $this->id=$facid; // TODO To move this we must remove parameter facid into this function declaration
- $result=$this->update_price(1);
+ $result=$this->update_price(1,'auto'); // This method is designed to add line from user input so total calculation must be done using 'auto' mode.
if ($result > 0)
{
$this->db->commit();
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index ec8a9be586b..7f13f128541 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -1515,21 +1515,23 @@ abstract class CommonObject
* Update total_ht, total_ttc, total_vat, total_localtax1, total_localtax2 for an object (sum of lines).
* Must be called at end of methods addline or updateline.
*
- * @param int $exclspec Exclude special product (product_type=9)
- * @param int $roundingadjust -1=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND if defined, or 0), 0=Force use total of rounding, 1=Force use rounding of total
+ * @param int $exclspec >0 = Exclude special product (product_type=9)
+ * @param string $roundingadjust 'none'=Do nothing, 'auto'=Use default method (MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND if defined, or '0'), '0'=Force use total of rounding, '1'=Force use rounding of total
* @param int $nodatabaseupdate 1=Do not update database. Update only properties of object.
* @param Societe $seller If roundingadjust is 0, it means we recalculate total for lines before calculating total for object. For this, we need seller object.
* @return int <0 if KO, >0 if OK
*/
- function update_price($exclspec=0,$roundingadjust=-1,$nodatabaseupdate=0,$seller='')
+ function update_price($exclspec=0,$roundingadjust='none',$nodatabaseupdate=0,$seller='')
{
global $conf;
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
+ if ($roundingadjust == '-1') $roundingadjust='auto'; // For backward compatibility
+
$forcedroundingmode=$roundingadjust;
- if ($forcedroundingmode < 0 && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) $forcedroundingmode=$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND;
- if ($forcedroundingmode < 0) $forcedroundingmode=0;
+ if ($forcedroundingmode == 'auto' && isset($conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND)) $forcedroundingmode=$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND;
+ if ($forcedroundingmode == 'auto') $forcedroundingmode='0';
$error=0;
@@ -1575,17 +1577,17 @@ abstract class CommonObject
{
$obj = $this->db->fetch_object($resql);
- // By default, no adjustement is required ($forcedroundingmode = -1)
- if ($forcedroundingmode == 0) // Check if we need adjustement onto line for vat
+ // Note: There is no check on detail line and no check on total, if $forcedroundingmode = 'none'
+
+ if ($forcedroundingmode == '0') // Check if data on line are consistent. This may solve lines that were not consistent because set with $forcedroundingmode='auto'
{
$localtax_array=array($obj->localtax1_type,$obj->localtax1_tx,$obj->localtax2_type,$obj->localtax2_tx);
$tmpcal=calcul_price_total($obj->qty, $obj->up, $obj->remise_percent, $obj->vatrate, $obj->localtax1_tx, $obj->localtax2_tx, 0, 'HT', $obj->info_bits, $obj->product_type, $seller, $localtax_array);
$diff=price2num($tmpcal[1] - $obj->total_tva, 'MT', 1);
if ($diff)
{
- if (abs($diff) > 0.1) { dol_syslog('','A rounding difference was detected', LOG_WARNING); }
$sqlfix="UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".$tmpcal[1].", total_ttc = ".$tmpcal[2]." WHERE rowid = ".$obj->rowid;
- dol_syslog('We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". We fix the vat and total_ttc by running sqlfix = ".$sqlfix);
+ dol_syslog('We found unconsistent data into detailed line (difference of '.$diff.') for line rowid = '.$obj->rowid." (total vat of line calculated=".$tmpcal[1].", database=".$obj->total_tva."). We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix);
$resqlfix=$this->db->query($sqlfix);
if (! $resqlfix) dol_print_error($this->db,'Failed to update line');
$obj->total_tva = $tmpcal[1];
@@ -1606,17 +1608,16 @@ abstract class CommonObject
$total_tva_by_vats[$obj->vatrate] += $obj->total_tva;
$total_ttc_by_vats[$obj->vatrate] += $obj->total_ttc;
- if ($forcedroundingmode == 1) // Check if we need adjustement onto line for vat
+ if ($forcedroundingmode == '1') // Check if we need adjustement onto line for vat
{
$tmpvat=price2num($total_ht_by_vats[$obj->vatrate] * $obj->vatrate / 100, 'MT', 1);
$diff=price2num($total_tva_by_vats[$obj->vatrate]-$tmpvat, 'MT', 1);
//print 'Line '.$i.' rowid='.$obj->rowid.' vat_rate='.$obj->vatrate.' total_ht='.$obj->total_ht.' total_tva='.$obj->total_tva.' total_ttc='.$obj->total_ttc.' total_ht_by_vats='.$total_ht_by_vats[$obj->vatrate].' total_tva_by_vats='.$total_tva_by_vats[$obj->vatrate].' (new calculation = '.$tmpvat.') total_ttc_by_vats='.$total_ttc_by_vats[$obj->vatrate].($diff?" => DIFF":"")." \n";
if ($diff)
{
- if (abs($diff) > 0.1) { dol_syslog('','A rounding difference was detected but is too high to be corrected', LOG_WARNING); exit; }
+ if (abs($diff) > 0.1) { dol_syslog('','A rounding difference was detected into TOTAL but is too high to be corrected', LOG_WARNING); exit; }
$sqlfix="UPDATE ".MAIN_DB_PREFIX.$this->table_element_line." SET ".$fieldtva." = ".($obj->total_tva - $diff).", total_ttc = ".($obj->total_ttc - $diff)." WHERE rowid = ".$obj->rowid;
- //print 'We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". Run sqlfix = ".$sqlfix." \n";
- dol_syslog('We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". We fix the vat and total_ttc by running sqlfix = ".$sqlfix);
+ dol_syslog('We found a difference of '.$diff.' for line rowid = '.$obj->rowid.". We fix the total_vat and total_ttc of line by running sqlfix = ".$sqlfix);
$resqlfix=$this->db->query($sqlfix);
if (! $resqlfix) dol_print_error($this->db,'Failed to update line');
$this->total_tva -= $diff;
@@ -3284,6 +3285,92 @@ abstract class CommonObject
print '';
}
+
+ /**
+ * Add resources to the current object : add entry into llx_element_resources
+ *Need $this->element & $this->id
+ *
+ * @param int $resource_id Resource id
+ * @param string $resource_element Resource element
+ * @return int <=0 if KO, >0 if OK
+ */
+ function add_element_resource($resource_id,$resource_element,$busy=0,$mandatory=0)
+ {
+ $this->db->begin();
+
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."element_resources (";
+ $sql.= "resource_id";
+ $sql.= ", resource_type";
+ $sql.= ", element_id";
+ $sql.= ", element_type";
+ $sql.= ", busy";
+ $sql.= ", mandatory";
+ $sql.= ") VALUES (";
+ $sql.= $resource_id;
+ $sql.= ", '".$resource_element."'";
+ $sql.= ", '".$this->id."'";
+ $sql.= ", '".$this->element."'";
+ $sql.= ", '".$busy."'";
+ $sql.= ", '".$mandatory."'";
+ $sql.= ")";
+
+ dol_syslog(get_class($this)."::add_element_resource sql=".$sql, LOG_DEBUG);
+ if ($this->db->query($sql))
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ $this->error=$this->db->lasterror();
+ $this->db->rollback();
+ return 0;
+ }
+ }
+
+ /**
+ * Delete a link to resource line
+ *
+ * @param int $rowid Id of resource line to delete
+ * @param int $element element name (for trigger) TODO: use $this->element into commonobject class
+ * @param int $notrigger Disable all triggers
+ * @return int >0 if OK, <0 if KO
+ */
+ function delete_resource($rowid, $element, $notrigger=0)
+ {
+ global $user,$langs,$conf;
+
+ $error=0;
+
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_resources";
+ $sql.= " WHERE rowid =".$rowid;
+
+ dol_syslog(get_class($this)."::delete_resource sql=".$sql);
+ if ($this->db->query($sql))
+ {
+ if (! $notrigger)
+ {
+ // Call triggers
+ include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
+ $interface=new Interfaces($this->db);
+ $result=$interface->run_triggers(strtoupper($element).'_DELETE_RESOURCE',$this,$user,$langs,$conf);
+ if ($result < 0) {
+ $error++; $this->errors=$interface->errors;
+ }
+ // End call triggers
+ }
+
+ return 1;
+ }
+ else
+ {
+ $this->error=$this->db->lasterror();
+ dol_syslog(get_class($this)."::delete_resource error=".$this->error, LOG_ERR);
+ return -1;
+ }
+ }
+
+
/**
* Overwrite magic function to solve problem of cloning object that are kept as references
*
diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php
index efa0af07843..cc84823c276 100644
--- a/htdocs/core/lib/functions2.lib.php
+++ b/htdocs/core/lib/functions2.lib.php
@@ -1656,3 +1656,125 @@ function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent)
return $totalnb;
}
}
+
+/**
+ * Get an array with properties of an element
+*
+* @param string $element_type Element type. ex : project_task or object@modulext or object_under@module
+* @return array (module, classpath, element, subelement, classfile, classname)
+*/
+function getElementProperties($element_type)
+{
+ // Parse element/subelement (ex: project_task)
+ $module = $element = $subelement = $element_type;
+
+ // If we ask an resource form external module (instead of default path)
+ if (preg_match('/^([^@]+)@([^@]+)$/i',$element_type,$regs))
+ {
+ $element = $subelement = $regs[1];
+ $module = $regs[2];
+ }
+
+ //print ' 1. element : '.$element.' - module : '.$module .' ';
+ if ( preg_match('/^([^_]+)_([^_]+)/i',$element,$regs))
+ {
+ $module = $element = $regs[1];
+ $subelement = $regs[2];
+ }
+
+ $classfile = strtolower($subelement);
+ $classname = ucfirst($subelement);
+ $classpath = $module.'/class';
+
+ // For compat
+ if($element_type == "action") {
+ $classpath = 'comm/action/class';
+ $subelement = 'Actioncomm';
+ $module = 'agenda';
+ }
+
+ // To work with non standard path
+ if ($element_type == 'facture' || $element_type == 'invoice') {
+ $classpath = 'compta/facture/class';
+ $module='facture';
+ $subelement='facture';
+ }
+ if ($element_type == 'commande' || $element_type == 'order') {
+ $classpath = 'commande/class';
+ $module='commande';
+ $subelement='commande';
+ }
+ if ($element_type == 'propal') {
+ $classpath = 'comm/propal/class';
+ }
+ if ($element_type == 'shipping') {
+ $classpath = 'expedition/class';
+ $subelement = 'expedition';
+ $module = 'expedition_bon';
+ }
+ if ($element_type == 'delivery') {
+ $classpath = 'livraison/class';
+ $subelement = 'livraison';
+ $module = 'livraison_bon';
+ }
+ if ($element_type == 'contract') {
+ $classpath = 'contrat/class';
+ $module='contrat';
+ $subelement='contrat';
+ }
+ if ($element_type == 'member') {
+ $classpath = 'adherents/class';
+ $module='adherent';
+ $subelement='adherent';
+ }
+ if ($element_type == 'cabinetmed_cons') {
+ $classpath = 'cabinetmed/class';
+ $module='cabinetmed';
+ $subelement='cabinetmedcons';
+ }
+ if ($element_type == 'fichinter') {
+ $classpath = 'fichinter/class';
+ $module='ficheinter';
+ $subelement='fichinter';
+ }
+ $classfile = strtolower($subelement);
+ $classname = ucfirst($subelement);
+
+ $element_properties = array(
+ 'module' => $module,
+ 'classpath' => $classpath,
+ 'element' => $element,
+ 'subelement' => $subelement,
+ 'classfile' => $classfile,
+ 'classname' => $classname
+ );
+ return $element_properties;
+}
+
+/**
+ * Fetch an object with element_type and its id
+ * Inclusion classes is automatic
+ *
+ * @param int $element_id Element id
+ * @param string $element_type Element type
+ * @return object || 0 || -1 if error
+ */
+function fetchObjectByElement($element_id,$element_type) {
+
+ global $conf;
+ global $db,$conf;
+
+ $element_prop = getElementProperties($element_type);
+ if (is_array($element_prop) && $conf->$element_prop['module']->enabled)
+ {
+ dol_include_once('/'.$element_prop['classpath'].'/'.$element_prop['classfile'].'.class.php');
+
+ $objectstat = new $element_prop['classname']($db);
+ $ret = $objectstat->fetch($element_id);
+ if ($ret >= 0)
+ {
+ return $objectstat;
+ }
+ }
+ return 0;
+}
diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php
index 7be5f3e2ee5..ac9845f22a1 100644
--- a/htdocs/core/lib/price.lib.php
+++ b/htdocs/core/lib/price.lib.php
@@ -299,7 +299,7 @@ function calcul_price_total($qty, $pu, $remise_percent_ligne, $txtva, $uselocalt
}
}
- //print "Price.lib::calcul_price_total ".$result[0]."-".$result[1]."-".$result[2];
+ dol_syslog('Price.lib::calcul_price_total MAIN_ROUNDING_RULE_TOT='.$conf->global->MAIN_ROUNDING_RULE_TOT.' pu='.$pu.' qty='.$qty.' price_base_type='.$price_base_type.' total_ht='.$result[0].'-total_vat='.$result[1].'-total_ttc='.$result[2]);
return $result;
}
diff --git a/htdocs/core/lib/resource.lib.php b/htdocs/core/lib/resource.lib.php
new file mode 100644
index 00000000000..c516485ed9d
--- /dev/null
+++ b/htdocs/core/lib/resource.lib.php
@@ -0,0 +1,44 @@
+
+ *
+ * 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 lib/resource.lib.php
+ * \ingroup resource
+ * \brief This file is library for resource module
+ */
+
+function resourcePrepareHead($object)
+{
+ global $langs, $conf, $user;
+ $h = 0;
+ $head = array();
+
+ $head[$h][0] = dol_buildpath('/resource/card.php',1).'?id='.$object->id;
+ $head[$h][1] = $langs->trans("ResourceCard");
+ $head[$h][2] = 'resource';
+ $h++;
+
+ // Show more tabs from modules
+ // Entries must be declared in modules descriptor with line
+ // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
+ // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
+ complete_head_from_modules($conf,$langs,$object,$head,$h,'resource');
+
+
+ return $head;
+}
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index 4f8051e2ee3..35b3f78c5e7 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -702,6 +702,17 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
$newmenu->add("/fourn/commande/index.php?leftmenu=orders_suppliers",$langs->trans("SuppliersOrders"), 0, $user->rights->fournisseur->commande->lire, '', $mainmenu, 'orders_suppliers');
$newmenu->add("/fourn/commande/fiche.php?action=create&leftmenu=orders_suppliers", $langs->trans("NewOrder"), 1, $user->rights->fournisseur->commande->creer);
$newmenu->add("/fourn/commande/liste.php?leftmenu=orders_suppliers", $langs->trans("List"), 1, $user->rights->fournisseur->commande->lire);
+
+ if (empty($leftmenu) || $leftmenu=="orders_suppliers") $newmenu->add("/fourn/commande/liste.php?leftmenu=orders_suppliers&statut=0", $langs->trans("StatusOrderDraftShort"), 2, $user->rights->fournisseur->commande->lire);
+ if (empty($leftmenu) || $leftmenu=="orders_suppliers") $newmenu->add("/fourn/commande/liste.php?leftmenu=orders_suppliers&statut=1", $langs->trans("StatusOrderValidated"), 2, $user->rights->fournisseur->commande->lire);
+ if (empty($leftmenu) || $leftmenu=="orders_suppliers") $newmenu->add("/fourn/commande/liste.php?leftmenu=orders_suppliers&statut=2", $langs->trans("StatusOrderApprovedShort"), 2, $user->rights->fournisseur->commande->lire);
+ if (empty($leftmenu) || $leftmenu=="orders_suppliers") $newmenu->add("/fourn/commande/liste.php?leftmenu=orders_suppliers&statut=3", $langs->trans("StatusOrderOnProcess"), 2, $user->rights->fournisseur->commande->lire);
+ if (empty($leftmenu) || $leftmenu=="orders_suppliers") $newmenu->add("/fourn/commande/liste.php?leftmenu=orders_suppliers&statut=4", $langs->trans("StatusOrderReceivedPartially"), 2, $user->rights->fournisseur->commande->lire);
+ if (empty($leftmenu) || $leftmenu=="orders_suppliers") $newmenu->add("/fourn/commande/liste.php?leftmenu=orders_suppliers&statut=5", $langs->trans("StatusOrderReceivedAll"), 2, $user->rights->fournisseur->commande->lire);
+ if (empty($leftmenu) || $leftmenu=="orders_suppliers") $newmenu->add("/fourn/commande/liste.php?leftmenu=orders_suppliers&statut=6,7", $langs->trans("StatusOrderCanceled"), 2, $user->rights->fournisseur->commande->lire);
+ if (empty($leftmenu) || $leftmenu=="orders_suppliers") $newmenu->add("/fourn/commande/liste.php?leftmenu=orders_suppliers&statut=9", $langs->trans("StatusOrderRefused"), 2, $user->rights->fournisseur->commande->lire);
+
+
$newmenu->add("/commande/stats/index.php?leftmenu=orders_suppliers&mode=supplier", $langs->trans("Statistics"), 1, $user->rights->fournisseur->commande->lire);
}
diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php
new file mode 100644
index 00000000000..b391c6bb4af
--- /dev/null
+++ b/htdocs/core/modules/modResource.class.php
@@ -0,0 +1,391 @@
+
+ *
+ * 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 .
+ */
+
+/**
+ * \defgroup resource Resource module
+ * \brief Resource module descriptor.
+ * \file core/modules/modResource.class.php
+ * \ingroup resource
+ * \brief Description and activation file for module Resource
+ */
+include_once DOL_DOCUMENT_ROOT . "/core/modules/DolibarrModules.class.php";
+
+/**
+ * Description and activation class for module Resource
+ */
+class modResource extends DolibarrModules
+{
+
+ /**
+ * Constructor. Define names, constants, directories, boxes, permissions
+ *
+ * @param DoliDB $db Database handler
+ */
+ public function __construct($db)
+ {
+ global $langs, $conf;
+
+ $this->db = $db;
+
+ // Id for module (must be unique).
+ // Use a free id here
+ // (See in Home -> System information -> Dolibarr for list of used modules id).
+ $this->numero = 110111;
+ // Key text used to identify module (for permissions, menus, etc...)
+ $this->rights_class = 'resource';
+
+ // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
+ // It is used to group modules in module setup page
+ $this->family = "hr";
+ // 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));
+ // Module description
+ // used if translation string 'ModuleXXXDesc' not found
+ // (where XXX is value of numeric property 'numero' of module)
+ $this->description = "Description of module Resource";
+ // Possible values for version are: 'development', 'experimental' or version
+ $this->version = 'experimental';
+ // Key used in llx_const table to save module status enabled/disabled
+ // (where MYMODULE is value of property name of module in uppercase)
+ $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
+ // Where to store the module in setup page
+ // (0=common,1=interface,2=others,3=very specific)
+ $this->special = 0;
+ // Name of image file used for this module.
+ // If file is in theme/yourtheme/img directory under name object_pictovalue.png
+ // use this->picto='pictovalue'
+ // If file is in module/img directory under name object_pictovalue.png
+ // use this->picto='pictovalue@module'
+ $this->picto = 'resource'; // mypicto@resource
+ // Defined all module parts (triggers, login, substitutions, menus, css, etc...)
+ // for default path (eg: /resource/core/xxxxx) (0=disable, 1=enable)
+ // for specific path of parts (eg: /resource/core/modules/barcode)
+ // for specific css file (eg: /resource/css/resource.css.php)
+ $this->module_parts = array(
+ // Set this to 1 if module has its own trigger directory
+ //'triggers' => 1,
+ // Set this to 1 if module has its own login method directory
+ //'login' => 0,
+ // Set this to 1 if module has its own substitution function file
+ //'substitutions' => 0,
+ // Set this to 1 if module has its own menus handler directory
+ //'menus' => 0,
+ // Set this to 1 if module has its own barcode directory
+ //'barcode' => 0,
+ // Set this to 1 if module has its own models directory
+ //'models' => 0,
+ // Set this to relative path of css if module has its own css file
+ //'css' => '/resource/css/resource.css.php',
+ // Set here all hooks context managed by module
+ 'hooks' => array('actioncard','actioncommdao','resource_card','element_resource')
+ // Set here all workflow context managed by module
+ //'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE'))
+ );
+
+ // Data directories to create when module is enabled.
+ // Example: this->dirs = array("/resource/temp");
+ //$this->dirs = array("/resource");
+
+ // Config pages. Put here list of php pages
+ // stored into resource/admin directory, used to setup module.
+ //$this->config_page_url = array("admin_resource.php@resource");
+
+ // Dependencies
+ // List of modules id that must be enabled if this module is enabled
+ $this->depends = array();
+ // List of modules id to disable if this one is disabled
+ $this->requiredby = array('modPlace');
+ // Minimum version of PHP required by module
+ $this->phpmin = array(5, 3);
+ // Minimum version of Dolibarr required by module
+ $this->need_dolibarr_version = array(3, 5);
+ $this->langfiles = array("resource@resource"); // langfiles@resource
+ // Constants
+ // List of particular constants to add when module is enabled
+ // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
+ // Example:
+ $this->const = array();
+
+ // Array to add new pages in new tabs
+ // Example:
+ $this->tabs = array(
+ // // To add a new tab identified by code tabname1
+ // 'objecttype:+tabname1:Title1:langfile@resource:$user->rights->resource->read:/resource/mynewtab1.php?id=__ID__',
+ // // To add another new tab identified by code tabname2
+ // 'objecttype:+tabname2:Title2:langfile@resource:$user->rights->othermodule->read:/resource/mynewtab2.php?id=__ID__',
+ // // To remove an existing tab identified by code tabname
+ // 'objecttype:-tabname'
+ );
+ // where objecttype can be
+ // 'thirdparty' to add a tab in third party view
+ // 'intervention' to add a tab in intervention view
+ // 'order_supplier' to add a tab in supplier order view
+ // 'invoice_supplier' to add a tab in supplier invoice view
+ // 'invoice' to add a tab in customer invoice view
+ // 'order' to add a tab in customer order view
+ // 'product' to add a tab in product view
+ // 'stock' to add a tab in stock view
+ // 'propal' to add a tab in propal view
+ // 'member' to add a tab in fundation member view
+ // 'contract' to add a tab in contract view
+ // 'user' to add a tab in user view
+ // 'group' to add a tab in group view
+ // 'contact' to add a tab in contact view
+ // 'categories_x' to add a tab in category view
+ // (reresource 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
+
+ $this->tabs = array(
+ 'action:+resources:Resources:resource:$user->rights->resource->read:/resource/element_resource.php?element=action&element_id=__ID__',
+ 'thirdparty:+resources:Resources:resource:$user->rights->resource->read:/resource/element_resource.php?element=societe&element_id=__ID__'
+ );
+
+ // Boxes
+ // Add here list of php file(s) stored in core/boxes that contains class to show a box.
+ $this->boxes = array(); // Boxes list
+ $r = 0;
+ // Example:
+
+ //$this->boxes[$r][1] = "MyBox@resource";
+ //$r ++;
+ /*
+ $this->boxes[$r][1] = "myboxb.php";
+ $r++;
+ */
+
+ // Permissions
+ $this->rights = array(); // Permission array used by this module
+ $r = 0;
+
+ $this->rights[$r][0] = 1101201;
+ $this->rights[$r][1] = 'See resources';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'read';
+ $r++;
+
+ $this->rights[$r][0] = 1101202;
+ $this->rights[$r][1] = 'Modify resources';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'write';
+ $r++;
+
+ $this->rights[$r][0] = 1101203;
+ $this->rights[$r][1] = 'Delete resources';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'delete';
+ $r++;
+
+ $this->rights[$r][0] = 1101204;
+ $this->rights[$r][1] = 'Link resources';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'link';
+ $r++;
+
+
+ // Add here list of permission defined by
+ // an id, a label, a boolean and two constant strings.
+ // Example:
+ //// Permission id (must not be already used)
+ //$this->rights[$r][0] = 2000;
+ //// Permission label
+ //$this->rights[$r][1] = 'Permision label';
+ //// Permission by default for new user (0/1)
+ //$this->rights[$r][3] = 1;
+ //// In php code, permission will be checked by test
+ //// if ($user->rights->permkey->level1->level2)
+ //$this->rights[$r][4] = 'level1';
+ //// In php code, permission will be checked by test
+ //// if ($user->rights->permkey->level1->level2)
+ //$this->rights[$r][5] = 'level2';
+ //$r++;
+ // Main menu entries
+ $this->menu = array(); // List of menus to add
+ $r = 0;
+
+ // Menus declaration
+ $this->menu[$r]=array(
+ 'fk_menu'=>'fk_mainmenu=tools',
+ 'type'=>'left',
+ 'titre'=> 'MenuResourceIndex',
+ 'mainmenu'=>'tools',
+ 'leftmenu'=> 'resource',
+ 'url'=> '/resource/list.php',
+ 'langs'=> 'resource',
+ 'position'=> 100,
+ 'enabled'=> '1',
+ 'perms'=> '$user->rights->resource->read',
+ 'user'=> 0
+ );
+ $r++;
+
+ $this->menu[$r++]=array(
+ 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=resource', //On utilise les ancres définis dans le menu parent déclaré au dessus
+ 'type'=> 'left', // Toujours un menu gauche
+ 'titre'=> 'MenuResourceAdd',
+ 'mainmenu'=> 'tools',
+ 'leftmenu'=> '', // On n'indique rien ici car on ne souhaite pas intégrer de sous-menus à ce menu
+ 'url'=> '/resource/add.php',
+ 'langs'=> 'resource',
+ 'position'=> 101,
+ 'enabled'=> '1',
+ 'perms'=> '$user->rights->resource->read',
+ 'target'=> '',
+ 'user'=> 0
+ );
+
+ // Exports
+ $r = 1;
+
+ // Example:
+ //$this->export_code[$r]=$this->rights_class.'_'.$r;
+ //// Translation key (used only if key ExportDataset_xxx_z not found)
+ //$this->export_label[$r]='CustomersInvoicesAndInvoiceLines';
+ //// Condition to show export in list (ie: '$user->id==3').
+ //// Set to 1 to always show when module is enabled.
+ //$this->export_enabled[$r]='1';
+ //$this->export_permission[$r]=array(array("facture","facture","export"));
+ //$this->export_fields_array[$r]=array(
+ // 's.rowid'=>"IdCompany",
+ // 's.nom'=>'CompanyName',
+ // 's.address'=>'Address',
+ // 's.cp'=>'Zip',
+ // 's.ville'=>'Town',
+ // 's.fk_pays'=>'Country',
+ // 's.tel'=>'Phone',
+ // 's.siren'=>'ProfId1',
+ // 's.siret'=>'ProfId2',
+ // 's.ape'=>'ProfId3',
+ // 's.idprof4'=>'ProfId4',
+ // 's.code_compta'=>'CustomerAccountancyCode',
+ // 's.code_compta_fournisseur'=>'SupplierAccountancyCode',
+ // 'f.rowid'=>"InvoiceId",
+ // 'f.facnumber'=>"InvoiceRef",
+ // 'f.datec'=>"InvoiceDateCreation",
+ // 'f.datef'=>"DateInvoice",
+ // 'f.total'=>"TotalHT",
+ // 'f.total_ttc'=>"TotalTTC",
+ // 'f.tva'=>"TotalVAT",
+ // 'f.paye'=>"InvoicePaid",
+ // 'f.fk_statut'=>'InvoiceStatus',
+ // 'f.note'=>"InvoiceNote",
+ // 'fd.rowid'=>'LineId',
+ // 'fd.description'=>"LineDescription",
+ // 'fd.price'=>"LineUnitPrice",
+ // 'fd.tva_tx'=>"LineVATRate",
+ // 'fd.qty'=>"LineQty",
+ // 'fd.total_ht'=>"LineTotalHT",
+ // 'fd.total_tva'=>"LineTotalTVA",
+ // 'fd.total_ttc'=>"LineTotalTTC",
+ // 'fd.date_start'=>"DateStart",
+ // 'fd.date_end'=>"DateEnd",
+ // 'fd.fk_product'=>'ProductId',
+ // 'p.ref'=>'ProductRef'
+ //);
+ //$this->export_entities_array[$r]=array('s.rowid'=>"company",
+ // 's.nom'=>'company',
+ // 's.address'=>'company',
+ // 's.cp'=>'company',
+ // 's.ville'=>'company',
+ // 's.fk_pays'=>'company',
+ // 's.tel'=>'company',
+ // 's.siren'=>'company',
+ // 's.siret'=>'company',
+ // 's.ape'=>'company',
+ // 's.idprof4'=>'company',
+ // 's.code_compta'=>'company',
+ // 's.code_compta_fournisseur'=>'company',
+ // 'f.rowid'=>"invoice",
+ // 'f.facnumber'=>"invoice",
+ // 'f.datec'=>"invoice",
+ // 'f.datef'=>"invoice",
+ // 'f.total'=>"invoice",
+ // 'f.total_ttc'=>"invoice",
+ // 'f.tva'=>"invoice",
+ // 'f.paye'=>"invoice",
+ // 'f.fk_statut'=>'invoice',
+ // 'f.note'=>"invoice",
+ // 'fd.rowid'=>'invoice_line',
+ // 'fd.description'=>"invoice_line",
+ // 'fd.price'=>"invoice_line",
+ // 'fd.total_ht'=>"invoice_line",
+ // 'fd.total_tva'=>"invoice_line",
+ // 'fd.total_ttc'=>"invoice_line",
+ // 'fd.tva_tx'=>"invoice_line",
+ // 'fd.qty'=>"invoice_line",
+ // 'fd.date_start'=>"invoice_line",
+ // 'fd.date_end'=>"invoice_line",
+ // 'fd.fk_product'=>'product',
+ // 'p.ref'=>'product'
+ //);
+ //$this->export_sql_start[$r] = 'SELECT DISTINCT ';
+ //$this->export_sql_end[$r] = ' FROM (' . MAIN_DB_PREFIX . 'facture as f, '
+ // . MAIN_DB_PREFIX . 'facturedet as fd, ' . MAIN_DB_PREFIX . 'societe as s)';
+ //$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX
+ // . 'product as p on (fd.fk_product = p.rowid)';
+ //$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid '
+ // . 'AND f.rowid = fd.fk_facture';
+ //$r++;
+ }
+
+ /**
+ * Function called when module is enabled.
+ * The init function add constants, boxes, permissions and menus
+ * (defined in constructor) into Dolibarr database.
+ * It also creates data directories
+ *
+ * @param string $options Options when enabling module ('', 'noboxes')
+ * @return int 1 if OK, 0 if KO
+ */
+ public function init($options = '')
+ {
+ $sql = array();
+
+ $result = $this->loadTables();
+
+ return $this->_init($sql, $options);
+ }
+
+ /**
+ * Function called when module is disabled.
+ * Remove from database constants, boxes and permissions from Dolibarr database.
+ * Data directories are not deleted
+ *
+ * @param string $options Options when enabling module ('', 'noboxes')
+ * @return int 1 if OK, 0 if KO
+ */
+ public function remove($options = '')
+ {
+ $sql = array();
+
+ return $this->_remove($sql, $options);
+ }
+
+ /**
+ * Create tables, keys and data required by module
+ * Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys
+ * and create data commands must be stored in directory /resource/sql/
+ * This function is called by this->init
+ *
+ * @return int <=0 if KO, >0 if OK
+ */
+ private function loadTables()
+ {
+ return $this->_load_tables('/resource/sql/');
+ }
+}
diff --git a/htdocs/core/tpl/resource_add.tpl.php b/htdocs/core/tpl/resource_add.tpl.php
new file mode 100644
index 00000000000..f9cd20b5dc3
--- /dev/null
+++ b/htdocs/core/tpl/resource_add.tpl.php
@@ -0,0 +1,45 @@
+load($resource_type);
+
+$form = new Form($db);
+if(!class_exists('FormResource'))
+ require_once(DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php');
+$formresources = new FormResource($db);
+
+$out .= '
';
+
+}
+// FIN DU TPL
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 80ad56263fa..591fce671b1 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -1216,7 +1216,7 @@ class CommandeFournisseur extends CommonOrder
// Fin appel triggers
}
- $this->update_price();
+ $this->update_price('','auto');
$this->db->commit();
return 1;
@@ -1799,7 +1799,7 @@ class CommandeFournisseur extends CommonOrder
}
// Mise a jour info denormalisees au niveau facture
- $this->update_price();
+ $this->update_price('','auto');
$this->db->commit();
return $result;
diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php
index 37d918e07bd..549a9caed32 100644
--- a/htdocs/fourn/class/fournisseur.facture.class.php
+++ b/htdocs/fourn/class/fournisseur.facture.class.php
@@ -1256,7 +1256,7 @@ class FactureFournisseur extends CommonInvoice
}
// Update total price into invoice record
- $result=$this->update_price();
+ $result=$this->update_price('','auto');
return $result;
}
@@ -1285,7 +1285,7 @@ class FactureFournisseur extends CommonInvoice
$error=0;
$this->db->begin();
-
+
if (! $error && ! $notrigger)
{
// Appel des triggers
diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index aa853a789c2..bcd98329e69 100644
--- a/htdocs/fourn/commande/fiche.php
+++ b/htdocs/fourn/commande/fiche.php
@@ -1144,6 +1144,10 @@ elseif (! empty($object->id))
$author = new User($db);
$author->fetch($object->user_author_id);
+ $societe = new Fournisseur($db);
+ $result=$societe->fetch($object->socid);
+ if ($result < 0) dol_print_error($db);
+
$head = ordersupplier_prepare_head($object);
$title=$langs->trans("SupplierOrder");
@@ -1751,7 +1755,7 @@ elseif (! empty($object->id))
$var = true;
// Add free products/services
- $object->formAddObjectLine(1, $mysoc, $soc);
+ $object->formAddObjectLine(1, $societe, $mysoc);
$parameters = array();
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
diff --git a/htdocs/fourn/commande/liste.php b/htdocs/fourn/commande/liste.php
index e845f48a47c..4da9f5e40c1 100644
--- a/htdocs/fourn/commande/liste.php
+++ b/htdocs/fourn/commande/liste.php
@@ -115,9 +115,9 @@ if ($sall)
}
if ($socid) $sql.= " AND s.rowid = ".$socid;
-if (GETPOST('statut'))
+if (GETPOST('statut')!='')
{
- $sql .= " AND fk_statut =".GETPOST('statut','int');
+ $sql .= " AND fk_statut IN (".GETPOST('statut').")";
}
if ($search_refsupp)
{
diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index a787930471a..a244d85b343 100644
--- a/htdocs/fourn/facture/fiche.php
+++ b/htdocs/fourn/facture/fiche.php
@@ -989,7 +989,7 @@ elseif ($action == 'calculate')
$object->fetch($id);
$object->fetch_thirdparty();
- $result=$object->update_price(0, ($calculationrule=='totalofround'?0:1), 0, $object->thirdparty);
+ $result=$object->update_price(0, (($calculationrule=='totalofround')?'0':'1'), 0, $object->thirdparty);
if ($result <= 0)
{
dol_print_error($db,$result);
@@ -1888,8 +1888,7 @@ else
// Show product and description
$type=(! empty($object->lines[$i]->product_type)?$object->lines[$i]->product_type:(! empty($object->lines[$i]->fk_product_type)?$object->lines[$i]->fk_product_type:0));
- // Try to enhance type detection using date_start and date_end for free lines where type
- // was not saved.
+ // Try to enhance type detection using date_start and date_end for free lines where type was not saved.
$date_start='';
$date_end='';
if (! empty($object->lines[$i]->date_start))
@@ -2077,7 +2076,7 @@ else
$var = true;
// Add free products/services
- $object->formAddObjectLine(1, $mysoc, $soc);
+ $object->formAddObjectLine(1, $societe, $mysoc);
$parameters = array();
$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
diff --git a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql
index 35b8571813a..f4945b0c30f 100644
--- a/htdocs/install/mysql/migration/3.5.0-3.6.0.sql
+++ b/htdocs/install/mysql/migration/3.5.0-3.6.0.sql
@@ -1003,7 +1003,7 @@ create table llx_product_customer_price
datec datetime,
tms timestamp,
fk_product integer NOT NULL,
- fk_soc integer NOT NULL,
+ fk_soc integer NOT NULL,
price double(24,8) DEFAULT 0,
price_ttc double(24,8) DEFAULT 0,
price_min double(24,8) DEFAULT 0,
@@ -1011,7 +1011,7 @@ create table llx_product_customer_price
price_base_type varchar(3) DEFAULT 'HT',
tva_tx double(6,3),
recuperableonly integer NOT NULL DEFAULT '0', -- Other NPR VAT
- localtax1_tx double(6,3) DEFAULT 0, -- Other local VAT 1
+ localtax1_tx double(6,3) DEFAULT 0, -- Other local VAT 1
localtax2_tx double(6,3) DEFAULT 0, -- Other local VAT 2
fk_user integer,
import_key varchar(14) -- Import key
@@ -1038,7 +1038,7 @@ create table llx_product_customer_price_log
entity integer DEFAULT 1 NOT NULL, -- multi company id
datec datetime,
fk_product integer NOT NULL,
- fk_soc integer NOT NULL,
+ fk_soc integer NOT NULL,
price double(24,8) DEFAULT 0,
price_ttc double(24,8) DEFAULT 0,
price_min double(24,8) DEFAULT 0,
@@ -1046,7 +1046,7 @@ create table llx_product_customer_price_log
price_base_type varchar(3) DEFAULT 'HT',
tva_tx double(6,3),
recuperableonly integer NOT NULL DEFAULT 0, -- Other NPR VAT
- localtax1_tx double(6,3) DEFAULT 0, -- Other local VAT 1
+ localtax1_tx double(6,3) DEFAULT 0, -- Other local VAT 1
localtax2_tx double(6,3) DEFAULT 0, -- Other local VAT 2
fk_user integer,
import_key varchar(14) -- Import key
@@ -1091,10 +1091,10 @@ CREATE TABLE llx_payment_salary (
num_payment varchar(50),
label varchar(255),
datesp date, -- date de début de la période
- dateep date, -- date de fin de la période
+ dateep date, -- date de fin de la période
entity integer DEFAULT 1 NOT NULL, -- multi company id
note text,
- fk_bank integer,
+ fk_bank integer,
fk_user_creat integer,
fk_user_modif integer
)ENGINE=innodb;
@@ -1155,3 +1155,45 @@ create table llx_categorie_lang
ALTER TABLE llx_categorie_lang ADD UNIQUE INDEX uk_category_lang (fk_category, lang);
ALTER TABLE llx_categorie_lang ADD CONSTRAINT fk_category_lang_fk_category FOREIGN KEY (fk_category) REFERENCES llx_categorie (rowid);
+
+-- Resource module
+CREATE TABLE llx_resource
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ entity integer,
+ ref varchar(255),
+ description text,
+ fk_code_type_resource varchar(32),
+ note_public text,
+ note_private text,
+ tms timestamp
+)ENGINE=innodb;
+
+ALTER TABLE llx_resource ADD INDEX fk_code_type_resource_idx (fk_code_type_resource);
+
+CREATE TABLE llx_element_resources
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ resource_id integer,
+ resource_type varchar(64),
+ element_id integer,
+ element_type varchar(64),
+ busy integer,
+ mandatory integer,
+ fk_user_create integer,
+ tms timestamp
+)ENGINE=innodb;
+
+ALTER TABLE llx_element_resources ADD UNIQUE INDEX idx_element_resources_idx1 (resource_id, resource_type, element_id, element_type);
+ALTER TABLE llx_element_resources ADD INDEX idx_element_element_element_id (element_id);
+-- Pas de contraite sur resource_id et element_id car pointe sur differentes tables
+
+create table llx_c_type_resource
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ code varchar(32) NOT NULL,
+ label varchar(64) NOT NULL,
+ active tinyint DEFAULT 1 NOT NULL
+)ENGINE=innodb;
+
+ALTER TABLE llx_c_type_resource ADD UNIQUE INDEX uk_c_type_resource_id (label, code);
diff --git a/htdocs/install/mysql/tables/llx_c_type_resource.key.sql b/htdocs/install/mysql/tables/llx_c_type_resource.key.sql
new file mode 100644
index 00000000000..5a76ff0cfa6
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_c_type_resource.key.sql
@@ -0,0 +1,21 @@
+-- ========================================================================
+-- Copyright (C) 2014 Laurent Destailleur
+--
+-- 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 .
+--
+-- ========================================================================
+
+
+ALTER TABLE llx_c_type_contact ADD UNIQUE INDEX uk_c_type_contact_id (element, source, code);
+
diff --git a/htdocs/install/mysql/tables/llx_c_type_resource.sql b/htdocs/install/mysql/tables/llx_c_type_resource.sql
new file mode 100644
index 00000000000..efb505ba574
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_c_type_resource.sql
@@ -0,0 +1,34 @@
+-- ========================================================================
+-- Copyright (C) 2014 Jean-François Ferry
+--
+--
+-- 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 .
+--
+-- Defini les types de contact d'un element sert de reference pour
+-- la table llx_element_contact
+--
+-- element est le nom de la table utilisant le type de contact.
+-- i.e. contact, facture, projet, societe (sans le llx_ devant).
+-- Libelle est un texte decrivant le type de contact.
+-- active precise si cette valeur est 'active' ou 'archive'.
+--
+-- ========================================================================
+
+create table llx_c_type_resource
+(
+ rowid integer PRIMARY KEY,
+ code varchar(32) NOT NULL,
+ libelle varchar(64) NOT NULL,
+ active tinyint DEFAULT 1 NOT NULL
+)ENGINE=innodb;
diff --git a/htdocs/install/mysql/tables/llx_element_resources.key.sql b/htdocs/install/mysql/tables/llx_element_resources.key.sql
new file mode 100644
index 00000000000..72dd5f3d850
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_element_resources.key.sql
@@ -0,0 +1,23 @@
+-- ============================================================================
+-- Copyright (C) 2014 Jean-François Ferry
+--
+-- 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 .
+--
+-- ============================================================================
+
+
+ALTER TABLE llx_element_resources ADD UNIQUE INDEX idx_element_resources_idx1 (resource_id, resource_type, element_id, element_type);
+ALTER TABLE llx_element_resources ADD INDEX idx_element_element_element_id (element_id);
+-- Pas de contraite sur resource_id et element_id car pointe sur differentes tables
+
\ No newline at end of file
diff --git a/htdocs/install/mysql/tables/llx_element_resources.sql b/htdocs/install/mysql/tables/llx_element_resources.sql
new file mode 100644
index 00000000000..3cc636ceab4
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_element_resources.sql
@@ -0,0 +1,28 @@
+--
+-- Copyright (C) 2013 Jean-François Ferry
+--
+-- 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 llx_element_resources
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ resource_id integer,
+ resource_type varchar(64),
+ element_id integer,
+ element_type varchar(64),
+ busy integer,
+ mandatory integer,
+ fk_user_create integer,
+ tms timestamp
+)ENGINE=innodb;
diff --git a/htdocs/install/mysql/tables/llx_resource.key.sql b/htdocs/install/mysql/tables/llx_resource.key.sql
new file mode 100755
index 00000000000..62eb21056c4
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_resource.key.sql
@@ -0,0 +1,18 @@
+-- Module to manage resources into Dolibarr ERP/CRM
+-- Copyright (C) 2013 Jean-François Ferry
+--
+-- 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 .
+
+
+ALTER TABLE llx_resource ADD INDEX fk_code_type_resource_idx (fk_code_type_resource);
\ No newline at end of file
diff --git a/htdocs/install/mysql/tables/llx_resource.sql b/htdocs/install/mysql/tables/llx_resource.sql
new file mode 100755
index 00000000000..91ebbe8b75d
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_resource.sql
@@ -0,0 +1,27 @@
+-- Module to manage resources into Dolibarr ERP/CRM
+-- Copyright (C) 2013 Jean-François Ferry
+--
+-- 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 llx_resource
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ entity integer,
+ ref varchar(255),
+ description text,
+ fk_code_type_resource varchar(32),
+ note_public text,
+ note_private text,
+ tms timestamp
+)ENGINE=innodb;
\ No newline at end of file
diff --git a/htdocs/langs/en_US/resource.lang b/htdocs/langs/en_US/resource.lang
new file mode 100755
index 00000000000..f5927388193
--- /dev/null
+++ b/htdocs/langs/en_US/resource.lang
@@ -0,0 +1,33 @@
+
+MenuResourceIndex=Resources
+MenuResourceAdd=New resource
+MenuResourcePlanning=Resource planning
+DeleteResource=Delete resource
+ConfirmDeleteResourceElement=Confirm delete the resource for this element
+NoResourceInDatabase=No resource in database.
+NoResourceLinked=No resource linked
+
+ResourcePageIndex=Resources list
+ResourceSingular=Resource
+ResourceCard=Resource card
+AddResource=Add a resource
+ResourceFormLabel_ref=Resource name
+ResourceType=Resource type
+ResourceFormLabel_description=Resource description
+
+ResourcesLinkedToElement=Resources linked to element
+RessourceLineSuccessfullyUpdated=Resource successfully updated
+RessourceLineSuccessfullyDeleted=Resource successfully deleted
+
+ShowResourcePlanning=Show resource planning
+NoResourceInDatabase=No resource in database
+GotoDate=Go to date
+
+ResourceCreatedWithSuccess=Resource successfully created
+RessourceLineSuccessfullyDeleted=Resource line successfully deleted
+RessourceLineSuccessfullyUpdated=Resource line successfully updated
+
+TitleResourceCard=Resource card
+ConfirmDeleteResource=Confirm to delete this resource
+RessourceSuccessfullyDeleted=Resource successfully deleted
+DictionaryResourceType=Type of resources
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/resource.lang b/htdocs/langs/fr_FR/resource.lang
new file mode 100755
index 00000000000..7d896e27f5f
--- /dev/null
+++ b/htdocs/langs/fr_FR/resource.lang
@@ -0,0 +1,33 @@
+
+MenuResourceIndex=Ressources
+MenuResourceAdd=Nouvelle ressource
+MenuResourcePlanning=Planning des Ressources
+DeleteResource=Effacer resource
+ConfirmDeleteResourceElement=Confirmer la suppression de la ressource pour cet élément
+NoResourceInDatabase=Aucune ressource en base de données.
+NoResourceLinked=Aucune ressource liée
+
+ResourcePageIndex=Liste des Ressources
+ResourceSingular=Ressource
+ResourceCard=Fiche ressource
+AddResource=Ajouter une ressource
+ResourceFormLabel_ref=Nom de la ressource
+ResourceType=Type de la ressource
+ResourceFormLabel_description=Description de la ressource
+
+ResourcesLinkedToElement=Ressources liées à l'élément
+RessourceLineSuccessfullyUpdated=Ressource mise à jour
+RessourceLineSuccessfullyDeleted=Resource supprimée
+
+ShowResourcePlanning=Montrer le planning des ressources
+PlanningOfAffectedResources=Planning des ressources affectées aux évènements
+GotoDate=Afficher la date
+
+ResourceCreatedWithSuccess=Ressource créee avec succès
+RessourceLineSuccessfullyDeleted=Ressource supprimée avec succès
+RessourceLineSuccessfullyUpdated=Ressource mise à jour
+
+TitleResourceCard=Fiche resource
+ConfirmDeleteResource=Confirmer la suppression de cette ressource?
+RessourceSuccessfullyDeleted=Ressource effacée avec succès
+DictionaryResourceType=Type de ressources
\ No newline at end of file
diff --git a/htdocs/resource/add.php b/htdocs/resource/add.php
new file mode 100755
index 00000000000..5b127204185
--- /dev/null
+++ b/htdocs/resource/add.php
@@ -0,0 +1,175 @@
+
+ *
+ * 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 resource/add.php
+ * \ingroup resource
+ * \brief Page to manage resource object
+ * Initialy built by build_class_from_table on 2013-07-24 16:03
+ */
+
+
+// Change this following line to use the correct relative path (../, ../../, etc)
+$res=0;
+$res=@include("../main.inc.php"); // For root directory
+if (! $res) $res=@include("../../main.inc.php"); // For "custom" directory
+if (! $res) die("Include of main fails");
+
+require_once 'class/resource.class.php';
+require_once 'class/html.formresource.class.php';
+
+// Load traductions files requiredby by page
+$langs->load("resource");
+$langs->load("companies");
+$langs->load("other");
+$langs->load("resource@resource");
+
+// Get parameters
+$id = GETPOST('id','int');
+$action = GETPOST('action','alpha');
+if (empty($sortorder)) $sortorder="DESC";
+if (empty($sortfield)) $sortfield="t.rowid";
+if (empty($arch)) $arch = 0;
+
+if ($page == -1) {
+ $page = 0 ;
+}
+
+$limit = $conf->global->limit;
+$offset = $limit * $page ;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+
+
+// Protection if external user
+if ($user->societe_id > 0)
+{
+ accessforbidden();
+}
+
+$object = new Resource($db);
+
+if ($action == 'confirm_add_resource')
+{
+ $error='';
+
+ $ref=GETPOST('ref','alpha');
+ $description=GETPOST('description','alpha');
+ $fk_code_type_resource=GETPOST('fk_code_type_resource','alpha');
+
+ if (empty($ref))
+ {
+ $mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref"));
+ setEventMessage($mesg, 'errors');
+ $error++;
+ }
+
+ if (! $error)
+ {
+ $object=new Resource($db);
+ $object->ref=$ref;
+ $object->description=$description;
+ $object->fk_code_type_resource=$fk_code_type_resource;
+
+ $result=$object->create($user);
+ if ($result > 0)
+ {
+ // Creation OK
+ $db->commit();
+ setEventMessage($langs->trans('ResourceCreatedWithSuccess'));
+ Header("Location: card.php?id=" . $object->id);
+ return;
+ }
+ else
+ {
+ // Creation KO
+ setEventMessage($object->error, 'errors');
+ $action = '';
+ }
+ }
+ else
+ {
+ $action = '';
+ }
+}
+
+/***************************************************
+* VIEW
+*
+****************************************************/
+
+$form=new Form($db);
+$formresource = new FormResource($db);
+
+if ( !$action )
+{
+ $pagetitle=$langs->trans('AddResource');
+ llxHeader('',$pagetitle,'');
+ print_fiche_titre($pagetitle,'','resource.png@resource');
+
+ print '';
+}
+
+
+// End of page
+llxFooter();
+$db->close();
+?>
diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php
new file mode 100755
index 00000000000..1ecf827fe39
--- /dev/null
+++ b/htdocs/resource/card.php
@@ -0,0 +1,252 @@
+
+ *
+ * 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 resource/card.php
+ * \ingroup resource
+ * \brief Page to manage resource object
+ */
+
+
+// Change this following line to use the correct relative path (../, ../../, etc)
+$res=0;
+$res=@include("../main.inc.php"); // For root directory
+if (! $res) $res=@include("../../main.inc.php"); // For "custom" directory
+if (! $res) die("Include of main fails");
+
+require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
+require_once 'class/resource.class.php';
+require_once 'class/html.formresource.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
+
+// Load traductions files requiredby by page
+$langs->load("resource");
+$langs->load("companies");
+$langs->load("other");
+$langs->load("main");
+
+// Get parameters
+$id = GETPOST('id','int');
+$action = GETPOST('action','alpha');
+$ref = GETPOST('ref');
+$description = GETPOST('description');
+$fk_code_type_resource = GETPOST('fk_code_type_resource','alpha');
+
+// Protection if external user
+if ($user->societe_id > 0)
+{
+ accessforbidden();
+}
+
+if( ! $user->rights->resource->read)
+ accessforbidden();
+
+$object = new Resource($db);
+
+$hookmanager->initHooks(array('resource_card'));
+$parameters=array('resource_id'=>$id);
+$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+
+
+/*******************************************************************
+* ACTIONS
+*
+* Put here all code to do according to value of "action" parameter
+********************************************************************/
+
+if ($action == 'update' && ! $_POST["cancel"] && $user->rights->resource->write )
+{
+ $error=0;
+
+ if (empty($ref))
+ {
+ $error++;
+ $mesg='
';
+ }
+ }
+ }
+}
+
+llxFooter();
+
+$db->close();
diff --git a/htdocs/resource/img/object_resource.png b/htdocs/resource/img/object_resource.png
new file mode 100644
index 00000000000..55f2e1bf937
Binary files /dev/null and b/htdocs/resource/img/object_resource.png differ
diff --git a/htdocs/resource/img/resource.png b/htdocs/resource/img/resource.png
new file mode 100644
index 00000000000..7d5bbfa5a3d
Binary files /dev/null and b/htdocs/resource/img/resource.png differ
diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php
new file mode 100644
index 00000000000..3fde7b52999
--- /dev/null
+++ b/htdocs/resource/list.php
@@ -0,0 +1,175 @@
+
+ *
+ * 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 resource/index.php
+ * \ingroup resource
+ * \brief Page to manage resource objects
+ */
+
+
+// Change this following line to use the correct relative path (../, ../../, etc)
+$res=0;
+$res=@include("../main.inc.php"); // For root directory
+if (! $res) $res=@include("../../main.inc.php"); // For "custom" directory
+if (! $res) die("Include of main fails");
+
+require 'class/resource.class.php';
+
+// Load traductions files requiredby by page
+$langs->load("resource");
+$langs->load("companies");
+$langs->load("other");
+
+// Get parameters
+$id = GETPOST('id','int');
+$action = GETPOST('action','alpha');
+
+$lineid = GETPOST('lineid','int');
+$element = GETPOST('element','alpha');
+$element_id = GETPOST('element_id','int');
+$resource_id = GETPOST('resource_id','int');
+
+$sortorder = GETPOST('sortorder','alpha');
+$sortfield = GETPOST('sortfield','alpha');
+$page = GETPOST('page','int');
+
+$object = new Resource($db);
+
+$hookmanager->initHooks(array('resource_list'));
+
+$parameters=array();
+$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
+
+if (empty($sortorder)) $sortorder="DESC";
+if (empty($sortfield)) $sortfield="t.rowid";
+if (empty($arch)) $arch = 0;
+
+if ($page == -1) {
+ $page = 0 ;
+}
+
+$limit = $conf->liste_limit;
+$offset = $limit * $page ;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+
+if( ! $user->rights->resource->read)
+ accessforbidden();
+
+/***************************************************
+ * VIEW
+*
+* Put here all code to build page
+****************************************************/
+
+$pagetitle=$langs->trans('ResourcePageIndex');
+llxHeader('',$pagetitle,'');
+
+
+
+$form=new Form($db);
+
+print_fiche_titre($pagetitle,'','resource.png@resource');
+
+// Confirmation suppression resource line
+if ($action == 'delete_resource')
+{
+ print $form->formconfirm($_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id."&lineid=".$lineid,$langs->trans("DeleteResource"),$langs->trans("ConfirmDeleteResourceElement"),"confirm_delete_resource",'','',1);
+}
+
+// Load object list
+$ret = $object->fetch_all($sortorder, $sortfield, $limit, $offset);
+if($ret == -1) {
+ dol_print_error($db,$object->error);
+ exit;
+}
+if(!$ret) {
+ print '
';
+
+llxFooter();
+
+$db->close();
+
+
diff --git a/htdocs/theme/auguria/style.css.php b/htdocs/theme/auguria/style.css.php
index 78bdafc3e0d..a3b5150bb57 100644
--- a/htdocs/theme/auguria/style.css.php
+++ b/htdocs/theme/auguria/style.css.php
@@ -423,7 +423,7 @@ foreach($mainmenuusedarray as $val)
}
if ($found)
{
- print "/* A mainmenu entry but img file ".$val.".png not found, so we use a generic one */\n";
+ print "/* A mainmenu entry but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n";
print "div.mainmenu.".$val." {\n";
print " background-image: url(".$url.");\n";
print " height:28px;\n";
diff --git a/htdocs/theme/bureau2crea/style.css.php b/htdocs/theme/bureau2crea/style.css.php
index 5c367ffb798..00bb6e62a14 100644
--- a/htdocs/theme/bureau2crea/style.css.php
+++ b/htdocs/theme/bureau2crea/style.css.php
@@ -462,7 +462,7 @@ foreach($mainmenuusedarray as $val)
}
if ($found)
{
- print "/* A mainmenu entry but img file ".$val.".png not found, so we use a generic one */\n";
+ print "/* A mainmenu entry but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n";
print "div.mainmenu.".$val." {\n";
print " background-image: url(".$url.");\n";
print " height:28px;\n";
diff --git a/htdocs/theme/cameleo/style.css.php b/htdocs/theme/cameleo/style.css.php
index 5ac4a4cbb1c..ff6e3696d33 100644
--- a/htdocs/theme/cameleo/style.css.php
+++ b/htdocs/theme/cameleo/style.css.php
@@ -599,7 +599,7 @@ foreach($mainmenuusedarray as $val)
}
if ($url)
{
- print "/* A mainmenu entry but img file ".$val.".png not found, so we use a generic one */\n";
+ print "/* A mainmenu entry but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n";
print "div.mainmenu.".$val." {\n";
print " background-image: url(".$url.");\n";
print " height:28px;\n";
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index 63eea66a591..2f2622cd9c1 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -785,7 +785,7 @@ foreach($mainmenuusedarray as $val)
$url=dol_buildpath($path.'/theme/'.$theme.'/img/menus/generic'.$generic.".png",1);
$found=1;
if ($generic < 4) $generic++;
- print "/* A mainmenu entry but img file ".$val.".png not found, so we use a generic one */\n";
+ print "/* A mainmenu entry but img file ".$val.".png not found (check /".$val."/img/".$val.".png), so we use a generic one */\n";
}
if ($found)
{
diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php
index c478288c74e..c79c862146c 100644
--- a/htdocs/webservices/server_invoice.php
+++ b/htdocs/webservices/server_invoice.php
@@ -515,7 +515,7 @@ function createInvoice($authentication,$invoice)
$newobject->date=dol_stringtotime($invoice['date'],'dayrfc');
$newobject->note_private=$invoice['note_private'];
$newobject->note_public=$invoice['note_public'];
- $newobject->statut=$invoice['status'];
+ $newobject->statut=0; // We start with status draft
$newobject->fk_project=$invoice['project_id'];
$newobject->date_creation=$now;
@@ -551,7 +551,7 @@ function createInvoice($authentication,$invoice)
$error++;
}
- if ($newobject->statut == 1) // We want invoice validated
+ if ($invoice['status'] == 1) // We want invoice to have status validated
{
$result=$newobject->validate($fuser);
if ($result < 0)
diff --git a/htdocs/webservices/server_order.php b/htdocs/webservices/server_order.php
index e9e835d3fde..d70725b468f 100644
--- a/htdocs/webservices/server_order.php
+++ b/htdocs/webservices/server_order.php
@@ -392,7 +392,7 @@ function getOrder($authentication,$id='',$ref='',$ref_ext='')
'date_creation' => $invoice->date_creation?dol_print_date($invoice->date_creation,'dayhourrfc'):'',
'date_validation' => $invoice->date_validation?dol_print_date($invoice->date_creation,'dayhourrfc'):'',
'date_modification' => $invoice->datem?dol_print_date($invoice->datem,'dayhourrfc'):'',
-
+
'remise' => $order->remise,
'remise_percent' => $order->remise_percent,
'remise_absolue' => $order->remise_absolue,
@@ -407,7 +407,7 @@ function getOrder($authentication,$id='',$ref='',$ref_ext='')
'mode_reglement_id' => $order->mode_reglement_id,
'mode_reglement_code' => $order->mode_reglement_code,
'mode_reglement' => $order->mode_reglement,
-
+
'date_livraison' => $order->date_livraison,
'fk_delivery_address' => $order->fk_delivery_address,
@@ -617,7 +617,7 @@ function createOrder($authentication,$order)
dol_syslog("Function: createOrder login=".$authentication['login']." socid :".$order['socid']);
if ($authentication['entity']) $conf->entity=$authentication['entity'];
-
+
// Init and check authentication
$objectresp=array();
$errorcode='';$errorlabel='';
@@ -637,7 +637,7 @@ function createOrder($authentication,$order)
$newobject->date_lim_reglement=dol_stringtotime($order['date_due'],'dayrfc');
$newobject->note_private=$order['note_private'];
$newobject->note_public=$order['note_public'];
- $newobject->statut=0;
+ $newobject->statut=0; // We start with status draft
$newobject->facturee=$order['facturee'];
$newobject->fk_project=$order['project_id'];
$newobject->cond_reglement_id=$order['cond_reglement_id'];
@@ -679,7 +679,7 @@ function createOrder($authentication,$order)
}
- if ($order['status'] == 1) // We want order validated
+ if ($order['status'] == 1) // We want order to have status validated
{
dol_syslog("Webservice server_order:: order validation start", LOG_DEBUG);
$result=$newobject->valid($fuser);
@@ -689,7 +689,7 @@ function createOrder($authentication,$order)
$error++;
}
}
-
+
if ($result >= 0)
{
dol_syslog("Webservice server_order:: order creation & validation succeeded, commit", LOG_DEBUG);
@@ -704,7 +704,7 @@ function createOrder($authentication,$order)
$errorcode='KO';
$errorlabel=$newobject->error;
}
-
+
}
if ($error)
diff --git a/test/soapui/soap_createInvoice.xml b/test/soapui/soap_createInvoice.xml
new file mode 100644
index 00000000000..7665be64d81
--- /dev/null
+++ b/test/soapui/soap_createInvoice.xml
@@ -0,0 +1,36 @@
+
+
+
+
+ dolibarrkey
+ PRESTASHOP
+ admin
+ admin
+
+
+
+ WSTESTCREATEINVOICE1
+ 1
+ 2014-04-23 15:59:24
+ 0
+ Created from WS
+
+ 1
+
+
+
+ 0
+ Product
+ 66.05
+ 198.150000
+ 38.85
+ 237.000000
+ 19.600
+ 3
+ 1
+
+
+
+
+
+
\ No newline at end of file