[CORE] première partie des grosses modifications (#new_ask_price).

This commit is contained in:
phf 2015-01-27 16:53:27 +01:00
parent 6fee87ca56
commit aaacca9b13
19 changed files with 5283 additions and 204 deletions

File diff suppressed because it is too large Load Diff

View File

@ -37,14 +37,14 @@ require_once DOL_DOCUMENT_ROOT .'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT .'/margin/lib/margins.lib.php';
/**
* Class to manage proposals
* Class to manage price ask supplier
*/
class Propal extends CommonObject
class AskPriceSupplier extends CommonObject
{
public $element='propal';
public $table_element='propal';
public $table_element_line='propaldet';
public $fk_element='fk_propal';
public $element='askpricesupplier';
public $table_element='askpricesupplier';
public $table_element_line='askpricesupplierdet';
public $fk_element='fk_askpricesupplier';
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
/**
@ -128,33 +128,33 @@ class Propal extends CommonObject
*
* @param DoliDB $db Database handler
* @param int $socid Id third party
* @param int $propalid Id proposal
* @param int $askpricesupplierid Id askpricesupplier
*/
function __construct($db, $socid="", $propalid=0)
function __construct($db, $socid="", $askpricesupplierid=0)
{
global $conf,$langs;
$this->db = $db;
$this->socid = $socid;
$this->id = $propalid;
$this->id = $askpricesupplierid;
$this->products = array();
$this->remise = 0;
$this->remise_percent = 0;
$this->remise_absolue = 0;
$this->duree_validite=$conf->global->PROPALE_VALIDITY_DURATION;
$this->duree_validite=$conf->global->ASKPRICESUPPLIER_VALIDITY_DURATION;
$langs->load("propal");
$this->labelstatut[0]=(! empty($conf->global->PROPAL_STATUS_DRAFT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFT_LABEL : $langs->trans("PropalStatusDraft"));
$this->labelstatut[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATED_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATED_LABEL : $langs->trans("PropalStatusValidated"));
$this->labelstatut[2]=(! empty($conf->global->PROPAL_STATUS_SIGNED_LABEL) ? $conf->global->PROPAL_STATUS_SIGNED_LABEL : $langs->trans("PropalStatusSigned"));
$this->labelstatut[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNED_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNED_LABEL : $langs->trans("PropalStatusNotSigned"));
$this->labelstatut[4]=(! empty($conf->global->PROPAL_STATUS_BILLED_LABEL) ? $conf->global->PROPAL_STATUS_BILLED_LABEL : $langs->trans("PropalStatusBilled"));
$this->labelstatut_short[0]=(! empty($conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL) ? $conf->global->PROPAL_STATUS_DRAFTSHORT_LABEL : $langs->trans("PropalStatusDraftShort"));
$this->labelstatut_short[1]=(! empty($conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_VALIDATEDSHORT_LABEL : $langs->trans("Opened"));
$this->labelstatut_short[2]=(! empty($conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_SIGNEDSHORT_LABEL : $langs->trans("PropalStatusSignedShort"));
$this->labelstatut_short[3]=(! empty($conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_NOTSIGNEDSHORT_LABEL : $langs->trans("PropalStatusNotSignedShort"));
$this->labelstatut_short[4]=(! empty($conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL) ? $conf->global->PROPAL_STATUS_BILLEDSHORT_LABEL : $langs->trans("PropalStatusBilledShort"));
$langs->load("askpricesupplier");
$this->labelstatut[0]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_DRAFT_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_DRAFT_LABEL : $langs->trans("AskpricesupplierStatusDraft"));
$this->labelstatut[1]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_VALIDATED_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_VALIDATED_LABEL : $langs->trans("AskpricesupplierStatusValidated"));
$this->labelstatut[2]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_SIGNED_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_SIGNED_LABEL : $langs->trans("AskpricesupplierStatusSigned"));
$this->labelstatut[3]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_NOTSIGNED_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_NOTSIGNED_LABEL : $langs->trans("AskpricesupplierStatusNotSigned"));
$this->labelstatut[4]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_BILLED_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_BILLED_LABEL : $langs->trans("AskpricesupplierStatusBilled"));
$this->labelstatut_short[0]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_DRAFTSHORT_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_DRAFTSHORT_LABEL : $langs->trans("AskpricesupplierStatusDraftShort"));
$this->labelstatut_short[1]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_VALIDATEDSHORT_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_VALIDATEDSHORT_LABEL : $langs->trans("Opened"));
$this->labelstatut_short[2]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_SIGNEDSHORT_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_SIGNEDSHORT_LABEL : $langs->trans("AskpricesupplierStatusSignedShort"));
$this->labelstatut_short[3]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_NOTSIGNEDSHORT_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_NOTSIGNEDSHORT_LABEL : $langs->trans("AskpricesupplierStatusNotSignedShort"));
$this->labelstatut_short[4]=(! empty($conf->global->ASKPRICESUPPLIER_STATUS_BILLEDSHORT_LABEL) ? $conf->global->ASKPRICESUPPLIER_STATUS_BILLEDSHORT_LABEL : $langs->trans("AskpricesupplierStatusBilledShort"));
}
@ -199,7 +199,7 @@ class Propal extends CommonObject
$price = $prod->price;
}
$line = new PropaleLigne($this->db);
$line = new AskPriceSupplierLigne($this->db);
$line->fk_product=$idproduct;
$line->desc=$productdesc;
@ -239,8 +239,8 @@ class Propal extends CommonObject
return -5;
}
$propalligne=new PropaleLigne($this->db);
$propalligne->fk_propal=$this->id;
$propalligne=new AskPriceSupplierLigne($this->db);
$propalligne->fk_askpricesupplier=$this->id;
$propalligne->fk_remise_except=$remise->id;
$propalligne->desc=$remise->description; // Description ligne
$propalligne->tva_tx=$remise->tva_tx;
@ -324,7 +324,7 @@ class Propal extends CommonObject
{
global $mysoc;
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");
dol_syslog(get_class($this)."::addline askpricesupplierid=$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
@ -391,9 +391,9 @@ class Propal extends CommonObject
}
// Insert line
$this->line=new PropaleLigne($this->db);
$this->line=new AskPriceSupplierLigne($this->db);
$this->line->fk_propal=$this->id;
$this->line->fk_askpricesupplier=$this->id;
$this->line->label=$label;
$this->line->desc=$desc;
$this->line->qty=$qty;
@ -543,10 +543,10 @@ class Propal extends CommonObject
}
// Update line
$this->line=new PropaleLigne($this->db);
$this->line=new AskPriceSupplierLigne($this->db);
// Stock previous line records
$staticline=new PropaleLigne($this->db);
$staticline=new AskPriceSupplierLigne($this->db);
$staticline->fetch($rowid);
$this->line->oldline = $staticline;
@ -610,7 +610,7 @@ class Propal extends CommonObject
$this->update_price(1);
$this->fk_propal = $this->id;
$this->fk_askpricesupplier = $this->id;
$this->rowid = $rowid;
$this->db->commit();
@ -625,7 +625,7 @@ class Propal extends CommonObject
}
else
{
dol_syslog(get_class($this)."::updateline Erreur -2 Propal en mode incompatible pour cette action");
dol_syslog(get_class($this)."::updateline Erreur -2 Askpricesupplier en mode incompatible pour cette action");
return -2;
}
}
@ -641,7 +641,7 @@ class Propal extends CommonObject
{
if ($this->statut == 0)
{
$line=new PropaleLigne($this->db);
$line=new AskPriceSupplierLigne($this->db);
// For triggers
$line->fetch($lineid);
@ -720,7 +720,7 @@ class Propal extends CommonObject
$this->db->begin();
// Insert into database
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propal (";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."askpricesupplier (";
$sql.= "fk_soc";
$sql.= ", price";
$sql.= ", remise";
@ -779,12 +779,12 @@ class Propal extends CommonObject
$resql=$this->db->query($sql);
if ($resql)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."propal");
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."askpricesupplier");
if ($this->id)
{
$this->ref='(PROV'.$this->id.')';
$sql = 'UPDATE '.MAIN_DB_PREFIX."propal SET ref='".$this->ref."' WHERE rowid=".$this->id;
$sql = 'UPDATE '.MAIN_DB_PREFIX."askpricesupplier SET ref='".$this->ref."' WHERE rowid=".$this->id;
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql=$this->db->query($sql);
@ -853,7 +853,7 @@ class Propal extends CommonObject
// Set delivery address
if (! $error && $this->fk_delivery_address)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier";
$sql.= " SET fk_delivery_address = ".$this->fk_delivery_address;
$sql.= " WHERE ref = '".$this->ref."'";
$sql.= " AND entity = ".$conf->entity;
@ -890,7 +890,7 @@ class Propal extends CommonObject
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('PROPAL_CREATE',$user);
$result=$this->call_trigger('ASKPRICESUPPLIER_CREATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
@ -992,7 +992,7 @@ class Propal extends CommonObject
$this->id=0;
$this->statut=0;
if (empty($conf->global->PROPALE_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"))
if (empty($conf->global->ASKPRICESUPPLIER_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT ."/core/modules/askpricesupplier/".$conf->global->ASKPRICESUPPLIER_ADDON.".php"))
{
$this->error='ErrorSetupNotComplete';
return -1;
@ -1007,10 +1007,10 @@ class Propal extends CommonObject
if (empty($conf->global->MAIN_KEEP_REF_CUSTOMER_ON_CLONING)) $this->ref_client = '';
// Set ref
require_once DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.'.php';
$obj = $conf->global->PROPALE_ADDON;
$modPropale = new $obj;
$this->ref = $modPropale->getNextValue($objsoc,$this);
require_once DOL_DOCUMENT_ROOT ."/core/modules/askpricesupplier/".$conf->global->ASKPRICESUPPLIER_ADDON.'.php';
$obj = $conf->global->ASKPRICESUPPLIER_ADDON;
$modAskPriceSupplier = new $obj;
$this->ref = $modAskPriceSupplier->getNextValue($objsoc,$this);
// Create clone
$result=$this->create($user);
@ -1041,7 +1041,7 @@ class Propal extends CommonObject
}
// Call trigger
$result=$this->call_trigger('PROPAL_CLONE',$user);
$result=$this->call_trigger('ASKPRICESUPPLIER_CLONE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
@ -1184,13 +1184,13 @@ class Propal extends CommonObject
/*
* Lignes propales liees a un produit ou non
*/
$sql = "SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,";
$sql = "SELECT d.rowid, d.fk_askpricesupplier, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,";
$sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,";
$sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,';
$sql.= ' d.date_start, d.date_end';
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet as d";
$sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplierdet as d";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid";
$sql.= " WHERE d.fk_propal = ".$this->id;
$sql.= " WHERE d.fk_askpricesupplier = ".$this->id;
$sql.= " ORDER by d.rang";
$result = $this->db->query($sql);
@ -1203,10 +1203,10 @@ class Propal extends CommonObject
{
$objp = $this->db->fetch_object($result);
$line = new PropaleLigne($this->db);
$line = new AskPriceSupplierLigne($this->db);
$line->rowid = $objp->rowid;
$line->fk_propal = $objp->fk_propal;
$line->fk_askpricesupplier = $objp->fk_askpricesupplier;
$line->fk_parent_line = $objp->fk_parent_line;
$line->product_type = $objp->product_type;
$line->label = $objp->custom_label;
@ -1334,8 +1334,8 @@ class Propal extends CommonObject
$error=0;
$now=dol_now();
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate)))
if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->askpricesupplier->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->askpricesupplier->propal_advance->validate)))
{
$this->db->begin();
@ -1354,7 +1354,7 @@ class Propal extends CommonObject
}
$this->newref = $num;
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier";
$sql.= " SET ref = '".$num."',";
$sql.= " fk_statut = 1, date_valid='".$this->db->idate($now)."', fk_user_valid=".$user->id;
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
@ -1371,7 +1371,7 @@ class Propal extends CommonObject
if (! $error && ! $notrigger)
{
// Call trigger
$result=$this->call_trigger('PROPAL_VALIDATE',$user);
$result=$this->call_trigger('ASKPRICESUPPLIER_VALIDATE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
@ -1387,8 +1387,8 @@ class Propal extends CommonObject
// to not lose the linked files
$oldref = dol_sanitizeFileName($this->ref);
$newref = dol_sanitizeFileName($num);
$dirsource = $conf->propal->dir_output.'/'.$oldref;
$dirdest = $conf->propal->dir_output.'/'.$newref;
$dirsource = $conf->askpricesupplier->dir_output.'/'.$oldref;
$dirdest = $conf->askpricesupplier->dir_output.'/'.$newref;
if (file_exists($dirsource))
{
@ -1397,7 +1397,7 @@ class Propal extends CommonObject
{
dol_syslog("Rename ok");
// Rename docs starting with $oldref with $newref
$listoffiles=dol_dir_list($conf->propal->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/'));
$listoffiles=dol_dir_list($conf->askpricesupplier->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref,'/'));
foreach($listoffiles as $fileentry)
{
$dirsource=$fileentry['name'];
@ -1444,9 +1444,9 @@ class Propal extends CommonObject
return -1;
}
if (! empty($user->rights->propal->creer))
if (! empty($user->rights->askpricesupplier->creer))
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET datep = '".$this->db->idate($date)."'";
$sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier SET datep = '".$this->db->idate($date)."'";
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
dol_syslog(get_class($this)."::set_date", LOG_DEBUG);
@ -1475,7 +1475,7 @@ class Propal extends CommonObject
{
if (! empty($user->rights->propal->creer))
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fin_validite = ".($date_fin_validite!=''?"'".$this->db->idate($date_fin_validite)."'":'null');
$sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier SET fin_validite = ".($date_fin_validite!=''?"'".$this->db->idate($date_fin_validite)."'":'null');
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
if ($this->db->query($sql) )
{
@ -1501,7 +1501,7 @@ class Propal extends CommonObject
{
if (! empty($user->rights->propal->creer))
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier ";
$sql.= " SET date_livraison = ".($date_livraison!=''?"'".$this->db->idate($date_livraison)."'":'null');
$sql.= " WHERE rowid = ".$this->id;
@ -1530,7 +1530,7 @@ class Propal extends CommonObject
{
if (! empty($user->rights->propal->creer))
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier ";
$sql.= " SET fk_availability = '".$id."'";
$sql.= " WHERE rowid = ".$this->id;
@ -1559,7 +1559,7 @@ class Propal extends CommonObject
{
if (! empty($user->rights->propal->creer))
{
$sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier ";
$sql.= " SET fk_input_reason = '".$id."'";
$sql.= " WHERE rowid = ".$this->id;
@ -1586,11 +1586,11 @@ class Propal extends CommonObject
*/
function set_ref_client($user, $ref_client)
{
if (! empty($user->rights->propal->creer))
if (! empty($user->rights->askpricesupplier->creer))
{
dol_syslog('Propale::set_ref_client this->id='.$this->id.', ref_client='.$ref_client);
dol_syslog('AskPriceSupplier::set_ref_client this->id='.$this->id.', ref_client='.$ref_client);
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET ref_client = '.(empty($ref_client) ? 'NULL' : '\''.$this->db->escape($ref_client).'\'');
$sql = 'UPDATE '.MAIN_DB_PREFIX.'askpricesupplier SET ref_client = '.(empty($ref_client) ? 'NULL' : '\''.$this->db->escape($ref_client).'\'');
$sql.= ' WHERE rowid = '.$this->id;
if ($this->db->query($sql) )
{
@ -1600,7 +1600,7 @@ class Propal extends CommonObject
else
{
$this->error=$this->db->error();
dol_syslog('Propale::set_ref_client Erreur '.$this->error.' - '.$sql);
dol_syslog('AskPriceSupplier::set_ref_client Erreur '.$this->error.' - '.$sql);
return -2;
}
}
@ -1625,7 +1625,7 @@ class Propal extends CommonObject
{
$remise = price2num($remise);
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET remise_percent = ".$remise;
$sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier SET remise_percent = ".$remise;
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
if ($this->db->query($sql) )
@ -1658,7 +1658,7 @@ class Propal extends CommonObject
{
$remise = price2num($remise);
$sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
$sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier ";
$sql.= " SET remise_absolue = ".$remise;
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
@ -1694,7 +1694,7 @@ class Propal extends CommonObject
$this->statut = $statut;
$error=0;
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier";
$sql.= " SET fk_statut = ".$this->statut.",";
if (! empty($note)) $sql.= " note_private = '".$this->db->escape($note)."',";
$sql.= " date_cloture=NULL, fk_user_cloture=NULL";
@ -1712,7 +1712,7 @@ class Propal extends CommonObject
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('PROPAL_REOPEN',$user);
$result=$this->call_trigger('ASKPRICESUPPLIER_REOPEN',$user);
if ($result < 0) { $error++; }
// End call triggers
}
@ -1758,20 +1758,20 @@ class Propal extends CommonObject
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier";
$sql.= " SET fk_statut = ".$statut.", note_private = '".$this->db->escape($note)."', date_cloture='".$this->db->idate($now)."', fk_user_cloture=".$user->id;
$sql.= " WHERE rowid = ".$this->id;
$resql=$this->db->query($sql);
if ($resql)
{
$modelpdf=$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED?$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED:$this->modelpdf;
$trigger_name='PROPAL_CLOSE_REFUSED';
$modelpdf=$conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_CLOSED?$conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_CLOSED:$this->modelpdf;
$trigger_name='ASKPRICESUPPLIER_CLOSE_REFUSED';
if ($statut == 2)
{
$trigger_name='PROPAL_CLOSE_SIGNED';
$modelpdf=$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL?$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL:$this->modelpdf;
$trigger_name='ASKPRICESUPPLIER_CLOSE_SIGNED';
$modelpdf=$conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_TOBILL?$conf->global->ASKPRICESUPPLIER_ADDON_PDF_ODT_TOBILL:$this->modelpdf;
// The connected company is classified as a client
$soc=new Societe($this->db);
@ -1787,7 +1787,7 @@ class Propal extends CommonObject
}
if ($statut == 4)
{
$trigger_name='PROPAL_CLASSIFY_BILLED';
$trigger_name='ASKPRICESUPPLIER_CLASSIFY_BILLED';
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
@ -1835,7 +1835,7 @@ class Propal extends CommonObject
*/
function classifyBilled()
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal SET fk_statut = 4';
$sql = 'UPDATE '.MAIN_DB_PREFIX.'askpricesupplier SET fk_statut = 4';
$sql .= ' WHERE rowid = '.$this->id.' AND fk_statut > 0 ;';
if ($this->db->query($sql) )
{
@ -1869,7 +1869,7 @@ class Propal extends CommonObject
{
global $conf,$langs;
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 0";
$sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplier SET fk_statut = 0";
$sql.= " WHERE rowid = ".$this->id;
if ($this->db->query($sql))
@ -1908,7 +1908,7 @@ class Propal extends CommonObject
$sql.= " p.rowid as propalid, p.fk_statut, p.total_ht, p.ref, p.remise, ";
$sql.= " p.datep as dp, p.fin_validite as datelimite";
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."askpricesupplier as p, ".MAIN_DB_PREFIX."c_propalst as c";
if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE p.entity = ".$conf->entity;
$sql.= " AND p.fk_soc = s.rowid";
@ -1944,7 +1944,7 @@ class Propal extends CommonObject
}
else
{
$ga[$i]['id'] = $obj->propalid;
$ga[$i]['id'] = $obj->askpricesupplierid;
$ga[$i]['ref'] = $obj->ref;
$ga[$i]['name'] = $obj->name;
}
@ -2075,17 +2075,17 @@ class Propal extends CommonObject
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('PROPAL_DELETE',$user);
$result=$this->call_trigger('ASKPRICESUPPLIER_DELETE',$user);
if ($result < 0) { $error++; }
// End call triggers
}
if (! $error)
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."askpricesupplierdet WHERE fk_askpricesupplier = ".$this->id;
if ($this->db->query($sql))
{
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id;
$sql = "DELETE FROM ".MAIN_DB_PREFIX."askpricesupplier WHERE rowid = ".$this->id;
if ($this->db->query($sql))
{
// Delete linked object
@ -2187,10 +2187,10 @@ class Propal extends CommonObject
*/
function availability($availability_id)
{
dol_syslog('Propale::availability('.$availability_id.')');
dol_syslog('AskPriceSupplier::availability('.$availability_id.')');
if ($this->statut >= 0)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal';
$sql = 'UPDATE '.MAIN_DB_PREFIX.'askpricesupplier';
$sql .= ' SET fk_availability = '.$availability_id;
$sql .= ' WHERE rowid='.$this->id;
if ( $this->db->query($sql) )
@ -2200,14 +2200,14 @@ class Propal extends CommonObject
}
else
{
dol_syslog('Propale::availability Erreur '.$sql.' - '.$this->db->error());
dol_syslog('AskPriceSupplier::availability Erreur '.$sql.' - '.$this->db->error());
$this->error=$this->db->error();
return -1;
}
}
else
{
dol_syslog('Propale::availability, etat propale incompatible');
dol_syslog('AskPriceSupplier::availability, etat propale incompatible');
$this->error='Etat propale incompatible '.$this->statut;
return -2;
}
@ -2221,10 +2221,10 @@ class Propal extends CommonObject
*/
function demand_reason($demand_reason_id)
{
dol_syslog('Propale::demand_reason('.$demand_reason_id.')');
dol_syslog('AskPriceSupplier::demand_reason('.$demand_reason_id.')');
if ($this->statut >= 0)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX.'propal';
$sql = 'UPDATE '.MAIN_DB_PREFIX.'askpricesupplier';
$sql .= ' SET fk_input_reason = '.$demand_reason_id;
$sql .= ' WHERE rowid='.$this->id;
if ( $this->db->query($sql) )
@ -2234,14 +2234,14 @@ class Propal extends CommonObject
}
else
{
dol_syslog('Propale::demand_reason Erreur '.$sql.' - '.$this->db->error());
dol_syslog('AskPriceSupplier::demand_reason Erreur '.$sql.' - '.$this->db->error());
$this->error=$this->db->error();
return -1;
}
}
else
{
dol_syslog('Propale::demand_reason, etat propale incompatible');
dol_syslog('AskPriceSupplier::demand_reason, etat propale incompatible');
$this->error='Etat propale incompatible '.$this->statut;
return -2;
}
@ -2259,7 +2259,7 @@ class Propal extends CommonObject
$sql = "SELECT c.rowid, ";
$sql.= " c.datec, c.date_valid as datev, c.date_cloture as dateo,";
$sql.= " c.fk_user_author, c.fk_user_valid, c.fk_user_cloture";
$sql.= " FROM ".MAIN_DB_PREFIX."propal as c";
$sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier as c";
$sql.= " WHERE c.rowid = ".$id;
$result = $this->db->query($sql);
@ -2327,7 +2327,7 @@ class Propal extends CommonObject
function LibStatut($statut,$mode=1)
{
global $langs;
$langs->load("propal");
$langs->load("askpricesupplier");
if ($statut==0) $statuttrans='statut0';
if ($statut==1) $statuttrans='statut1';
@ -2361,7 +2361,7 @@ class Propal extends CommonObject
$clause = " WHERE";
$sql = "SELECT p.rowid, p.ref, p.datec as datec, p.fin_validite as datefin";
$sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier as p";
if (!$user->rights->societe->client->voir && !$user->societe_id)
{
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON p.fk_soc = sc.fk_soc";
@ -2376,8 +2376,8 @@ class Propal extends CommonObject
$resql=$this->db->query($sql);
if ($resql)
{
if ($mode == 'opened') $delay_warning=$conf->propal->cloture->warning_delay;
if ($mode == 'signed') $delay_warning=$conf->propal->facturation->warning_delay;
if ($mode == 'opened') $delay_warning=$conf->askpricesupplier->cloture->warning_delay;
if ($mode == 'signed') $delay_warning=$conf->askpricesupplier->facturation->warning_delay;
// This assignment in condition is not a bug. It allows walking the results.
while ($obj=$this->db->fetch_object($resql))
@ -2456,7 +2456,7 @@ class Propal extends CommonObject
$xnbp = 0;
while ($xnbp < $nbp)
{
$line=new PropaleLigne($this->db);
$line=new AskPriceSupplierLigne($this->db);
$line->desc=$langs->trans("Description")." ".$xnbp;
$line->qty=1;
$line->subprice=100;
@ -2505,7 +2505,7 @@ class Propal extends CommonObject
$clause = "WHERE";
$sql = "SELECT count(p.rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
$sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON p.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->societe_id)
{
@ -2545,20 +2545,20 @@ class Propal extends CommonObject
function getNextNumRef($soc)
{
global $conf, $db, $langs;
$langs->load("propal");
$langs->load("askpricesupplier");
if (! empty($conf->global->PROPALE_ADDON))
if (! empty($conf->global->ASKPRICESUPPLIER_ADDON))
{
$mybool=false;
$file = $conf->global->PROPALE_ADDON.".php";
$classname = $conf->global->PROPALE_ADDON;
$file = $conf->global->ASKPRICESUPPLIER_ADDON.".php";
$classname = $conf->global->ASKPRICESUPPLIER_ADDON;
// Include file with class
$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
foreach ($dirmodels as $reldir) {
$dir = dol_buildpath($reldir."core/modules/propale/");
$dir = dol_buildpath($reldir."core/modules/askpricesupplier/");
// Load file with numbering class (if found)
$mybool|=@include_once $dir.$file;
@ -2606,25 +2606,25 @@ class Propal extends CommonObject
global $langs;
$result='';
$label=$langs->trans("ShowPropal").': '.$this->ref;
$label=$langs->trans("ShowAskpricesupplier").': '.$this->ref;
if (! empty($this->ref_client))
$label.= '<br>'.$langs->trans('RefCustomer').': '.$this->ref_client;
$linkclose = '" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
if ($option == '') {
$lien = '<a href="'.DOL_URL_ROOT.'/comm/propal.php?id='.$this->id. $get_params .$linkclose;
$lien = '<a href="'.DOL_URL_ROOT.'/comm/askpricesupplier.php?id='.$this->id. $get_params .$linkclose;
}
if ($option == 'compta') { // deprecated
$lien = '<a href="'.DOL_URL_ROOT.'/comm/propal.php?id='.$this->id. $get_params .$linkclose;
$lien = '<a href="'.DOL_URL_ROOT.'/comm/askpricesupplier.php?id='.$this->id. $get_params .$linkclose;
}
if ($option == 'expedition') {
$lien = '<a href="'.DOL_URL_ROOT.'/expedition/propal.php?id='.$this->id. $get_params .$linkclose;
$lien = '<a href="'.DOL_URL_ROOT.'/expedition/askpricesupplier.php?id='.$this->id. $get_params .$linkclose;
}
if ($option == 'document') {
$lien = '<a href="'.DOL_URL_ROOT.'/comm/propal/document.php?id='.$this->id. $get_params .$linkclose;
$lien = '<a href="'.DOL_URL_ROOT.'/comm/askpricesupplier/document.php?id='.$this->id. $get_params .$linkclose;
}
$lienfin='</a>';
$picto='propal';
$picto='askpricesupplier';
if ($withpicto)
@ -2648,9 +2648,9 @@ class Propal extends CommonObject
$sql.= ' pt.date_start, pt.date_end, pt.product_type, pt.rang, pt.fk_parent_line,';
$sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,';
$sql.= ' p.description as product_desc';
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
$sql.= ' FROM '.MAIN_DB_PREFIX.'askpricesupplierdet as pt';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid';
$sql.= ' WHERE pt.fk_propal = '.$this->id;
$sql.= ' WHERE pt.fk_askpricesupplier = '.$this->id;
$sql.= ' ORDER BY pt.rang ASC, pt.rowid';
dol_syslog(get_class($this).'::getLinesArray', LOG_DEBUG);
@ -2722,14 +2722,14 @@ class Propal extends CommonObject
{
global $conf,$user,$langs;
$langs->load("propale");
$langs->load("askpricesupplier");
// Positionne le modele sur le nom du modele a utiliser
if (! dol_strlen($modele))
{
if (! empty($conf->global->PROPALE_ADDON_PDF))
if (! empty($conf->global->ASKPRICESUPPLIER_ADDON_PDF))
{
$modele = $conf->global->PROPALE_ADDON_PDF;
$modele = $conf->global->ASKPRICESUPPLIER_ADDON_PDF;
}
else
{
@ -2737,7 +2737,7 @@ class Propal extends CommonObject
}
}
$modelpath = "core/modules/propale/doc/";
$modelpath = "core/modules/askpricesupplier/doc/";
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
@ -2747,22 +2747,22 @@ class Propal extends CommonObject
/**
* \class PropaleLigne
* \brief Class to manage commercial proposal lines
* \class AskPriceSupplierLigne
* \brief Class to manage price ask supplier lines
*/
class PropaleLigne extends CommonObject
class AskPriceSupplierLigne extends CommonObject
{
var $db;
var $error;
public $element='propaldet';
public $table_element='propaldet';
public $element='askpricesupplierdet';
public $table_element='askpricesupplierdet';
var $oldline;
// From llx_propaldet
var $rowid;
var $fk_propal;
var $fk_askpricesupplier;
var $fk_parent_line;
var $desc; // Description ligne
var $fk_product; // Id produit predefini
@ -2833,13 +2833,13 @@ class PropaleLigne extends CommonObject
*/
function fetch($rowid)
{
$sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,';
$sql = 'SELECT pd.rowid, pd.fk_askpricesupplier, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,';
$sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,';
$sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,';
$sql.= ' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,';
$sql.= ' p.ref as product_ref, p.label as product_label, p.description as product_desc,';
$sql.= ' pd.date_start, pd.date_end, pd.product_type';
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pd';
$sql.= ' FROM '.MAIN_DB_PREFIX.'askpricesupplierdet as pd';
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pd.fk_product = p.rowid';
$sql.= ' WHERE pd.rowid = '.$rowid;
@ -2849,7 +2849,7 @@ class PropaleLigne extends CommonObject
$objp = $this->db->fetch_object($result);
$this->rowid = $objp->rowid;
$this->fk_propal = $objp->fk_propal;
$this->fk_askpricesupplier = $objp->fk_askpricesupplier;
$this->fk_parent_line = $objp->fk_parent_line;
$this->label = $objp->custom_label;
$this->desc = $objp->description;
@ -2939,14 +2939,14 @@ class PropaleLigne extends CommonObject
$this->db->begin();
// Insert line into database
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'propaldet';
$sql.= ' (fk_propal, fk_parent_line, label, description, fk_product, product_type,';
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'askpricesupplierdet';
$sql.= ' (fk_askpricesupplier, fk_parent_line, label, description, fk_product, product_type,';
$sql.= ' fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,';
$sql.= ' subprice, remise_percent, ';
$sql.= ' info_bits, ';
$sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang,';
$sql.= ' date_start, date_end)';
$sql.= " VALUES (".$this->fk_propal.",";
$sql.= " VALUES (".$this->fk_askpricesupplier.",";
$sql.= " ".($this->fk_parent_line>0?"'".$this->fk_parent_line."'":"null").",";
$sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").",";
$sql.= " '".$this->db->escape($this->desc)."',";
@ -2979,7 +2979,7 @@ class PropaleLigne extends CommonObject
$resql=$this->db->query($sql);
if ($resql)
{
$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'propaldet');
$this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'askpricesupplierdet');
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
{
@ -2994,7 +2994,7 @@ class PropaleLigne extends CommonObject
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('LINEPROPAL_INSERT',$user);
$result=$this->call_trigger('LINEASKPRICESUPPLIER_INSERT',$user);
if ($result < 0)
{
$this->db->rollback();
@ -3026,8 +3026,8 @@ class PropaleLigne extends CommonObject
$error=0;
$this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE rowid = ".$this->rowid;
dol_syslog("PropaleLigne::delete", LOG_DEBUG);
$sql = "DELETE FROM ".MAIN_DB_PREFIX."askpricesupplierdet WHERE rowid = ".$this->rowid;
dol_syslog("AskPriceSupplierLigne::delete", LOG_DEBUG);
if ($this->db->query($sql) )
{
@ -3044,7 +3044,7 @@ class PropaleLigne extends CommonObject
}
// Call trigger
$result=$this->call_trigger('LINEPROPAL_DELETE',$user);
$result=$this->call_trigger('LINEASKPRICESUPLLIER_DELETE',$user);
if ($result < 0)
{
$this->db->rollback();
@ -3105,7 +3105,7 @@ class PropaleLigne extends CommonObject
$this->db->begin();
// Mise a jour ligne en base
$sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET";
$sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplierdet SET";
$sql.= " description='".$this->db->escape($this->desc)."'";
$sql.= " , label=".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null");
$sql.= " , product_type=".$this->product_type;
@ -3154,7 +3154,7 @@ class PropaleLigne extends CommonObject
if (! $notrigger)
{
// Call trigger
$result=$this->call_trigger('LINEPROPAL_UPDATE',$user);
$result=$this->call_trigger('LINEASKPRICESUPPLIER_UPDATE',$user);
if ($result < 0)
{
$this->db->rollback();
@ -3185,13 +3185,13 @@ class PropaleLigne extends CommonObject
$this->db->begin();
// Mise a jour ligne en base
$sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET";
$sql = "UPDATE ".MAIN_DB_PREFIX."askpricesupplierdet SET";
$sql.= " total_ht=".price2num($this->total_ht,'MT')."";
$sql.= ",total_tva=".price2num($this->total_tva,'MT')."";
$sql.= ",total_ttc=".price2num($this->total_ttc,'MT')."";
$sql.= " WHERE rowid = ".$this->rowid;
dol_syslog("PropaleLigne::update_total", LOG_DEBUG);
dol_syslog("AskPriceSupplierLigne::update_total", LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)

View File

@ -25,9 +25,9 @@
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT .'/comm/propal/class/propal.class.php';
require_once DOL_DOCUMENT_ROOT .'/comm/askpricesupplier/class/askpricesupplier.class.php';
$langs->load("propal");
$langs->load("askpricesupplier");
$langs->load("companies");
// Security check
@ -37,22 +37,22 @@ if (isset($user->societe_id) && $user->societe_id > 0)
$action = '';
$socid = $user->societe_id;
}
$result = restrictedArea($user, 'propal');
$result = restrictedArea($user, 'askpricesupplier');
/*
* View
*/
$now=dol_now();
$propalstatic=new Propal($db);
$askpricesupplierstatic=new AskPriceSupplier($db);
$companystatic=new Societe($db);
$form = new Form($db);
$formfile = new FormFile($db);
$help_url="EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo_Presupuestos";
llxHeader("",$langs->trans("ProspectionArea"),$help_url);
llxHeader("",$langs->trans("AskPriceSupplierArea"),$help_url);
print_fiche_titre($langs->trans("ProspectionArea"));
print_fiche_titre($langs->trans("AskPriceSupplierArea"));
//print '<table width="100%" class="notopnoleftnoright">';
//print '<tr><td valign="top" width="30%" class="notopnoleft">';
@ -64,9 +64,9 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
*/
$var=false;
print '<table class="noborder nohover" width="100%">';
print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal/list.php">';
print '<form method="post" action="'.DOL_URL_ROOT.'/comm/askpricesupplier/list.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchPropal").'</td></tr>';
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchRequest").'</td></tr>';
print '<tr '.$bc[$var].'><td>';
print $langs->trans("Ref").':</td><td><input type="text" class="flat" name="sref" size=18></td><td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print '<tr '.$bc[$var].'><td class="nowrap">'.$langs->trans("Other").':</td><td><input type="text" class="flat" name="sall" size="18"></td>';
@ -80,7 +80,7 @@ print "</form></table><br>\n";
$sql = "SELECT count(p.rowid), p.fk_statut";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."propal as p";
$sql.= ", ".MAIN_DB_PREFIX."askpricesupplier as p";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE p.fk_soc = s.rowid";
$sql.= " AND p.entity = ".$conf->entity;
@ -116,17 +116,17 @@ if ($resql)
$db->free($resql);
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("Proposals").'</td></tr>'."\n";
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("CommRequests").'</td></tr>'."\n";
$var=true;
$listofstatus=array(0,1,2,3,4);
foreach ($listofstatus as $status)
{
$dataseries[]=array('label'=>$propalstatic->LibStatut($status,1),'data'=>(isset($vals[$status])?(int) $vals[$status]:0));
$dataseries[]=array('label'=>$askpricesupplierstatic->LibStatut($status,1),'data'=>(isset($vals[$status])?(int) $vals[$status]:0));
if (! $conf->use_javascript_ajax)
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td>'.$propalstatic->LibStatut($status,0).'</td>';
print '<td>'.$askpricesupplierstatic->LibStatut($status,0).'</td>';
print '<td align="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status])?$vals[$status]:0).'</a></td>';
print "</tr>\n";
}
@ -155,7 +155,7 @@ else
if (! empty($conf->propal->enabled))
{
$sql = "SELECT c.rowid, c.ref, s.nom as socname, s.rowid as socid, s.canvas, s.client";
$sql.= " FROM ".MAIN_DB_PREFIX."propal as c";
$sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier as c";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.rowid";
@ -169,8 +169,8 @@ if (! empty($conf->propal->enabled))
{
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="2">'.$langs->trans("DraftPropals").'</td></tr>';
$langs->load("propal");
print '<td colspan="2">'.$langs->trans("DraftRequests").'</td></tr>';
$langs->load("askpricesupplier");
$num = $db->num_rows($resql);
if ($num)
{
@ -182,9 +182,9 @@ if (! empty($conf->propal->enabled))
$obj = $db->fetch_object($resql);
print "<tr ".$bc[$var].">";
$propalstatic->id=$obj->rowid;
$propalstatic->ref=$obj->ref;
print '<td class="nowrap">'.$propalstatic->getNomUrl(1).'</td>';
$askpricesupplierstatic->id=$obj->rowid;
$askpricesupplierstatic->ref=$obj->ref;
print '<td class="nowrap">'.$askpricesupplierstatic->getNomUrl(1).'</td>';
$companystatic->id=$obj->socid;
$companystatic->name=$obj->socname;
@ -213,7 +213,7 @@ $max=5;
$sql = "SELECT c.rowid, c.ref, c.fk_statut, s.nom as socname, s.rowid as socid, s.canvas, s.client,";
$sql.= " date_cloture as datec";
$sql.= " FROM ".MAIN_DB_PREFIX."propal as c";
$sql.= " FROM ".MAIN_DB_PREFIX."askpricesupplier as c";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.rowid";
@ -229,7 +229,7 @@ if ($resql)
{
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="4">'.$langs->trans("LastModifiedProposals",$max).'</td></tr>';
print '<td colspan="4">'.$langs->trans("LastModifiedRequests",$max).'</td></tr>';
$num = $db->num_rows($resql);
if ($num)
@ -244,12 +244,12 @@ if ($resql)
print "<tr ".$bc[$var].">";
print '<td width="20%" class="nowrap">';
$propalstatic->id=$obj->rowid;
$propalstatic->ref=$obj->ref;
$askpricesupplierstatic->id=$obj->rowid;
$askpricesupplierstatic->ref=$obj->ref;
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td width="96" class="nobordernopadding nowrap">';
print $propalstatic->getNomUrl(1);
print $askpricesupplierstatic->getNomUrl(1);
print '</td>';
print '<td width="16" class="nobordernopadding nowrap">';
@ -260,7 +260,7 @@ if ($resql)
$filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir);
print $formfile->getDocumentsLink($askpricesupplierstatic->element, $filename, $filedir);
print '</td></tr></table>';
print '</td>';
@ -272,7 +272,7 @@ if ($resql)
print '<td>'.$companystatic->getNomUrl(1,'customer').'</td>';
print '<td>'.dol_print_date($db->jdate($obj->datec),'day').'</td>';
print '<td align="right">'.$propalstatic->LibStatut($obj->fk_statut,5).'</td>';
print '<td align="right">'.$askpricesupplierstatic->LibStatut($obj->fk_statut,5).'</td>';
print '</tr>';
$i++;
}
@ -285,15 +285,15 @@ else dol_print_error($db);
/*
* Opened proposals
*/
if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
if (! empty($conf->askpricesupplier->enabled) && $user->rights->askpricesupplier->lire)
{
$langs->load("propal");
$langs->load("askpricesupplier");
$now=dol_now();
$sql = "SELECT s.nom as socname, s.rowid as socid, s.canvas, s.client, p.rowid as propalid, p.total as total_ttc, p.total_ht, p.ref, p.fk_statut, p.datep as dp, p.fin_validite as dfv";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."propal as p";
$sql.= ", ".MAIN_DB_PREFIX."askpricesupplier as p";
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE p.fk_soc = s.rowid";
$sql.= " AND p.entity = ".$conf->entity;
@ -313,7 +313,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
$var=true;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="5">'.$langs->trans("ProposalsOpened").' <a href="'.DOL_URL_ROOT.'/comm/propal/list.php?viewstatut=1"><span class="badge">'.$num.'</span></a></td></tr>';
print '<tr class="liste_titre"><td colspan="5">'.$langs->trans("RequestsOpened").' <a href="'.DOL_URL_ROOT.'/comm/askpricesupplier/list.php?viewstatut=1"><span class="badge">'.$num.'</span></a></td></tr>';
$nbofloop=min($num, (empty($conf->global->MAIN_MAXLIST_OVERLOAD)?500:$conf->global->MAIN_MAXLIST_OVERLOAD));
while ($i < $nbofloop)
@ -325,21 +325,21 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
// Ref
print '<td class="nowrap" width="140">';
$propalstatic->id=$obj->propalid;
$propalstatic->ref=$obj->ref;
$askpricesupplierstatic->id=$obj->propalid;
$askpricesupplierstatic->ref=$obj->ref;
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td class="nobordernopadding nowrap">';
print $propalstatic->getNomUrl(1);
print $askpricesupplierstatic->getNomUrl(1);
print '</td>';
print '<td width="18" class="nobordernopadding nowrap">';
if ($db->jdate($obj->dfv) < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
if ($db->jdate($obj->dfv) < ($now - $conf->askpricesupplier->cloture->warning_delay)) print img_warning($langs->trans("Late"));
print '</td>';
print '<td width="16" align="center" class="nobordernopadding">';
$filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->propalid;
print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir);
$filedir=$conf->askpricesupplier->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->askpricesupplierid;
print $formfile->getDocumentsLink($askpricesupplierstatic->element, $filename, $filedir);
print '</td></tr></table>';
print "</td>";
@ -353,7 +353,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propale->lire)
print '<td align="right">';
print dol_print_date($db->jdate($obj->dp),'day').'</td>'."\n";
print '<td align="right">'.price($obj->total_ttc).'</td>';
print '<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut,3).'</td>'."\n";
print '<td align="center" width="14">'.$askpricesupplierstatic->LibStatut($obj->fk_statut,3).'</td>'."\n";
print '</tr>'."\n";
$i++;
$total += $obj->total_ttc;
@ -412,12 +412,12 @@ if (! empty($conf->propal->enabled))
print "<tr ".$bc[$var].">";
print '<td class="nowrap">';
$propalstatic->id=$obj->rowid;
$propalstatic->ref=$obj->ref;
$askpricesupplierstatic->id=$obj->rowid;
$askpricesupplierstatic->ref=$obj->ref;
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td width="96" class="nobordernopadding nowrap">';
print $propalstatic->getNomUrl(1);
print $askpricesupplierstatic->getNomUrl(1);
print '</td>';
print '<td width="16" class="nobordernopadding nowrap">';
@ -428,14 +428,14 @@ if (! empty($conf->propal->enabled))
$filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir);
print $formfile->getDocumentsLink($askpricesupplierstatic->element, $filename, $filedir);
print '</td></tr></table>';
print '</td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->name,24).'</a></td>';
print '<td align="right">'.$propalstatic->LibStatut($obj->fk_statut,$obj->facture,5).'</td>';
print '<td align="right">'.$askpricesupplierstatic->LibStatut($obj->fk_statut,$obj->facture,5).'</td>';
print '</tr>';
$i++;
@ -484,12 +484,12 @@ if (! empty($conf->propal->enabled))
print "<tr ".$bc[$var].">";
print '<td width="20%" class="nowrap">';
$propalstatic->id=$obj->rowid;
$propalstatic->ref=$obj->ref;
$askpricesupplierstatic->id=$obj->rowid;
$askpricesupplierstatic->ref=$obj->ref;
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td width="96" class="nobordernopadding nowrap">';
print $propalstatic->getNomUrl(1);
print $askpricesupplierstatic->getNomUrl(1);
print '</td>';
print '<td width="16" class="nobordernopadding nowrap">';
@ -500,14 +500,14 @@ if (! empty($conf->propal->enabled))
$filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($propalstatic->element, $filename, $filedir);
print $formfile->getDocumentsLink($askpricesupplierstatic->element, $filename, $filedir);
print '</td></tr></table>';
print '</td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->name.'</a></td>';
print '<td align="right">'.$propalstatic->LibStatut($obj->fk_statut,$obj->facture,5).'</td>';
print '<td align="right">'.$askpricesupplierstatic->LibStatut($obj->fk_statut,$obj->facture,5).'</td>';
print '</tr>';
$i++;

View File

@ -0,0 +1,58 @@
CREATE TABLE `llx_askpricesupplier` (
`rowid` int(11) NOT NULL AUTO_INCREMENT,
`ref` varchar(30) NOT NULL,
`entity` int(11) NOT NULL DEFAULT '1',
`ref_ext` varchar(255) DEFAULT NULL,
`ref_int` varchar(255) DEFAULT NULL,
`ref_client` varchar(255) DEFAULT NULL,
`fk_soc` int(11) DEFAULT NULL,
`fk_projet` int(11) DEFAULT NULL,
`tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`datec` datetime DEFAULT NULL,
`datep` date DEFAULT NULL,
`fin_validite` datetime DEFAULT NULL,
`date_valid` datetime DEFAULT NULL,
`date_cloture` datetime DEFAULT NULL,
`fk_user_author` int(11) DEFAULT NULL,
`fk_user_modif` int(11) DEFAULT NULL,
`fk_user_valid` int(11) DEFAULT NULL,
`fk_user_cloture` int(11) DEFAULT NULL,
`fk_statut` smallint(6) NOT NULL DEFAULT '0',
`price` double DEFAULT '0',
`remise_percent` double DEFAULT '0',
`remise_absolue` double DEFAULT '0',
`remise` double DEFAULT '0',
`total_ht` double(24,8) DEFAULT '0.00000000',
`tva` double(24,8) DEFAULT '0.00000000',
`localtax1` double(24,8) DEFAULT '0.00000000',
`localtax2` double(24,8) DEFAULT '0.00000000',
`total` double(24,8) DEFAULT '0.00000000',
`fk_account` int(11) DEFAULT NULL,
`fk_currency` varchar(3) DEFAULT NULL,
`fk_cond_reglement` int(11) DEFAULT NULL,
`fk_mode_reglement` int(11) DEFAULT NULL,
`note_private` text,
`note_public` text,
`model_pdf` varchar(255) DEFAULT NULL,
`date_livraison` date DEFAULT NULL,
`fk_shipping_method` int(11) DEFAULT NULL,
`fk_availability` int(11) DEFAULT NULL,
`fk_input_reason` int(11) DEFAULT NULL,
`import_key` varchar(14) DEFAULT NULL,
`extraparams` varchar(255) DEFAULT NULL,
`fk_delivery_address` int(11) DEFAULT NULL,
PRIMARY KEY (`rowid`),
UNIQUE KEY `uk_askpricesupplier_ref` (`ref`,`entity`),
KEY `idx_askpricesupplier_fk_soc` (`fk_soc`),
KEY `idx_askpricesupplier_fk_user_author` (`fk_user_author`),
KEY `idx_askpricesupplier_fk_user_valid` (`fk_user_valid`),
KEY `idx_askpricesupplier_fk_user_cloture` (`fk_user_cloture`),
KEY `idx_askpricesupplier_fk_projet` (`fk_projet`),
KEY `idx_askpricesupplier_fk_account` (`fk_account`),
KEY `idx_askpricesupplier_fk_currency` (`fk_currency`),
CONSTRAINT `fk_askpricesupplier_fk_projet` FOREIGN KEY (`fk_projet`) REFERENCES `llx_projet` (`rowid`),
CONSTRAINT `fk_askpricesupplier_fk_soc` FOREIGN KEY (`fk_soc`) REFERENCES `llx_societe` (`rowid`),
CONSTRAINT `fk_askpricesupplier_fk_user_author` FOREIGN KEY (`fk_user_author`) REFERENCES `llx_user` (`rowid`),
CONSTRAINT `fk_askpricesupplier_fk_user_cloture` FOREIGN KEY (`fk_user_cloture`) REFERENCES `llx_user` (`rowid`),
CONSTRAINT `fk_askpricesupplier_fk_user_valid` FOREIGN KEY (`fk_user_valid`) REFERENCES `llx_user` (`rowid`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8

View File

@ -0,0 +1,8 @@
CREATE TABLE `llx_askpricesupplier_extrafields` (
`rowid` int(11) NOT NULL AUTO_INCREMENT,
`tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`fk_object` int(11) NOT NULL,
`import_key` varchar(14) DEFAULT NULL,
PRIMARY KEY (`rowid`),
KEY `idx_askpricesupplier_extrafields` (`fk_object`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

View File

@ -0,0 +1,36 @@
CREATE TABLE `llx_askpricesupplierdet` (
`rowid` int(11) NOT NULL AUTO_INCREMENT,
`fk_askpricesupplier` int(11) NOT NULL,
`fk_parent_line` int(11) DEFAULT NULL,
`fk_product` int(11) DEFAULT NULL,
`label` varchar(255) DEFAULT NULL,
`description` text,
`fk_remise_except` int(11) DEFAULT NULL,
`tva_tx` double(6,3) DEFAULT '0.000',
`localtax1_tx` double(6,3) DEFAULT '0.000',
`localtax1_type` varchar(10) DEFAULT NULL,
`localtax2_tx` double(6,3) DEFAULT '0.000',
`localtax2_type` varchar(10) DEFAULT NULL,
`qty` double DEFAULT NULL,
`remise_percent` double DEFAULT '0',
`remise` double DEFAULT '0',
`price` double DEFAULT NULL,
`subprice` double(24,8) DEFAULT '0.00000000',
`total_ht` double(24,8) DEFAULT '0.00000000',
`total_tva` double(24,8) DEFAULT '0.00000000',
`total_localtax1` double(24,8) DEFAULT '0.00000000',
`total_localtax2` double(24,8) DEFAULT '0.00000000',
`total_ttc` double(24,8) DEFAULT '0.00000000',
`product_type` int(11) DEFAULT '0',
`date_start` datetime DEFAULT NULL,
`date_end` datetime DEFAULT NULL,
`info_bits` int(11) DEFAULT '0',
`buy_price_ht` double(24,8) DEFAULT '0.00000000',
`fk_product_fournisseur_price` int(11) DEFAULT NULL,
`special_code` int(11) DEFAULT '0',
`rang` int(11) DEFAULT '0',
PRIMARY KEY (`rowid`),
KEY `idx_askpricesupplierdet_fk_askpricesupplierdet` (`fk_askpricesupplier`),
KEY `idx_askpricesupplierdet_fk_product` (`fk_product`),
CONSTRAINT `fk_askpricesupplierdet_fk_propal` FOREIGN KEY (`fk_askpricesupplier`) REFERENCES `llx_askpricesupplier` (`rowid`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8

View File

@ -0,0 +1,8 @@
CREATE TABLE `llx_askpricesupplierdet_extrafields` (
`rowid` int(11) NOT NULL AUTO_INCREMENT,
`tms` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`fk_object` int(11) NOT NULL,
`import_key` varchar(14) DEFAULT NULL,
PRIMARY KEY (`rowid`),
KEY `idx_askpricesupplierdet_extrafields` (`fk_object`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

View File

@ -52,11 +52,11 @@ foreach($linkedObjectBlock as $object)
$var=!$var;
?>
<tr <?php echo $bc[$var]; ?> ><td>
<a href="<?php echo DOL_URL_ROOT.'/comm/propal.php?id='.$object->id ?>"><?php echo img_object($langs->trans("ShowPropal"),"propal").' '.$object->ref; ?></a></td>
<a href="<?php echo DOL_URL_ROOT.'/comm/askpricesupplier.php?id='.$object->id ?>"><?php echo img_object($langs->trans("ShowAskPriceSupplier"),"askpricesupplier").' '.$object->ref; ?></a></td>
<td><?php echo $object->ref_client; ?></td>
<td align="center"><?php echo dol_print_date($object->date,'day'); ?></td>
<td align="right"><?php
if ($user->rights->propale->lire) {
if ($user->rights->askpricesupplier->lire) {
$total = $total + $object->total_ht;
echo price($object->total_ht);
} ?></td>
@ -69,7 +69,7 @@ foreach($linkedObjectBlock as $object)
<tr class="liste_total">
<td align="left" colspan="3"><?php echo $langs->trans('TotalHT'); ?></td>
<td align="right"><?php
if ($user->rights->propale->lire) {
if ($user->rights->askpricesupplier->lire) {
echo price($total);
} ?></td>
<td>&nbsp;</td>

View File

@ -0,0 +1,148 @@
<?php
/* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
*
* 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 <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/lib/propal.lib.php
* \brief Ensemble de fonctions de base pour le module propal
* \ingroup propal
*/
/**
* Prepare array with list of tabs
*
* @param object $object Object related to tabs
* @return array Array of tabs to show
*/
function propal_prepare_head($object)
{
global $langs, $conf, $user;
$langs->load("propal");
$langs->load("compta");
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?id='.$object->id;
$head[$h][1] = $langs->trans('ProposalCard');
$head[$h][2] = 'comm';
$h++;
if ((empty($conf->commande->enabled) && ((! empty($conf->expedition_bon->enabled) && $user->rights->expedition->lire)
|| (! empty($conf->livraison_bon->enabled) && $user->rights->expedition->livraison->lire))))
{
$langs->load("sendings");
$head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$object->id;
if ($conf->expedition_bon->enabled) $text=$langs->trans("Shipment");
if ($conf->livraison_bon->enabled) $text.='/'.$langs->trans("Receivings");
$head[$h][1] = $text;
$head[$h][2] = 'shipping';
$h++;
}
if (! empty($conf->global->MAIN_USE_PREVIEW_TABS))
{
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?id='.$object->id;
$head[$h][1] = $langs->trans("Preview");
$head[$h][2] = 'preview';
$h++;
}
if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
{
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/contact.php?id='.$object->id;
$head[$h][1] = $langs->trans('ContactsAddresses');
$head[$h][2] = 'contact';
$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); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'propal');
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$nbNote = 0;
if(!empty($object->note_private)) $nbNote++;
if(!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?id='.$object->id;
$head[$h][1] = $langs->trans('Notes');
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
$head[$h][2] = 'note';
$h++;
}
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref);
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$'));
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id;
$head[$h][1] = $langs->trans('Documents');
if($nbFiles > 0) $head[$h][1].= ' <span class="badge">'.$nbFiles.'</span>';
$head[$h][2] = 'document';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?id='.$object->id;
$head[$h][1] = $langs->trans('Info');
$head[$h][2] = 'info';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'propal','remove');
return $head;
}
/**
* Return array head with list of tabs to view object informations.
*
* @return array head array with tabs
*/
function propal_admin_prepare_head()
{
global $langs, $conf, $user;
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/admin/propal.php';
$head[$h][1] = $langs->trans("Miscellaneous");
$head[$h][2] = 'general';
$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,null,$head,$h,'propal_admin');
$head[$h][0] = DOL_URL_ROOT.'/comm/admin/propal_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields");
$head[$h][2] = 'attributes';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/admin/propaldet_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsLines");
$head[$h][2] = 'attributeslines';
$h++;
complete_head_from_modules($conf,$langs,null,$head,$h,'propal_admin','remove');
return $head;
}

View File

@ -0,0 +1,484 @@
<?php
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
*
* 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 <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php
* \ingroup societe
* \brief File of class to build ODT documents for third parties
*/
require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
/**
* Class to build documents using ODF templates generator
*/
class doc_generic_proposal_odt extends ModelePDFPropales
{
var $emetteur; // Objet societe qui emet
var $phpmin = array(5,2,0); // Minimum version of PHP required by module
var $version = 'dolibarr';
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
global $conf,$langs,$mysoc;
$langs->load("main");
$langs->load("companies");
$this->db = $db;
$this->name = "ODT templates";
$this->description = $langs->trans("DocumentModelOdt");
$this->scandir = 'PROPALE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
// Dimension page pour format A4
$this->type = 'odt';
$this->page_largeur = 0;
$this->page_hauteur = 0;
$this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=0;
$this->marge_droite=0;
$this->marge_haute=0;
$this->marge_basse=0;
$this->option_logo = 1; // Affiche logo
$this->option_tva = 0; // Gere option tva PROPALE_TVAOPTION
$this->option_modereg = 0; // Affiche mode reglement
$this->option_condreg = 0; // Affiche conditions reglement
$this->option_codeproduitservice = 0; // Affiche code produit-service
$this->option_multilang = 1; // Dispo en plusieurs langues
$this->option_escompte = 0; // Affiche si il y a eu escompte
$this->option_credit_note = 0; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
// Recupere emetteur
$this->emetteur=$mysoc;
if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined
}
/**
* Return description of a module
*
* @param Translate $langs Lang object to use for output
* @return string Description
*/
function info($langs)
{
global $conf,$langs;
$langs->load("companies");
$langs->load("errors");
$form = new Form($this->db);
$texte = $this->description.".<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$texte.= '<input type="hidden" name="action" value="setModuleOptions">';
$texte.= '<input type="hidden" name="param1" value="PROPALE_ADDON_PDF_ODT_PATH">';
if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
{
$texte.= '<input type="hidden" name="param2" value="PROPALE_ADDON_PDF_ODT_DEFAULT">';
$texte.= '<input type="hidden" name="param3" value="PROPALE_ADDON_PDF_ODT_TOBILL">';
$texte.= '<input type="hidden" name="param4" value="PROPALE_ADDON_PDF_ODT_CLOSED">';
}
$texte.= '<table class="nobordernopadding" width="100%">';
// List of directories area
$texte.= '<tr><td>';
$texttitle=$langs->trans("ListOfDirectories");
$listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PROPALE_ADDON_PDF_ODT_PATH)));
$listoffiles=array();
foreach($listofdir as $key=>$tmpdir)
{
$tmpdir=trim($tmpdir);
$tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
if (! $tmpdir) {
unset($listofdir[$key]); continue;
}
if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
else
{
$tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
}
}
$texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
// Add list of substitution keys
$texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
$texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
$texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
$texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
$texte.= '<textarea class="flat" cols="60" name="value1">';
$texte.=$conf->global->PROPALE_ADDON_PDF_ODT_PATH;
$texte.= '</textarea>';
$texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
$texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
$texte.= '<br></div></div>';
// Scan directories
if (count($listofdir))
{
$texte.=$langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>';
if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
{
// Model for creation
$liste=ModelePDFPropales::liste_modeles($this->db);
$texte.= '<table width="50%;">';
$texte.= '<tr>';
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalCreate").'</td>';
$texte.= '<td colspan="">';
$texte.= $form->selectarray('value2',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT);
$texte.= "</td></tr>";
$texte.= '<tr>';
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalToBill").'</td>';
$texte.= '<td colspan="">';
$texte.= $form->selectarray('value3',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_TOBILL);
$texte.= "</td></tr>";
$texte.= '<tr>';
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalClosed").'</td>';
$texte.= '<td colspan="">';
$texte.= $form->selectarray('value4',$liste,$conf->global->PROPALE_ADDON_PDF_ODT_CLOSED);
$texte.= "</td></tr>";
$texte.= '</table>';
}
}
$texte.= '</td>';
$texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
$texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
$texte.= '</td>';
$texte.= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
return $texte;
}
/**
* Function to build a document on disk using the generic odt module.
*
* @param Propale $object Object source to build document
* @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref
* @return int 1 if OK, <=0 if KO
*/
function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0)
{
global $user,$langs,$conf,$mysoc,$hookmanager;
if (empty($srctemplatepath))
{
dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
return -1;
}
// Add odtgeneration hook
if (! is_object($hookmanager))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($this->db);
}
$hookmanager->initHooks(array('odtgeneration'));
global $action;
if (! is_object($outputlangs)) $outputlangs=$langs;
$sav_charset_output=$outputlangs->charset_output;
$outputlangs->charset_output='UTF-8';
$outputlangs->load("main");
$outputlangs->load("dict");
$outputlangs->load("companies");
$outputlangs->load("bills");
if ($conf->propal->dir_output)
{
// If $object is id instead of object
if (! is_object($object))
{
$id = $object;
$object = new Propale($this->db);
$result=$object->fetch($id);
if ($result < 0)
{
dol_print_error($this->db,$object->error);
return -1;
}
}
$dir = $conf->propal->dir_output;
$objectref = dol_sanitizeFileName($object->ref);
if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
$file = $dir . "/" . $objectref . ".odt";
if (! file_exists($dir))
{
if (dol_mkdir($dir) < 0)
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
return -1;
}
}
if (file_exists($dir))
{
//print "srctemplatepath=".$srctemplatepath; // Src filename
$newfile=basename($srctemplatepath);
$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
$newfiletmp=$objectref.'_'.$newfiletmp;
// Get extension (ods or odt)
$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
{
$filename=$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.'.$newfileformat;
}
else
{
$filename=$newfiletmp.'.'.$newfileformat;
}
$file=$dir.'/'.$filename;
//print "newdir=".$dir;
//print "newfile=".$newfile;
//print "file=".$file;
//print "conf->propal->dir_temp=".$conf->propal->dir_temp;
dol_mkdir($conf->propal->dir_temp);
// If BILLING contact defined on invoice, we use it
$usecontact=false;
$arrayidcontact=$object->getIdContact('external','BILLING');
if (count($arrayidcontact) > 0)
{
$usecontact=true;
$result=$object->fetch_contact($arrayidcontact[0]);
}
// Recipient name
if (! empty($usecontact))
{
// On peut utiliser le nom de la societe du contact
if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
else $socobject = $object->client;
}
else
{
$socobject=$object->client;
}
// Make substitution
$substitutionarray=array(
'__FROM_NAME__' => $this->emetteur->name,
'__FROM_EMAIL__' => $this->emetteur->email,
'__TOTAL_TTC__' => $object->total_ttc,
'__TOTAL_HT__' => $object->total_ht,
'__TOTAL_VAT__' => $object->total_vat
);
complete_substitutions_array($substitutionarray, $langs, $object);
// Call the ODTSubstitution hook
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$substitutionarray);
$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
// Line of free text
$newfreetext='';
$paramfreetext='PROPALE_FREE_TEXT';
if (! empty($conf->global->$paramfreetext))
{
$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
}
// Open and load template
require_once ODTPHP_PATH.'odf.php';
try {
$odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->propal->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
}
catch(Exception $e)
{
$this->error=$e->getMessage();
return -1;
}
// After construction $odfHandler->contentXml contains content and
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
// [!-- BEGIN lines --]*[!-- END lines --]
//print html_entity_decode($odfHandler->__toString());
//print exit;
// Make substitutions into odt of freetext
try {
$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
}
catch(OdfException $e)
{
}
// Make substitutions into odt
$array_user=$this->get_substitutionarray_user($user,$outputlangs);
$array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
$array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
$array_objet=$this->get_substitutionarray_object($object,$outputlangs);
$array_other=$this->get_substitutionarray_other($outputlangs);
$tmparray = array_merge($array_user,$array_soc,$array_thirdparty,$array_objet,$array_other);
complete_substitutions_array($tmparray, $outputlangs, $object);
// Call the ODTSubstitution hook
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
$reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
foreach($tmparray as $key=>$value)
{
try {
if (preg_match('/logo$/',$key)) // Image
{
if (file_exists($value)) $odfHandler->setImage($key, $value);
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
}
else // Text
{
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
}
catch(OdfException $e)
{
}
}
// Replace tags of lines
try
{
$listlines = $odfHandler->setSegment('lines');
foreach ($object->lines as $line)
{
$tmparray=$this->get_substitutionarray_lines($line,$outputlangs);
complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
// Call the ODTSubstitutionLine hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray,'line'=>$line);
$reshook=$hookmanager->executeHooks('ODTSubstitutionLine',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
foreach($tmparray as $key => $val)
{
try
{
$listlines->setVars($key, $val, true, 'UTF-8');
}
catch(OdfException $e)
{
}
catch(SegmentException $e)
{
}
}
$listlines->merge();
}
$odfHandler->mergeSegment($listlines);
}
catch(OdfException $e)
{
$this->error=$e->getMessage();
dol_syslog($this->error, LOG_WARNING);
return -1;
}
// Replace labels translated
$tmparray=$outputlangs->get_translations_for_substitutions();
foreach($tmparray as $key=>$value)
{
try {
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
catch(OdfException $e)
{
}
}
// Call the beforeODTSave hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
// Write new file
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
try {
$odfHandler->exportAsAttachedPDF($file);
}catch (Exception $e){
$this->error=$e->getMessage();
return -1;
}
}
else {
try {
$odfHandler->saveToDisk($file);
}catch (Exception $e){
$this->error=$e->getMessage();
return -1;
}
}
$reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$odfHandler=null; // Destroy object
return 1; // Success
}
else
{
$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
return -1;
}
}
return -1;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,153 @@
<?php
/* Copyright (C) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
*
* 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 <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/modules/propale/mod_propale_marbre.php
* \ingroup propale
* \brief File of class to manage commercial proposal numbering rules Marbre
*/
require_once DOL_DOCUMENT_ROOT .'/core/modules/propale/modules_propale.php';
/**
* Class to manage customer order numbering rules Marbre
*/
class mod_propale_marbre extends ModeleNumRefPropales
{
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
var $prefix='PR';
var $error='';
var $nom = "Marbre";
/**
* Return description of numbering module
*
* @return string Text with description
*/
function info()
{
global $langs;
return $langs->trans("SimpleNumRefModelDesc",$this->prefix);
}
/**
* Return an example of numbering module values
*
* @return string Example
*/
function getExample()
{
return $this->prefix."0501-0001";
}
/**
* Test si les numeros deje en vigueur dans la base ne provoquent pas de
* de conflits qui empechera cette numerotation de fonctionner.
*
* @return boolean false si conflit, true si ok
*/
function canBeActivated()
{
global $conf,$langs,$db;
$pryymm=''; $max='';
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
$sql.= " WHERE ref LIKE '".$this->prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$row = $db->fetch_row($resql);
if ($row) { $pryymm = substr($row[0],0,6); $max=$row[0]; }
}
if (! $pryymm || preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$pryymm))
{
return true;
}
else
{
$langs->load("errors");
$this->error=$langs->trans('ErrorNumRefModel',$max);
return false;
}
}
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Propal $propal Object commercial proposal
* @return string Next value
*/
function getNextValue($objsoc,$propal)
{
global $db,$conf;
// D'abord on recupere la valeur max
$posindice=8;
$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
$sql.= " WHERE ref LIKE '".$this->prefix."____-%'";
$sql.= " AND entity = ".$conf->entity;
$resql=$db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
if ($obj) $max = intval($obj->max);
else $max=0;
}
else
{
dol_syslog(get_class($this)."::getNextValue", LOG_DEBUG);
return -1;
}
$date = time();
$yymm = strftime("%y%m",$date);
if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is
else $num = sprintf("%04s",$max+1);
dol_syslog(get_class($this)."::getNextValue return ".$this->prefix.$yymm."-".$num);
return $this->prefix.$yymm."-".$num;
}
/**
* Return next free value
*
* @param Societe $objsoc Object third party
* @param Object $objforref Object for number to search
* @return string Next free value
*/
function getNumRef($objsoc,$objforref)
{
return $this->getNextValue($objsoc,$objforref);
}
}

View File

@ -0,0 +1,131 @@
<?php
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
*
* 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 <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/modules/propale/mod_propale_saphir.php
* \ingroup propale
* \brief File that contains the numbering module rules Saphir
*/
require_once DOL_DOCUMENT_ROOT .'/core/modules/propale/modules_propale.php';
/**
* Class of file that contains the numbering module rules Saphir
*/
class mod_propale_saphir extends ModeleNumRefPropales
{
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
var $error = '';
var $nom = 'Saphir';
/**
* Return description of module
*
* @return string Texte descripif
*/
function info()
{
global $conf,$langs;
$langs->load("bills");
$form = new Form($this->db);
$texte = $langs->trans('GenericNumRefModelDesc')."<br>\n";
$texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
$texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$texte.= '<input type="hidden" name="action" value="updateMask">';
$texte.= '<input type="hidden" name="maskconstpropal" value="PROPALE_SAPHIR_MASK">';
$texte.= '<table class="nobordernopadding" width="100%">';
$tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Proposal"),$langs->transnoentities("Proposal"));
$tooltip.=$langs->trans("GenericMaskCodes2");
$tooltip.=$langs->trans("GenericMaskCodes3");
$tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Proposal"),$langs->transnoentities("Proposal"));
$tooltip.=$langs->trans("GenericMaskCodes5");
// Parametrage du prefix
$texte.= '<tr><td>'.$langs->trans("Mask").':</td>';
$texte.= '<td align="right">'.$form->textwithpicto('<input type="text" class="flat" size="24" name="maskpropal" value="'.$conf->global->PROPALE_SAPHIR_MASK.'">',$tooltip,1,1).'</td>';
$texte.= '<td align="left" rowspan="2">&nbsp; <input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button"></td>';
$texte.= '</tr>';
$texte.= '</table>';
$texte.= '</form>';
return $texte;
}
/**
* Renvoi un exemple de numerotation
*
* @return string Example
*/
function getExample()
{
global $conf,$langs,$mysoc;
$old_code_client=$mysoc->code_client;
$mysoc->code_client='CCCCCCCCCC';
$numExample = $this->getNextValue($mysoc,'');
$mysoc->code_client=$old_code_client;
if (! $numExample)
{
$numExample = 'NotConfigured';
}
return $numExample;
}
/**
* Return next value
*
* @param Societe $objsoc Object third party
* @param Propal $propal Object commercial proposal
* @return string Value if OK, 0 if KO
*/
function getNextValue($objsoc,$propal)
{
global $db,$conf;
require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php';
// On defini critere recherche compteur
$mask=$conf->global->PROPALE_SAPHIR_MASK;
if (! $mask)
{
$this->error='NotConfigured';
return 0;
}
$date=$propal->datep;
$customercode=$objsoc->code_client;
$numFinal=get_next_value($db,$mask,'propal','ref','',$customercode,$date);
return $numFinal;
}
}

View File

@ -0,0 +1,165 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/modules/propale/modules_propale.php
* \ingroup propale
* \brief Fichier contenant la classe mere de generation des propales en PDF
* et la classe mere de numerotation des propales
*/
require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // Requis car utilise dans les classes qui heritent
/**
* Classe mere des modeles de propale
*/
abstract class ModelePDFAskPriceSupplier extends CommonDocGenerator
{
var $error='';
/**
* Return list of active generation modules
*
* @param DoliDB $db Database handler
* @param string $maxfilenamelength Max length of value to show
* @return array List of templates
*/
static function liste_modeles($db,$maxfilenamelength=0)
{
global $conf;
$type='askpricesupplier';
$liste=array();
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
$liste=getListOfModels($db,$type,$maxfilenamelength);
return $liste;
}
}
/**
* Classe mere des modeles de numerotation des references de propales
*/
abstract class ModeleNumRefPropales
{
var $error='';
/**
* Return if a module can be used or not
*
* @return boolean true if module can be used
*/
function isEnabled()
{
return true;
}
/**
* Renvoi la description par defaut du modele de numerotation
*
* @return string Texte descripif
*/
function info()
{
global $langs;
$langs->load("propale");
return $langs->trans("NoDescription");
}
/**
* Renvoi un exemple de numerotation
*
* @return string Example
*/
function getExample()
{
global $langs;
$langs->load("propale");
return $langs->trans("NoExample");
}
/**
* Test si les numeros deja en vigueur dans la base ne provoquent pas de
* de conflits qui empechera cette numerotation de fonctionner.
*
* @return boolean false si conflit, true si ok
*/
function canBeActivated()
{
return true;
}
/**
* Renvoi prochaine valeur attribuee
*
* @param Societe $objsoc Object third party
* @param Propal $propal Object commercial proposal
* @return string Valeur
*/
function getNextValue($objsoc,$propal)
{
global $langs;
return $langs->trans("NotAvailable");
}
/**
* Renvoi version du module numerotation
*
* @return string Valeur
*/
function getVersion()
{
global $langs;
$langs->load("admin");
if ($this->version == 'development') return $langs->trans("VersionDevelopment");
if ($this->version == 'experimental') return $langs->trans("VersionExperimental");
if ($this->version == 'dolibarr') return DOL_VERSION;
if ($this->version) return $this->version;
return $langs->trans("NotAvailable");
}
}
/**
* Create a document onto disk according to template module.
*
* @param DoliDB $db Database handler
* @param object $object Object proposal
* @param string $modele Force model to use ('' to not force)
* @param Translate $outputlangs Object langs to use for output
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
* @param int $hideref Hide ref
* @return int 0 if KO, 1 if OK
* @deprecated Use the new function generateDocument of Propal class
*/
function propale_pdf_create(DoliDB $db, Propal $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
{
return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
}

View File

@ -73,12 +73,32 @@ class modAskPriceSupplier extends DolibarrModules
$this->const = array();
$r=0;
/*$this->const[$r][0] = "PROPALE_ADDON_PDF";
$this->const[$r][0] = "ASKPRICESUPPLIER_ADDON_PDF";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "azur";
$this->const[$r][3] = 'Nom du gestionnaire de generation des propales en PDF';
$this->const[$r][3] = 'Nom du gestionnaire de generation des demandes de prix fournisseurs en PDF';
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "ASKPRICESUPPLIER_ADDON";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "mod_propale_marbre";
$this->const[$r][3] = 'Nom du gestionnaire de numerotation des demandes de prix fournisseurs';
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "ASKPRICESUPPLIER_VALIDITY_DURATION";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "15";
$this->const[$r][3] = 'Durée de validitée des demandes de prix fournisseurs';
$this->const[$r][4] = 0;
$r++;
$this->const[$r][0] = "ASKPRICESUPPLIER_ADDON_PDF_ODT_PATH";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/askpricesupplier";
$this->const[$r][3] = "";
$this->const[$r][4] = 0;
$r++;*/
// Boxes
$this->boxes = array();
@ -90,35 +110,36 @@ class modAskPriceSupplier extends DolibarrModules
$r++;
$this->rights[$r][0] = $this->numero + $r; // id de la permission
$this->rights[$r][1] = 'Créer/modifier les demandes fournisseurs'; // libelle de la permission
$this->rights[$r][1] = 'Lire les demandes fournisseurs'; // libelle de la permission
$this->rights[$r][3] = 1; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'create';
$this->rights[$r][4] = 'lire';
$r++;
$this->rights[$r][0] = $this->numero + $r; // id de la permission
$this->rights[$r][1] = 'Lire les demandes fournisseurs'; // libelle de la permission
$this->rights[$r][1] = 'Créer/modifier les demandes fournisseurs'; // libelle de la permission
$this->rights[$r][3] = 1; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'read';
$this->rights[$r][4] = 'creer';
$r++;
$this->rights[$r][0] = $this->numero + $r; // id de la permission
$this->rights[$r][1] = 'Valider les demandes fournisseurs'; // libelle de la permission
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'read';
$this->rights[$r][4] = '';
$this->rights[$r][5] = 'validate';
$r++;
$this->rights[$r][0] = $this->numero + $r; // id de la permission
$this->rights[$r][1] = 'Envoyer les demandes fournisseurs'; // libelle de la permission
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'read';
$this->rights[$r][4] = '';
$this->rights[$r][5] = 'send';
$r++;
$this->rights[$r][0] = $this->numero + $r; // id de la permission
$this->rights[$r][1] = 'Supprimer les demandes fournisseurs'; // libelle de la permission
$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
$this->rights[$r][4] = 'delete';
$this->rights[$r][4] = 'supprimer';
// Exports
//--------
@ -155,10 +176,10 @@ class modAskPriceSupplier extends DolibarrModules
'type'=>'left', // This is a Left menu entry
'titre'=>'askpricesupplierMENU_LEFT_TITLE',
'leftmenu'=>'askpricesuppliersubmenu',
'url'=>'/askpricesupplier/index.php',
'url'=>'/comm/askpricesupplier/index.php',
'langs'=>'askpricesupplier', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'enabled'=>'$conf->askpricesupplier->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
'perms'=>'$user->rights->askpricesupplier->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'perms'=>'$user->rights->askpricesupplier->lire', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'user'=>2 // 0=Menu for internal users, 1=external users, 2=both
);
$r++;
@ -167,10 +188,10 @@ class modAskPriceSupplier extends DolibarrModules
'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=askpricesuppliersubmenu',
'type'=>'left',
'titre'=>'askpricesupplierMENU_LEFT_TITLE_NEW',
'url'=>'/askpricesupplier/card.php?action=create',
'url'=>'/comm/askpricesupplier.php?action=create',
'langs'=>'askpricesupplier',
'enabled'=>'$conf->askpricesupplier->enabled',
'perms'=>'$user->rights->askpricesupplier->create',
'perms'=>'$user->rights->askpricesupplier->creer',
'user'=>2
);
$r++;
@ -179,10 +200,10 @@ class modAskPriceSupplier extends DolibarrModules
'fk_menu'=>'fk_mainmenu=commercial,fk_leftmenu=askpricesuppliersubmenu',
'type'=>'left',
'titre'=>'askpricesupplierMENU_LEFT_TITLE_LIST',
'url'=>'/askpricesupplier/list.php',
'url'=>'/comm/askpricesupplier/list.php',
'langs'=>'askpricesupplier',
'enabled'=>'$conf->askpricesupplier->enabled',
'perms'=>'$user->rights->askpricesupplier->read',
'perms'=>'$user->rights->askpricesupplier->lire',
'user'=>2
);
$r++;
@ -205,8 +226,7 @@ class modAskPriceSupplier extends DolibarrModules
$sql = array();
//$result=$this->_load_tables('/mymodule/sql/');
$result=$this->_load_tables('/comm/askpricesupplier/sql/');
return $this->_init($sql, $options);
}
@ -226,3 +246,22 @@ class modAskPriceSupplier extends DolibarrModules
}
}
/*
*
* CREATE TABLE IF NOT EXISTS llx_askpricesupplier (
rowid INT AUTO_INCREMENT,
fk_statut INT NOT NULL,
fk_soc INT NOT NULL,
price DOUBLE(24,8),
date_create TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
date_send TIMESTAMP,
PRIMARY KEY pk_rowid (rowid),
CONSTRAINT fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid)
);
*
*
*
*
*/

View File

@ -151,6 +151,19 @@ class InterfaceDemo extends DolibarrTriggers
case 'LINEPROPAL_UPDATE':
case 'LINEPROPAL_DELETE':
// Askpricesupplier
case 'ASKPRICESUPPLIER_CREATE':
case 'ASKPRICESUPPLIER_CLONE':
case 'ASKPRICESUPPLIER_MODIFY':
case 'ASKPRICESUPPLIER_VALIDATE':
case 'ASKPRICESUPPLIER_SENTBYMAIL':
case 'ASKPRICESUPPLIER_CLOSE_SIGNED':
case 'ASKPRICESUPPLIER_CLOSE_REFUSED':
case 'ASKPRICESUPPLIER_DELETE':
case 'LINEASKPRICESUPPLIER_INSERT':
case 'LINEASKPRICESUPPLIER_UPDATE':
case 'LINEASKPRICESUPPLIER_DELETE':
// Contracts
case 'CONTRACT_CREATE':
case 'CONTRACT_ACTIVATE':

View File

@ -3,4 +3,127 @@ AskPriceSupplier=Demande de prix fournisseur
askpricesupplierDESC=Gestion des demandes de prix aux fournisseurs
askpricesupplierMENU_LEFT_TITLE=Demandes de prix fourn.
askpricesupplierMENU_LEFT_TITLE_NEW=Nouvelle demande
askpricesupplierMENU_LEFT_TITLE_LIST=Liste
askpricesupplierMENU_LEFT_TITLE_LIST=Liste
# Dolibarr language file - Source file is en_US - propal
Proposals=Propositions commerciales
Proposal=Proposition commerciale
ProposalShort=Proposition
ProposalsDraft=Propositions commerciales brouillons
ProposalDraft=Proposition commerciale brouillon
ProposalsOpened=Propositions commerciales ouvertes
Prop=Propositions commerciales
CommercialProposal=Proposition commerciale
CommercialProposals=Propositions commerciales
ProposalCard=Fiche proposition
NewProp=Nouvelle proposition commerciale
NewProposal=Nouvelle proposition commerciale
NewPropal=Nouvelle proposition
Prospect=Prospect
ProspectList=Liste des prospects
ConfirmDeleteProp=Êtes-vous sûr de vouloir effacer cette proposition commerciale ?
ConfirmValidateProp=Êtes-vous sûr de vouloir valider cette proposition commerciale sous la référence <b>%s</b> ?
LastPropals=Les %s dernières propales
LastClosedProposals=Les %s dernières propositions commerciales fermées
LastModifiedProposals=Les %s dernières propositions commerciales modifiées
AllPropals=Toutes les propales
LastProposals=Dernières propositions
SearchAProposal=Rechercher une proposition commerciale
ProposalsStatistics=Statistiques des propositions commerciales
NumberOfProposalsByMonth=Nombre par mois
AmountOfProposalsByMonthHT=Montant par mois (HT)
NbOfProposals=Nombre de propositions commerciales
# # Ajout
ShowAskpricesupplier=Afficher demande
CommRequest=Demande de prix
CommRequests=Demandes de prix
SearchRequest=Rechercher une demande
DraftRequests=Demandes brouillons
LastModifiedRequests=Les %s dernières demandes de prix modifiées
RequestsOpened=Demandes de prix ouvertes
AskPriceSupplierArea=Espace des demandes de prix fournisseurs
NewAskPrice=Nouvelle demande de prix
NewAsk=Nouvelle demande
# # Modifié
DateAsk=Date de demande
DateEndAsk=Date de fin de validité
DateEndAskShort=Date de fin
DeleteAsk=Supprimer demande
ValidateAsk=Valider demande
AddAsk=Créer une demande
AskpricesupplierDraft=Brouillons
AskpricesupplierOpened=Ouvertes
AskpricesupplierNotBilled=Non facturées
AskpricesupplierStatusDraft=Brouillon (à valider)
AskpricesupplierStatusValidated=Validée (demande ouverte)
AskpricesupplierStatusOpened=Validée (demande ouverte)
AskpricesupplierStatusClosed=Fermée
AskpricesupplierStatusSigned=Signée (à facturer)
AskpricesupplierStatusNotSigned=Non signée (fermée)
AskpricesupplierStatusBilled=Facturée
AskpricesupplierStatusDraftShort=Brouillon
AskpricesupplierStatusValidatedShort=Validée
AskpricesupplierStatusOpenedShort=Ouverte
AskpricesupplierStatusClosedShort=Fermée
AskpricesupplierStatusSignedShort=Signée
AskpricesupplierStatusNotSignedShort=Non signée
AskpricesupplierStatusBilledShort=Facturée
AskpricesupplierToClose=Demandes de prix à fermer
AskpricesupplierToBill=Demandes de prix signées à facturer
CopyAskFrom=Créer demande/devis par recopie d'une demande existante
CreateEmptyAsk=Créer demande/devis vierge
CloneAsk=Cloner demande de prix
ConfirmCloneAsk=Êtes-vous sûr de vouloir cloner la demande de prix <b>%s</b> ?
ConfirmReOpenAsk=Êtes-vous sûr de vouloir réouvrir la demande de prix <b>%s</b> ?
SendAskByMail=Envoyer demande de prix par email
SendAskRef=Envoi de la demande de prix %s
##### Types de contacts #####
TypeContact_askpricesupplier_internal_SALESREPFOLL=Commercial suivi demande
TypeContact_askpricesupplier_external_BILLING=Contact client facturation demande
TypeContact_askpricesupplier_external_CUSTOMER=Contact client suivi demande
# #
ListOfProposals=Liste des devis/propositions commerciales
ActionsOnPropal=Événements sur la proposition
NoOpenedPropals=Pas de proposition ouverte
NoOtherOpenedPropals=Pas d'autre proposition brouillon
RefProposal=Réf. proposition commerciale
AssociatedDocuments=Documents associés à la proposition :
ErrorCantOpenDir=Impossible d'ouvrir le répertoire
ValidityDuration=Durée de validité
CloseAs=Clôturer au statut
ClassifyBilled=Classer facturée
BuildBill=Créer facture
ErrorPropalNotFound=Propale %s inexistante
Estimate=Devis :
EstimateShort=Devis
OtherPropals=Autres propositions
AddToDraftProposals=Ajouter à proposition brouillon
NoDraftProposals=Pas de propositions brouillons
DefaultProposalDurationValidity=Délai de validité par défaut (en jours)
UseCustomerContactAsPropalRecipientIfExist=Utiliser l'adresse de contact suivi client si définie plutôt que l'adresse du tiers comme destinataire des propositions
ProposalsAndProposalsLines=Propositions commerciales clients et lignes de propositions
ProposalLine=Ligne de proposition
AvailabilityPeriod=Délai de livraison
SetAvailability=Définir le délai de livraison
AfterOrder=après commande
##### Availability #####
AvailabilityTypeAV_NOW=Immédiate
AvailabilityTypeAV_1W=1 semaine
AvailabilityTypeAV_2W=2 semaines
AvailabilityTypeAV_3W=3 semaines
AvailabilityTypeAV_1M=1 mois
# Document models
DocModelAzurDescription=Modèle de proposition commerciale complet (logo…)
DocModelJauneDescription=Modèle de proposition Jaune
DefaultModelPropalCreate=Modèle par défaut à la création
DefaultModelPropalToBill=Modèle par défaut lors de la clôture d'une proposition commerciale (à facturer)
DefaultModelPropalClosed=Modèle par défaut lors de la clôture d'une proposition commerciale (non facturée)