New: Ajout methode load_board sur chaque objet mtier pour tableau de bord Dolibarr.
This commit is contained in:
parent
e4c4058211
commit
ec36e49fa2
@ -21,15 +21,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*! \file htdocs/don.class.php
|
||||
/**
|
||||
\file htdocs/don.class.php
|
||||
\ingroup don
|
||||
\brief Fichier de la classe des dons
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
|
||||
/*! \class Don
|
||||
\brief Classe permettant la gestion des dons
|
||||
/**
|
||||
\class Don
|
||||
\brief Classe permettant la gestion des dons
|
||||
*/
|
||||
|
||||
class Don
|
||||
@ -173,80 +175,79 @@ class Don
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Création du don en base
|
||||
* \param userid utilisateur qui crée le don
|
||||
/**
|
||||
* \brief Création du don en base
|
||||
* \param userid Objet utilisateur qui crée le don
|
||||
* \return int id don crée si ok, <0 si ko
|
||||
*/
|
||||
function create($userid)
|
||||
function create($user)
|
||||
{
|
||||
$this->date = $this->db->idate($this->date);
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."don (datec, amount, fk_paiement,prenom, nom, societe,adresse, cp, ville, pays, public,";
|
||||
if ($this->projetid)
|
||||
{
|
||||
$sql .= " fk_don_projet,";
|
||||
}
|
||||
$sql .= " note, fk_user_author, datedon, email)";
|
||||
$sql .= " VALUES (now(),".ereg_replace(",",".", $this->amount).", $this->modepaiementid,'$this->prenom','$this->nom','$this->societe','$this->adresse', '$this->cp','$this->ville','$this->pays',$this->public, ";
|
||||
if ($this->projetid)
|
||||
{
|
||||
$sql .= " $this->projetid,";
|
||||
}
|
||||
$sql .= " '$this->commentaire', $userid, '$this->date','$this->email')";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
return $this->db->last_insert_id(MAIN_DB_PREFIX."don");
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
$this->date = $this->db->idate($this->date);
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."don (datec, amount, fk_paiement,prenom, nom, societe,adresse, cp, ville, pays, public,";
|
||||
if ($this->projetid)
|
||||
{
|
||||
$sql .= " fk_don_projet,";
|
||||
}
|
||||
$sql .= " note, fk_user_author, datedon, email)";
|
||||
$sql .= " VALUES (now(),".ereg_replace(",",".", $this->amount).", $this->modepaiementid,'$this->prenom','$this->nom','$this->societe','$this->adresse', '$this->cp','$this->ville','$this->pays',$this->public, ";
|
||||
if ($this->projetid)
|
||||
{
|
||||
$sql .= " $this->projetid,";
|
||||
}
|
||||
$sql .= " '$this->commentaire', ".$user->id.", '$this->date','$this->email')";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
return $this->db->last_insert_id(MAIN_DB_PREFIX."don");
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Mise à jour du don
|
||||
* \param userid utilisateur qui crée le don
|
||||
*
|
||||
/**
|
||||
* \brief Mise à jour du don
|
||||
* \param user Objet utilisateur qui met à jour le don
|
||||
* \return int >0 si ok, <0 si ko
|
||||
*/
|
||||
function update($userid)
|
||||
function update($user)
|
||||
{
|
||||
|
||||
$this->date = $this->db->idate($this->date);
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET ";
|
||||
$sql .= "amount = " . $this->amount;
|
||||
$sql .= ",fk_paiement = ".$this->modepaiementid;
|
||||
$sql .= ",prenom = '".$this->prenom ."'";
|
||||
$sql .= ",nom='".$this->nom."'";
|
||||
$sql .= ",societe='".$this->societe."'";
|
||||
$sql .= ",adresse='".$this->adresse."'";
|
||||
$sql .= ",cp='".$this->cp."'";
|
||||
$sql .= ",ville='".$this->ville."'";
|
||||
$sql .= ",pays='".$this->pays."'";
|
||||
$sql .= ",public=".$this->public;
|
||||
if ($this->projetid) { $sql .= ",fk_don_projet=".$this->projetid; }
|
||||
$sql .= ",note='".$this->commentaire."'";
|
||||
$sql .= ",datedon='".$this->date."'";
|
||||
$sql .= ",email='".$this->email."'";
|
||||
$sql .= ",fk_statut=".$this->statut;
|
||||
|
||||
$sql .= " WHERE rowid = $this->id";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->date = $this->db->idate($this->date);
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET ";
|
||||
$sql .= "amount = " . $this->amount;
|
||||
$sql .= ",fk_paiement = ".$this->modepaiementid;
|
||||
$sql .= ",prenom = '".$this->prenom ."'";
|
||||
$sql .= ",nom='".$this->nom."'";
|
||||
$sql .= ",societe='".$this->societe."'";
|
||||
$sql .= ",adresse='".$this->adresse."'";
|
||||
$sql .= ",cp='".$this->cp."'";
|
||||
$sql .= ",ville='".$this->ville."'";
|
||||
$sql .= ",pays='".$this->pays."'";
|
||||
$sql .= ",public=".$this->public;
|
||||
if ($this->projetid) { $sql .= ",fk_don_projet=".$this->projetid; }
|
||||
$sql .= ",note='".$this->commentaire."'";
|
||||
$sql .= ",datedon='".$this->date."'";
|
||||
$sql .= ",email='".$this->email."'";
|
||||
$sql .= ",fk_statut=".$this->statut;
|
||||
|
||||
$sql .= " WHERE rowid = $this->id";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -266,13 +267,13 @@ class Don
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -283,9 +284,11 @@ class Don
|
||||
*/
|
||||
function fetch($rowid)
|
||||
{
|
||||
$sql = "SELECT d.rowid, ".$this->db->pdate("d.datedon")." as datedon, d.prenom, d.nom, d.societe, d.amount, p.libelle as projet, d.fk_statut, d.adresse, d.cp, d.ville, d.pays, d.public, d.amount, d.fk_paiement, d.note, cp.libelle, d.email, d.fk_don_projet";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."don as d, ".MAIN_DB_PREFIX."c_paiement as cp LEFT JOIN ".MAIN_DB_PREFIX."don_projet as p";
|
||||
$sql .= " ON p.rowid = d.fk_don_projet WHERE cp.id = d.fk_paiement AND d.rowid = $rowid";
|
||||
$sql = "SELECT d.rowid, ".$this->db->pdate("d.datec")." as datec,";
|
||||
$sql.= " ".$this->db->pdate("d.datedon")." as datedon,";
|
||||
$sql.= " d.prenom, d.nom, d.societe, d.amount, p.libelle as projet, d.fk_statut, d.adresse, d.cp, d.ville, d.pays, d.public, d.amount, d.fk_paiement, d.note, cp.libelle, d.email, d.fk_don_projet";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."don as d, ".MAIN_DB_PREFIX."c_paiement as cp LEFT JOIN ".MAIN_DB_PREFIX."don_projet as p";
|
||||
$sql.= " ON p.rowid = d.fk_don_projet WHERE cp.id = d.fk_paiement AND d.rowid = $rowid";
|
||||
|
||||
if ( $this->db->query( $sql) )
|
||||
{
|
||||
@ -295,6 +298,7 @@ class Don
|
||||
$obj = $this->db->fetch_object();
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->datec = $obj->datec;
|
||||
$this->date = $obj->datedon;
|
||||
$this->prenom = stripslashes($obj->prenom);
|
||||
$this->nom = stripslashes($obj->nom);
|
||||
|
||||
@ -1219,7 +1219,7 @@ class Facture
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi le libellé court d'un statut donn
|
||||
* \brief Renvoi le libellé court d'un statut donné
|
||||
* \param paye etat paye
|
||||
* \param statut id statut
|
||||
* \param amount amount already payed
|
||||
@ -1264,10 +1264,10 @@ class Facture
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* \brief Charge les informations d'ordre info dans l'objet facture
|
||||
* \param id id de la facture a charger
|
||||
*/
|
||||
/**
|
||||
* \brief Charge les informations d'ordre info dans l'objet facture
|
||||
* \param id Id de la facture a charger
|
||||
*/
|
||||
function info($id)
|
||||
{
|
||||
$sql = "SELECT c.rowid, ".$this->db->pdate("datec")." as datec";
|
||||
@ -1569,32 +1569,64 @@ class Facture
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Charge indicateurs this->nbtodo et this->nbtodolate de tableau de bord
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function load_board()
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$this->nbtodo=$this->nbtodolate=0;
|
||||
$sql = "SELECT f.rowid,".$this->db->pdate("f.date_lim_reglement")." as datefin";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql.= " WHERE f.paye=0 AND f.fk_statut = 1";
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
$this->nbtodo++;
|
||||
if ($obj->datefin < (time() - $conf->facture->client->warning_delay)) $this->nbtodolate++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\class FactureLigne
|
||||
\brief Classe permettant la gestion des lignes de factures
|
||||
\class FactureLigne
|
||||
\brief Classe permettant la gestion des lignes de factures
|
||||
*/
|
||||
|
||||
class FactureLigne
|
||||
{
|
||||
|
||||
/**
|
||||
* \brief Constructeur d'objets ligne de facture
|
||||
* \param DB handler d'accès base de donnée
|
||||
*/
|
||||
* \brief Constructeur d'objets ligne de facture
|
||||
* \param DB handler d'accès base de donnée
|
||||
*/
|
||||
function FactureLigne($DB)
|
||||
{
|
||||
$this->db= $DB ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Recupére l'objet ligne de facture
|
||||
* \param rowid id de la ligne de facture
|
||||
* \param societe_id id de la societe
|
||||
*/
|
||||
* \brief Recupére l'objet ligne de facture
|
||||
* \param rowid id de la ligne de facture
|
||||
* \param societe_id id de la societe
|
||||
*/
|
||||
function fetch($rowid, $societe_id=0)
|
||||
{
|
||||
$sql = "SELECT fk_product, description, price, qty, rowid, tva_taux, remise, remise_percent, subprice, ".$this->db->pdate("date_start")." as date_start,".$this->db->pdate("date_end")." as date_end";
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -42,31 +42,35 @@
|
||||
|
||||
class Propal
|
||||
{
|
||||
var $id;
|
||||
var $db;
|
||||
var $socidp;
|
||||
var $contactid;
|
||||
var $projetidp;
|
||||
var $author;
|
||||
var $ref;
|
||||
var $datep;
|
||||
var $remise;
|
||||
var $products;
|
||||
var $products_qty;
|
||||
var $note;
|
||||
var $price;
|
||||
var $status;
|
||||
|
||||
var $labelstatut=array();
|
||||
var $labelstatut_short=array();
|
||||
var $id;
|
||||
var $db;
|
||||
var $socidp;
|
||||
var $contactid;
|
||||
var $projetidp;
|
||||
var $author;
|
||||
var $ref;
|
||||
var $datep;
|
||||
var $remise;
|
||||
var $products;
|
||||
var $products_qty;
|
||||
var $note;
|
||||
var $price;
|
||||
var $status;
|
||||
|
||||
var $labelstatut=array();
|
||||
var $labelstatut_short=array();
|
||||
|
||||
var $product=array();
|
||||
|
||||
// Pour board
|
||||
var $nbtodo;
|
||||
var $nbtodolate;
|
||||
|
||||
var $product=array();
|
||||
|
||||
|
||||
/**
|
||||
* \brief Constructeur
|
||||
*/
|
||||
function Propal($DB, $soc_idp="", $propalid=0)
|
||||
function Propal($DB, $soc_idp="", $propalid=0)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
@ -99,66 +103,65 @@ class Propal
|
||||
* \see insert_product
|
||||
*/
|
||||
|
||||
function add_product($idproduct, $qty, $remise_percent=0)
|
||||
function add_product($idproduct, $qty, $remise_percent=0)
|
||||
{
|
||||
if ($idproduct > 0)
|
||||
{
|
||||
$i = sizeof($this->products);
|
||||
$this->products[$i] = $idproduct;
|
||||
if (!$qty)
|
||||
{
|
||||
$qty = 1 ;
|
||||
}
|
||||
$this->products_qty[$i] = $qty;
|
||||
$this->products_remise_percent[$i] = $remise_percent;
|
||||
}
|
||||
if ($idproduct > 0)
|
||||
{
|
||||
$i = sizeof($this->products);
|
||||
$this->products[$i] = $idproduct;
|
||||
if (!$qty)
|
||||
{
|
||||
$qty = 1 ;
|
||||
}
|
||||
$this->products_qty[$i] = $qty;
|
||||
$this->products_remise_percent[$i] = $remise_percent;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Ajout d'un produit dans la proposition, en base
|
||||
* \param idproduct id du produit à ajouter
|
||||
* \param qty quantité
|
||||
* \param remise_percent remise effectuée sur le produit
|
||||
* \return int 0 en cas de succès
|
||||
* \param idproduct id du produit à ajouter
|
||||
* \param qty quantité
|
||||
* \param remise_percent remise effectuée sur le produit
|
||||
* \return int >0 si ok, <0 si ko
|
||||
* \see add_product
|
||||
*/
|
||||
|
||||
function insert_product($idproduct, $qty, $remise_percent=0)
|
||||
function insert_product($idproduct, $qty, $remise_percent=0)
|
||||
{
|
||||
if ($this->statut == 0)
|
||||
{
|
||||
$prod = new Product($this->db, $idproduct);
|
||||
if ($prod->fetch($idproduct) > 0)
|
||||
{
|
||||
$price = $prod->price;
|
||||
$subprice = $prod->price;
|
||||
|
||||
if ($remise_percent > 0)
|
||||
{
|
||||
$remise = round(($prod->price * $remise_percent / 100), 2);
|
||||
$price = $prod->price - $remise;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propaldet (fk_propal, fk_product, qty, price, tva_tx, description, remise_percent, subprice) VALUES ";
|
||||
$sql .= " (".$this->id.",". $idproduct.",'". $qty."','". ereg_replace(",",".",$price)."','".$prod->tva_tx."','".addslashes($prod->label)."','".ereg_replace(",",".",$remise_percent)."','".ereg_replace(",",".",$subprice)."')";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$this->update_price();
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
if ($this->statut == 0)
|
||||
{
|
||||
$prod = new Product($this->db, $idproduct);
|
||||
if ($prod->fetch($idproduct) > 0)
|
||||
{
|
||||
$price = $prod->price;
|
||||
$subprice = $prod->price;
|
||||
|
||||
if ($remise_percent > 0)
|
||||
{
|
||||
$remise = round(($prod->price * $remise_percent / 100), 2);
|
||||
$price = $prod->price - $remise;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propaldet (fk_propal, fk_product, qty, price, tva_tx, description, remise_percent, subprice) VALUES ";
|
||||
$sql .= " (".$this->id.",". $idproduct.",'". $qty."','". ereg_replace(",",".",$price)."','".$prod->tva_tx."','".addslashes($prod->label)."','".ereg_replace(",",".",$remise_percent)."','".ereg_replace(",",".",$subprice)."')";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$this->update_price();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Mise à jour d'une ligne de produit
|
||||
* \param id id de la ligne
|
||||
@ -167,94 +170,92 @@ class Propal
|
||||
* \param remise_percent remise effectuée sur le produit
|
||||
* \return int 0 en cas de succès
|
||||
*/
|
||||
|
||||
function UpdateLigne($id, $subprice, $qty, $remise_percent=0)
|
||||
{
|
||||
if ($this->statut == 0)
|
||||
{
|
||||
$price = $subprice;
|
||||
if ($remise_percent > 0)
|
||||
{
|
||||
$remise = round(($subprice * $remise_percent / 100), 2);
|
||||
$price = $subprice - $remise;
|
||||
}
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propaldet ";
|
||||
$sql .= " SET qty='".$qty."'";
|
||||
$sql .= " , price='". ereg_replace(",",".",$price)."'";
|
||||
$sql .= " , remise_percent='".ereg_replace(",",".",$remise_percent)."'";
|
||||
$sql .= " , subprice='".ereg_replace(",",".",$subprice)."'";
|
||||
$sql .= " WHERE rowid = '".$id."';";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$this->update_price();
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Propal::UpdateLigne Erreur -1");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Propal::UpdateLigne Erreur -2 Propal en mode incompatible pour cette action");
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
function UpdateLigne($id, $subprice, $qty, $remise_percent=0)
|
||||
{
|
||||
if ($this->statut == 0)
|
||||
{
|
||||
$price = $subprice;
|
||||
if ($remise_percent > 0)
|
||||
{
|
||||
$remise = round(($subprice * $remise_percent / 100), 2);
|
||||
$price = $subprice - $remise;
|
||||
}
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propaldet ";
|
||||
$sql .= " SET qty='".$qty."'";
|
||||
$sql .= " , price='". ereg_replace(",",".",$price)."'";
|
||||
$sql .= " , remise_percent='".ereg_replace(",",".",$remise_percent)."'";
|
||||
$sql .= " , subprice='".ereg_replace(",",".",$subprice)."'";
|
||||
$sql .= " WHERE rowid = '".$id."';";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$this->update_price();
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Propal::UpdateLigne Erreur -1");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Propal::UpdateLigne Erreur -2 Propal en mode incompatible pour cette action");
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
function insert_product_generic($p_desc, $p_price, $p_qty, $p_tva_tx=19.6, $remise_percent=0)
|
||||
{
|
||||
if ($this->statut == 0)
|
||||
{
|
||||
if (strlen(trim($p_qty)) == 0)
|
||||
{
|
||||
$p_qty = 1;
|
||||
}
|
||||
|
||||
$p_price = ereg_replace(",",".",$p_price);
|
||||
|
||||
$price = $p_price;
|
||||
$subprice = $p_price;
|
||||
|
||||
if ($remise_percent > 0)
|
||||
{
|
||||
$remise = round(($p_price * $remise_percent / 100), 2);
|
||||
$price = $p_price - $remise;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propaldet (fk_propal, fk_product, qty, price, tva_tx, description, remise_percent, subprice) VALUES ";
|
||||
$sql .= " (".$this->id.", 0,'". $p_qty."','". ereg_replace(",",".",$price)."','".$p_tva_tx."','".$p_desc."','$remise_percent', '".ereg_replace(",",".",$subprice)."') ; ";
|
||||
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
|
||||
if ($this->update_price() > 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print $this->db->error();
|
||||
print "<br>".$sql;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
function insert_product_generic($p_desc, $p_price, $p_qty, $p_tva_tx=19.6, $remise_percent=0)
|
||||
{
|
||||
if ($this->statut == 0)
|
||||
{
|
||||
if (strlen(trim($p_qty)) == 0)
|
||||
{
|
||||
$p_qty = 1;
|
||||
}
|
||||
|
||||
$p_price = ereg_replace(",",".",$p_price);
|
||||
|
||||
$price = $p_price;
|
||||
$subprice = $p_price;
|
||||
|
||||
if ($remise_percent > 0)
|
||||
{
|
||||
$remise = round(($p_price * $remise_percent / 100), 2);
|
||||
$price = $p_price - $remise;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propaldet (fk_propal, fk_product, qty, price, tva_tx, description, remise_percent, subprice) VALUES ";
|
||||
$sql .= " (".$this->id.", 0,'". $p_qty."','". ereg_replace(",",".",$price)."','".$p_tva_tx."','".$p_desc."','$remise_percent', '".ereg_replace(",",".",$subprice)."') ; ";
|
||||
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
|
||||
if ($this->update_price() > 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ -348,12 +349,12 @@ class Propal
|
||||
}
|
||||
else
|
||||
{
|
||||
//dolibarr_print_error($this->db);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
return $this->id;
|
||||
}
|
||||
@ -582,7 +583,6 @@ class Propal
|
||||
}
|
||||
else
|
||||
{
|
||||
//dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -1059,18 +1059,58 @@ class Propal
|
||||
* \param size Libellé court si 0, long si non défini
|
||||
* \return string Libellé
|
||||
*/
|
||||
function LibStatut($statut,$size=1)
|
||||
{
|
||||
if ($size) return $this->labelstatut[$statut];
|
||||
else return $this->labelstatut_short[$statut];
|
||||
}
|
||||
|
||||
}
|
||||
function LibStatut($statut,$size=1)
|
||||
{
|
||||
if ($size) return $this->labelstatut[$statut];
|
||||
else return $this->labelstatut_short[$statut];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Charge indicateurs this->nbtodo et this->nbtodolate de tableau de bord
|
||||
* \param mode opened pour propal à fermer, signed pour propale à facturer
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function load_board($mode)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$this->nbtodo=$this->nbtodolate=0;
|
||||
$sql = "SELECT p.rowid,".$this->db->pdate("p.datec")." as datec,".$this->db->pdate("p.fin_validite")." as datefin";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal as p";
|
||||
if ($mode == 'opened') $sql.= " WHERE p.fk_statut = 1";
|
||||
if ($mode == 'signed') $sql.= " WHERE p.fk_statut = 2";
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
while ($obj=$this->db->fetch_object($resql))
|
||||
{
|
||||
$this->nbtodo++;
|
||||
if ($obj->datefin < (time() - $conf->propal->cloture->warning_delay)) $this->nbtodolate++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
$this->error=$this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\class PropalLigne
|
||||
\brief Classe permettant la gestion des lignes de propales
|
||||
*/
|
||||
|
||||
class PropaleLigne
|
||||
{
|
||||
function PropaleLigne()
|
||||
{
|
||||
}
|
||||
function PropaleLigne()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user