Renommage de certaines fonctions pour voir plus clair dans le code
This commit is contained in:
parent
1f900a8f6a
commit
a36cae106e
@ -422,7 +422,7 @@ if ($_GET['action'] == 'modif' && $user->rights->propale->creer)
|
|||||||
*/
|
*/
|
||||||
$propal = new Propal($db);
|
$propal = new Propal($db);
|
||||||
$propal->fetch($_GET['propalid']);
|
$propal->fetch($_GET['propalid']);
|
||||||
$propal->reopen($user->id);
|
$propal->set_draft($user->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1554,16 +1554,18 @@ if ($conf->expedition->enabled)
|
|||||||
*/
|
*/
|
||||||
if($conf->commande->enabled)
|
if($conf->commande->enabled)
|
||||||
{
|
{
|
||||||
$coms = $propal->associated_orders();
|
$propal->loadOrders();
|
||||||
|
$coms = $propal->commandes;
|
||||||
if (sizeof($coms) > 0)
|
if (sizeof($coms) > 0)
|
||||||
{
|
{
|
||||||
print '<br>';
|
if ($somethingshown) { print '<br>'; $somethingshown=1; }
|
||||||
print_titre($langs->trans('RelatedOrders'));
|
print_titre($langs->trans('RelatedOrders'));
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td>'.$langs->trans("Ref").'</td>';
|
print '<td>'.$langs->trans("Ref").'</td>';
|
||||||
print '<td align="center">'.$langs->trans("Date").'</td>';
|
print '<td align="center">'.$langs->trans("Date").'</td>';
|
||||||
print '<td align="right">'.$langs->trans("Price").'</td>';
|
print '<td align="right">'.$langs->trans("Price").'</td>';
|
||||||
|
print '<td align="right">'.$langs->trans("Status").'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
$var=true;
|
$var=true;
|
||||||
for ($i = 0 ; $i < sizeof($coms) ; $i++)
|
for ($i = 0 ; $i < sizeof($coms) ; $i++)
|
||||||
@ -1573,6 +1575,7 @@ if ($conf->expedition->enabled)
|
|||||||
print '<a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$coms[$i]->id.'">'.img_object($langs->trans("ShowOrder"),"order").' '.$coms[$i]->ref."</a></td>\n";
|
print '<a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$coms[$i]->id.'">'.img_object($langs->trans("ShowOrder"),"order").' '.$coms[$i]->ref."</a></td>\n";
|
||||||
print '<td align="center">'.dolibarr_print_date($coms[$i]->date).'</td>';
|
print '<td align="center">'.dolibarr_print_date($coms[$i]->date).'</td>';
|
||||||
print '<td align="right">'.$coms[$i]->total_ttc.'</td>';
|
print '<td align="right">'.$coms[$i]->total_ttc.'</td>';
|
||||||
|
print '<td align="right">'.$coms[$i]->getLibStatut(3).'</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
}
|
}
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|||||||
@ -260,7 +260,7 @@ class Commande extends CommonObject
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function reopen($userid)
|
function set_draft($userid)
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 0";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 0";
|
||||||
|
|
||||||
@ -1052,11 +1052,11 @@ class Commande extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoie un tableau avec les expéditions par ligne
|
* \brief Charge tableau avec les expéditions par ligne
|
||||||
* \param filtre_statut Filtre sur statut
|
* \param filtre_statut Filtre sur statut
|
||||||
* \return int 0 si OK, <0 si KO
|
* \return int 0 si OK, <0 si KO
|
||||||
*/
|
*/
|
||||||
function expedition_array($filtre_statut=-1)
|
function loadExpeditions($filtre_statut=-1)
|
||||||
{
|
{
|
||||||
$this->expeditions = array();
|
$this->expeditions = array();
|
||||||
$sql = 'SELECT fk_product, sum(ed.qty)';
|
$sql = 'SELECT fk_product, sum(ed.qty)';
|
||||||
@ -1068,11 +1068,11 @@ class Commande extends CommonObject
|
|||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows();
|
$num = $this->db->num_rows($result);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$row = $this->db->fetch_row( $i);
|
$row = $this->db->fetch_row($result);
|
||||||
$this->expeditions[$row[0]] = $row[1];
|
$this->expeditions[$row[0]] = $row[1];
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -420,7 +420,7 @@ if ($_GET['action'] == 'modif' && $user->rights->commande->creer)
|
|||||||
*/
|
*/
|
||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
$commande->fetch($_GET['id']);
|
$commande->fetch($_GET['id']);
|
||||||
$commande->reopen($user->id);
|
$commande->set_draft($user->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -203,7 +203,7 @@ if ($_GET['action'] == 'modif' && $user->rights->facture->modifier && $conf->glo
|
|||||||
// On vérifie si aucun paiement n'a été effectué
|
// On vérifie si aucun paiement n'a été effectué
|
||||||
if ($resteapayer == $fac->total_ttc && $fac->paye == 0 && $ventilExportCompta == 0)
|
if ($resteapayer == $fac->total_ttc && $fac->paye == 0 && $ventilExportCompta == 0)
|
||||||
{
|
{
|
||||||
$fac->reopen($user);
|
$fac->set_draft($user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -73,7 +73,7 @@ if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user-
|
|||||||
|
|
||||||
$paiement = new Paiement($db);
|
$paiement = new Paiement($db);
|
||||||
$paiement->id = $_GET['id'];
|
$paiement->id = $_GET['id'];
|
||||||
if ( $paiement->valide() == 0 )
|
if ($paiement->valide() >= 0)
|
||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
Header('Location: fiche.php?id='.$paiement->id);
|
Header('Location: fiche.php?id='.$paiement->id);
|
||||||
|
|||||||
@ -132,7 +132,7 @@ class RejetPrelevement
|
|||||||
|
|
||||||
/* Valide le paiement */
|
/* Valide le paiement */
|
||||||
|
|
||||||
if ($pai->valide() <> 0)
|
if ($pai->valide() < 0)
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
dolibarr_syslog("RejetPrelevement::Create Erreur validation du paiement");
|
dolibarr_syslog("RejetPrelevement::Create Erreur validation du paiement");
|
||||||
|
|||||||
@ -543,7 +543,7 @@ et non globalement
|
|||||||
print '<a class="butAction" href="facture.php?propalid='.$propal->id."&action=create\">".$langs->trans("BuildBill")."</a>";
|
print '<a class="butAction" href="facture.php?propalid='.$propal->id."&action=create\">".$langs->trans("BuildBill")."</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($propal->statut == 2 && sizeof($propal->getFactureListeArray()))
|
if ($propal->statut == 2 && sizeof($propal->getInvoiceArrayList()))
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="propal.php?propalid='.$propal->id."&action=setstatut&statut=4\">".$langs->trans("ClassifyBilled")."</a>";
|
print '<a class="butAction" href="propal.php?propalid='.$propal->id."&action=setstatut&statut=4\">".$langs->trans("ClassifyBilled")."</a>";
|
||||||
}
|
}
|
||||||
@ -575,12 +575,10 @@ et non globalement
|
|||||||
*/
|
*/
|
||||||
if($conf->commande->enabled)
|
if($conf->commande->enabled)
|
||||||
{
|
{
|
||||||
$coms = $propal->associated_orders();
|
$propal->loadOrders();
|
||||||
|
$coms = $propal->commandes;
|
||||||
if (sizeof($coms) > 0)
|
if (sizeof($coms) > 0)
|
||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php');
|
|
||||||
$staticcommande=new Commande($db);
|
|
||||||
|
|
||||||
$total=0;
|
$total=0;
|
||||||
if ($somethingshown) { print '<br>'; $somethingshown=1; }
|
if ($somethingshown) { print '<br>'; $somethingshown=1; }
|
||||||
print_titre($langs->trans('RelatedOrders'));
|
print_titre($langs->trans('RelatedOrders'));
|
||||||
@ -599,7 +597,7 @@ et non globalement
|
|||||||
print '<a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$coms[$i]->id.'">'.img_object($langs->trans("ShowOrder"),"order").' '.$coms[$i]->ref."</a></td>\n";
|
print '<a href="'.DOL_URL_ROOT.'/commande/fiche.php?id='.$coms[$i]->id.'">'.img_object($langs->trans("ShowOrder"),"order").' '.$coms[$i]->ref."</a></td>\n";
|
||||||
print '<td align="center">'.dolibarr_print_date($coms[$i]->date).'</td>';
|
print '<td align="center">'.dolibarr_print_date($coms[$i]->date).'</td>';
|
||||||
print '<td align="right">'.price($coms[$i]->total_ttc).'</td>';
|
print '<td align="right">'.price($coms[$i]->total_ttc).'</td>';
|
||||||
print '<td align="right">'.$staticcommande->LibStatut($coms[$i]->statut,$coms[$i]->facturee,3).'</td>';
|
print '<td align="right">'.$coms[$i]->getLibStatut(3).'</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
$total = $total + $objp->total;
|
$total = $total + $objp->total;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,7 +85,7 @@ if ($_GET["id"] > 0)
|
|||||||
$commande = New Commande($db);
|
$commande = New Commande($db);
|
||||||
if ( $commande->fetch($_GET["id"]) > 0)
|
if ( $commande->fetch($_GET["id"]) > 0)
|
||||||
{
|
{
|
||||||
$commande->expedition_array(1);
|
$commande->loadExpeditions(1);
|
||||||
|
|
||||||
$soc = new Societe($db);
|
$soc = new Societe($db);
|
||||||
$soc->fetch($commande->socidp);
|
$soc->fetch($commande->socidp);
|
||||||
|
|||||||
@ -186,7 +186,7 @@ if ($_GET["action"] == 'create')
|
|||||||
}
|
}
|
||||||
|
|
||||||
$commande = new Commande($db);
|
$commande = new Commande($db);
|
||||||
$commande->expedition_array();
|
$commande->loadExpeditions();
|
||||||
|
|
||||||
if ( $commande->fetch($_GET["commande_id"]))
|
if ( $commande->fetch($_GET["commande_id"]))
|
||||||
{
|
{
|
||||||
@ -274,7 +274,7 @@ if ($_GET["action"] == 'create')
|
|||||||
$lignes = $commande->fetch_lignes(1);
|
$lignes = $commande->fetch_lignes(1);
|
||||||
|
|
||||||
/* Lecture des expeditions déjà effectuées */
|
/* Lecture des expeditions déjà effectuées */
|
||||||
$commande->expedition_array();
|
$commande->loadExpeditions();
|
||||||
|
|
||||||
$num = sizeof($commande->lignes);
|
$num = sizeof($commande->lignes);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|||||||
@ -1140,7 +1140,7 @@ class Facture extends CommonObject
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function reopen($userid)
|
function set_draft($userid)
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."facture SET fk_statut = 0";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."facture SET fk_statut = 0";
|
||||||
$sql .= " WHERE rowid = $this->id;";
|
$sql .= " WHERE rowid = $this->id;";
|
||||||
|
|||||||
@ -136,8 +136,11 @@ if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == 'yes' && $user->
|
|||||||
$soc = new Societe($db);
|
$soc = new Societe($db);
|
||||||
$soc->fetch($commande->socidp);
|
$soc->fetch($commande->socidp);
|
||||||
$result = $commande->valid($user);
|
$result = $commande->valid($user);
|
||||||
Header("Location: fiche.php?id=".$_GET["id"]);
|
if ($result >= 0)
|
||||||
exit;
|
{
|
||||||
|
Header("Location: fiche.php?id=".$_GET["id"]);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST["action"] == 'confirm_approve' && $_POST["confirm"] == 'yes' && $user->rights->fournisseur->commande->approuver)
|
if ($_POST["action"] == 'confirm_approve' && $_POST["confirm"] == 'yes' && $user->rights->fournisseur->commande->approuver)
|
||||||
|
|||||||
@ -73,7 +73,7 @@ if ($_POST['action'] == 'confirm_valide' && $_POST['confirm'] == 'yes' && $user-
|
|||||||
|
|
||||||
$paiement = new PaiementFourn($db);
|
$paiement = new PaiementFourn($db);
|
||||||
$paiement->id = $_GET['id'];
|
$paiement->id = $_GET['id'];
|
||||||
if ( $paiement->valide() == 0 )
|
if ($paiement->valide() >= 0)
|
||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
Header('Location: fiche.php?id='.$paiement->id);
|
Header('Location: fiche.php?id='.$paiement->id);
|
||||||
|
|||||||
@ -444,11 +444,10 @@ class Propal extends CommonObject
|
|||||||
|
|
||||||
dolibarr_syslog("Propal::create ref=".$this->ref);
|
dolibarr_syslog("Propal::create ref=".$this->ref);
|
||||||
|
|
||||||
$soc = new Societe($this->db);
|
|
||||||
$soc->fetch($this->socidp);
|
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
|
$this->fetch_client();
|
||||||
|
|
||||||
// Insertion dans la base
|
// Insertion dans la base
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propal (fk_soc, price, remise, remise_percent, remise_absolue,";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propal (fk_soc, price, remise, remise_percent, remise_absolue,";
|
||||||
$sql.= " tva, total, datep, datec, ref, fk_user_author, note, note_public, model_pdf, fin_validite,";
|
$sql.= " tva, total, datep, datec, ref, fk_user_author, note, note_public, model_pdf, fin_validite,";
|
||||||
@ -476,10 +475,10 @@ class Propal extends CommonObject
|
|||||||
$prod = new Product($this->db, $this->products[$i]);
|
$prod = new Product($this->db, $this->products[$i]);
|
||||||
if ($prod->fetch($this->products[$i]))
|
if ($prod->fetch($this->products[$i]))
|
||||||
{
|
{
|
||||||
$tva_tx = get_default_tva($mysoc,$soc,$prod->tva_tx);
|
$tva_tx = get_default_tva($mysoc,$this->client,$prod->tva_tx);
|
||||||
// multiprix
|
// multiprix
|
||||||
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||||
$price = $prod->multiprices[$soc->price_level];
|
$price = $prod->multiprices[$this->client->price_level];
|
||||||
else
|
else
|
||||||
$price = $prod->price;
|
$price = $prod->price;
|
||||||
|
|
||||||
@ -1291,7 +1290,7 @@ class Propal extends CommonObject
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function reopen($userid)
|
function set_draft($userid)
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 0";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 0";
|
||||||
|
|
||||||
@ -1366,9 +1365,9 @@ class Propal extends CommonObject
|
|||||||
/**
|
/**
|
||||||
* \brief Renvoie un tableau contenant les numéros de commandes associées
|
* \brief Renvoie un tableau contenant les numéros de commandes associées
|
||||||
* \remarks Fonction plus light que associated_orders
|
* \remarks Fonction plus light que associated_orders
|
||||||
* \sa associated_orders
|
* \sa loadOrders
|
||||||
*/
|
*/
|
||||||
function commande_liste_array ()
|
function getOrderArrayList()
|
||||||
{
|
{
|
||||||
$ga = array();
|
$ga = array();
|
||||||
|
|
||||||
@ -1398,26 +1397,29 @@ class Propal extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoie un tableau contenant les commandes associées
|
* \brief Charge tableau contenant les commandes associées
|
||||||
* \remarks Fonction plus lourde que commande_liste_array
|
* \remarks Fonction plus lourde que getOrderArrayList
|
||||||
* \sa commande_liste_array
|
* \return int <0 si ko, >0 si ok
|
||||||
|
* \sa getOrdersArrayList
|
||||||
*/
|
*/
|
||||||
function associated_orders()
|
function loadOrders()
|
||||||
{
|
{
|
||||||
$ga = array();
|
$this->commandes = array();
|
||||||
|
|
||||||
|
$ga = array();
|
||||||
$sql = "SELECT fk_commande FROM ".MAIN_DB_PREFIX."co_pr";
|
$sql = "SELECT fk_commande FROM ".MAIN_DB_PREFIX."co_pr";
|
||||||
$sql.= " WHERE fk_propale = " . $this->id;
|
$sql.= " WHERE fk_propale = " . $this->id;
|
||||||
if ($this->db->query($sql) )
|
$result=$this->db->query($sql);
|
||||||
|
if ($result)
|
||||||
{
|
{
|
||||||
$nump = $this->db->num_rows();
|
$nump = $this->db->num_rows($result);
|
||||||
|
|
||||||
if ($nump)
|
if ($nump)
|
||||||
{
|
{
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $nump)
|
while ($i < $nump)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object();
|
$obj = $this->db->fetch_object($result);
|
||||||
$order=new Commande($this->db);
|
$order=new Commande($this->db);
|
||||||
|
|
||||||
if ($obj->fk_commande)
|
if ($obj->fk_commande)
|
||||||
@ -1428,11 +1430,13 @@ class Propal extends CommonObject
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $ga;
|
$this->commandes=$ga;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print $this->db->error();
|
$this->error=$this->db->error();
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1440,9 +1444,9 @@ class Propal extends CommonObject
|
|||||||
* \brief Renvoie un tableau contenant les numéros de factures associées
|
* \brief Renvoie un tableau contenant les numéros de factures associées
|
||||||
* \return array Tableau des id de factures
|
* \return array Tableau des id de factures
|
||||||
*/
|
*/
|
||||||
function getFactureListeArray ()
|
function getInvoiceArrayList ()
|
||||||
{
|
{
|
||||||
return $this->FactureListeArray($this->id);
|
return $this->InvoiceArrayList($this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1450,7 +1454,7 @@ class Propal extends CommonObject
|
|||||||
* \param id Id propal
|
* \param id Id propal
|
||||||
* \return array Tableau des id de factures
|
* \return array Tableau des id de factures
|
||||||
*/
|
*/
|
||||||
function FactureListeArray($id)
|
function InvoiceArrayList($id)
|
||||||
{
|
{
|
||||||
$ga = array();
|
$ga = array();
|
||||||
|
|
||||||
@ -1479,60 +1483,60 @@ class Propal extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Efface propal
|
* \brief Efface propal
|
||||||
* \param user Objet du user qui efface
|
* \param user Objet du user qui efface
|
||||||
*/
|
*/
|
||||||
function delete($user)
|
function delete($user)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id;
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id;
|
||||||
if ( $this->db->query($sql) )
|
if ( $this->db->query($sql) )
|
||||||
{
|
{
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id;
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id;
|
||||||
if ( $this->db->query($sql) )
|
if ( $this->db->query($sql) )
|
||||||
{
|
{
|
||||||
|
|
||||||
// On efface le répertoire du pdf
|
// On efface le répertoire du pdf
|
||||||
$propalref = sanitize_string($this->ref);
|
$propalref = sanitize_string($this->ref);
|
||||||
if ($conf->propal->dir_output)
|
if ($conf->propal->dir_output)
|
||||||
{
|
{
|
||||||
$dir = $conf->propal->dir_output . "/" . $propalref ;
|
$dir = $conf->propal->dir_output . "/" . $propalref ;
|
||||||
$file = $conf->propal->dir_output . "/" . $propalref . "/" . $propalref . ".pdf";
|
$file = $conf->propal->dir_output . "/" . $propalref . "/" . $propalref . ".pdf";
|
||||||
if (file_exists($file))
|
if (file_exists($file))
|
||||||
{
|
{
|
||||||
propale_delete_preview($this->db, $this->id, $this->ref);
|
propale_delete_preview($this->db, $this->id, $this->ref);
|
||||||
|
|
||||||
if (!dol_delete_file($file))
|
if (!dol_delete_file($file))
|
||||||
{
|
{
|
||||||
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
|
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (file_exists($dir))
|
if (file_exists($dir))
|
||||||
{
|
{
|
||||||
if (!dol_delete_dir($dir))
|
if (!dol_delete_dir($dir))
|
||||||
{
|
{
|
||||||
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
|
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dolibarr_syslog("Suppression de la proposition $this->id par $user->fullname ($user->id)");
|
dolibarr_syslog("Suppression de la proposition $this->id par $user->fullname ($user->id)");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Mets à jour les commentaires privés
|
* \brief Mets à jour les commentaires privés
|
||||||
@ -1820,10 +1824,13 @@ class Propal extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function create_from()
|
function create_from()
|
||||||
{
|
{
|
||||||
|
$this->fin_validite = $this->datep + ($this->duree_validite * 24 * 3600);
|
||||||
|
|
||||||
|
dolibarr_syslog("Propal::create_from ref=".$this->ref);
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$this->fin_validite = $this->datep + ($this->duree_validite * 24 * 3600);
|
$this->fetch_client();
|
||||||
|
|
||||||
// Insertion dans la base
|
// Insertion dans la base
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propal (fk_soc, price, remise, remise_percent, remise_absolue,";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propal (fk_soc, price, remise, remise_percent, remise_absolue,";
|
||||||
@ -1834,6 +1841,7 @@ class Propal extends CommonObject
|
|||||||
$sql.= "'".addslashes($this->note_public)."',";
|
$sql.= "'".addslashes($this->note_public)."',";
|
||||||
$sql.= "'$this->modelpdf','".$this->db->idate($this->fin_validite)."',";
|
$sql.= "'$this->modelpdf','".$this->db->idate($this->fin_validite)."',";
|
||||||
$sql.= " '$this->cond_reglement_id', '$this->mode_reglement_id', '".$this->db->idate($this->date_livraison)."', '$this->adresse_livraison_id')";
|
$sql.= " '$this->cond_reglement_id', '$this->mode_reglement_id', '".$this->db->idate($this->date_livraison)."', '$this->adresse_livraison_id')";
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -1848,10 +1856,10 @@ class Propal extends CommonObject
|
|||||||
{
|
{
|
||||||
$resql = $this->addline(
|
$resql = $this->addline(
|
||||||
$this->id,
|
$this->id,
|
||||||
$prod->description,
|
$ligne->description,
|
||||||
$price,
|
$ligne->price,
|
||||||
$ligne->qty,
|
$ligne->qty,
|
||||||
$tva_tx,
|
$ligne->tva_tx,
|
||||||
$ligne->fk_product,
|
$ligne->fk_product,
|
||||||
$ligne->remise_percent
|
$ligne->remise_percent
|
||||||
);
|
);
|
||||||
@ -1864,32 +1872,30 @@ class Propal extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Affectation au projet
|
if ($resql)
|
||||||
if ($this->projetidp)
|
{
|
||||||
{
|
// Mise a jour infos dénormalisés
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_projet=$this->projetidp WHERE ref='$this->ref'";
|
$resql=$this->update_price();
|
||||||
$result=$this->db->query($sql);
|
if ($resql)
|
||||||
}
|
{
|
||||||
|
// Appel des triggers
|
||||||
$resql=$this->update_price();
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
if ($resql)
|
$interface=new Interfaces($this->db);
|
||||||
{
|
$result=$interface->run_triggers('PROPAL_CREATE',$this,$user,$langs,$conf);
|
||||||
// Appel des triggers
|
// Fin appel triggers
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
|
||||||
$interface=new Interfaces($this->db);
|
$this->db->commit();
|
||||||
$result=$interface->run_triggers('PROPAL_CREATE',$this,$user,$langs,$conf);
|
dolibarr_syslog("Propal::Create_from done id=".$this->id);
|
||||||
// Fin appel triggers
|
return $this->id;
|
||||||
|
}
|
||||||
$this->db->commit();
|
else
|
||||||
return $this->id;
|
{
|
||||||
}
|
$this->error=$this->db->error();
|
||||||
else
|
dolibarr_syslog("Propal::Create_from -2 ".$this->error);
|
||||||
{
|
$this->db->rollback();
|
||||||
$this->error=$this->db->error();
|
return -2;
|
||||||
dolibarr_syslog("Propal::Create_from -2 ".$this->error);
|
}
|
||||||
$this->db->rollback();
|
}
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1900,6 +1906,8 @@ class Propal extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->db->commit();
|
||||||
|
dolibarr_syslog("Propal::Create_from done id=".$this->id);
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user