diff --git a/htdocs/admin/fournisseur.php b/htdocs/admin/fournisseur.php index 3eeb4a17b3a..caed089e46d 100644 --- a/htdocs/admin/fournisseur.php +++ b/htdocs/admin/fournisseur.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2007 Laurent Destailleur - * Copyright (C) 2005-2006 Regis Houssin + * Copyright (C) 2005-2007 Regis Houssin * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * @@ -49,8 +49,8 @@ if ($_GET["action"] == 'specimen') { $modele=$_GET["module"]; - $facture = new CommandeFournisseur($db); - $facture->initAsSpecimen(); + $commande = new CommandeFournisseur($db); + $commande->initAsSpecimen(); // Charge le modele $dir = DOL_DOCUMENT_ROOT . "/fourn/commande/modules/pdf/"; @@ -62,7 +62,7 @@ if ($_GET["action"] == 'specimen') $obj = new $classname($db); - if ($obj->write_pdf_file($facture,$langs) > 0) + if ($obj->write_pdf_file($commande,$langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=commande_fournisseur&file=SPECIMEN.pdf"); return; @@ -135,6 +135,13 @@ if ($_POST["action"] == 'addcat') $fourn->CreateCategory($user,$_POST["cat"]); } +// défini les constantes du modèle orchidee +if ($_POST["action"] == 'updateMatrice') dolibarr_set_const($db, "COMMANDE_FOURNISSEUR_NUM_MATRICE",$_POST["matrice"]); +if ($_POST["action"] == 'updatePrefixCommande') dolibarr_set_const($db, "COMMANDE_FOURNISSEUR_NUM_PREFIX",$_POST["prefixcommande"]); +if ($_POST["action"] == 'setOffset') dolibarr_set_const($db, "COMMANDE_FOURNISSEUR_NUM_DELTA",$_POST["offset"]); +if ($_POST["action"] == 'setFiscalMonth') dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START",$_POST["fiscalmonth"]); +if ($_POST["action"] == 'setNumRestart') dolibarr_set_const($db, "COMMANDE_FOURNISSEUR_NUM_RESTART_BEGIN_YEAR",$_POST["numrestart"]); + /* * Affichage page */ @@ -196,13 +203,15 @@ if ($handle) } print ''; + $commande = new CommandeFournisseur($db); + // Info $htmltooltip=''; - $nextval=$module->getNextValue($mysoc); + $nextval=$module->getNextValue($mysoc,$commande); if ($nextval != $langs->trans("NotAvailable")) - { - $htmltooltip=''.$langs->trans("NextValue").': '.$nextval; - } + { + $htmltooltip=''.$langs->trans("NextValue").': '.$nextval; + } print ''; print $html->textwithhelp('',$htmltooltip,1,0); print ''; diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 8ad0b5c34af..c494c06166a 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -897,10 +897,19 @@ class Commande extends CommonObject */ function fetch($id) { - $sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva, c.fk_cond_reglement, c.fk_mode_reglement,'; - $sql.= ' '.$this->db->pdate('c.date_commande').' as date_commande, '.$this->db->pdate('c.date_livraison').' as date_livraison,'; - $sql.= ' c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as facturee, c.note, c.note_public, c.ref_client, c.model_pdf, c.fk_adresse_livraison'; + $sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut'; + $sql.= ', c.amount_ht, c.total_ht, c.total_ttc, c.tva, c.fk_cond_reglement, c.fk_mode_reglement'; + $sql.= ', '.$this->db->pdate('c.date_commande').' as date_commande'; + $sql.= ', '.$this->db->pdate('c.date_livraison').' as date_livraison'; + $sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as facturee'; + $sql.= ', c.note, c.note_public, c.ref_client, c.model_pdf, c.fk_adresse_livraison'; + $sql.= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; + $sql.= ', cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle, cr.libelle_facture as cond_reglement_libelle_facture'; + $sql.= ', cp.fk_propale'; $sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'cond_reglement as cr ON (c.fk_cond_reglement = cr.rowid)'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as p ON (c.fk_mode_reglement = p.id)'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'co_pr as cp ON (cp.fk_commande = c.rowid)'; $sql.= ' WHERE c.rowid = '.$id; dolibarr_syslog("Commande::fetch sql=$sql"); @@ -911,84 +920,81 @@ class Commande extends CommonObject $obj = $this->db->fetch_object($result); if ($obj) { - $this->id = $obj->rowid; - $this->ref = $obj->ref; - $this->ref_client = $obj->ref_client; - $this->socid = $obj->fk_soc; - $this->statut = $obj->fk_statut; - $this->user_author_id = $obj->fk_user_author; - $this->total_ht = $obj->total_ht; - $this->total_tva = $obj->tva; - $this->total_ttc = $obj->total_ttc; - $this->date = $obj->date_commande; - $this->remise = $obj->remise; - $this->remise_percent = $obj->remise_percent; - $this->remise_absolue = $obj->remise_absolue; - $this->source = $obj->source; - $this->facturee = $obj->facturee; - $this->note = $obj->note; - $this->note_public = $obj->note_public; - $this->projet_id = $obj->fk_projet; - $this->modelpdf = $obj->model_pdf; - $this->cond_reglement_id = $obj->fk_cond_reglement; - $this->mode_reglement_id = $obj->fk_mode_reglement; - $this->date_livraison = $obj->date_livraison; - $this->adresse_livraison_id = $obj->fk_adresse_livraison; + $this->id = $obj->rowid; + $this->ref = $obj->ref; + $this->ref_client = $obj->ref_client; + $this->socid = $obj->fk_soc; + $this->statut = $obj->fk_statut; + $this->user_author_id = $obj->fk_user_author; + $this->total_ht = $obj->total_ht; + $this->total_tva = $obj->tva; + $this->total_ttc = $obj->total_ttc; + $this->date = $obj->date_commande; + $this->remise = $obj->remise; + $this->remise_percent = $obj->remise_percent; + $this->remise_absolue = $obj->remise_absolue; + $this->source = $obj->source; + $this->facturee = $obj->facturee; + $this->note = $obj->note; + $this->note_public = $obj->note_public; + $this->projet_id = $obj->fk_projet; + $this->modelpdf = $obj->model_pdf; + $this->mode_reglement_id = $obj->fk_mode_reglement; + $this->mode_reglement_code = $obj->mode_reglement_code; + $this->mode_reglement = $obj->mode_reglement_libelle; + $this->cond_reglement_id = $obj->fk_cond_reglement; + $this->cond_reglement_code = $obj->cond_reglement_code; + $this->cond_reglement = $obj->cond_reglement_libelle; + $this->cond_reglement_facture = $obj->cond_reglement_libelle_facture; + $this->date_livraison = $obj->date_livraison; + $this->adresse_livraison_id = $obj->fk_adresse_livraison; + $this->propale_id = $obj->fk_propale; + $this->lignes = array(); + if ($this->statut == 0) $this->brouillon = 1; $this->db->free(); - - if ($this->cond_reglement_id) - { - $sql = "SELECT rowid, libelle, code"; - $sql.= " FROM ".MAIN_DB_PREFIX."cond_reglement"; - $sql.= " WHERE rowid = ".$this->cond_reglement_id; - - $resqlcond = $this->db->query($sql); - - if ($resqlcond) - { - $objc = $this->db->fetch_object($resqlcond); - $this->cond_reglement = $objc->libelle; - $this->cond_reglement_code = $objc->code; - } - } - - $this->lignes = $this->fetch_lignes(); - + + if ($this->propale_id) + { + $sqlp = "SELECT ref"; + $sqlp.= " FROM ".MAIN_DB_PREFIX."propal"; + $sqlp.= " WHERE rowid = ".$this->propale_id; + + $resqlprop = $this->db->query($sqlp); + + if ($resqlprop) + { + $objp = $this->db->fetch_object($resqlprop); + $this->propale_ref = $objp->ref; + $this->db->free($resqlprop); + } + } + /* - * Propale associée + * Lignes */ - $sql = 'SELECT cp.fk_propale'; - $sql .= ' FROM '.MAIN_DB_PREFIX.'co_pr as cp'; - $sql .= ' WHERE cp.fk_commande = '.$this->id; - if ($this->db->query($sql)) - { - if ($this->db->num_rows()) - { - $obj = $this->db->fetch_object(); - $this->propale_id = $obj->fk_propale; - } - return 1; - } - else - { - dolibarr_print_error($this->db); - return -1; - } + $result=$this->fetch_lines(); + if ($result < 0) + { + return -3; + } + return 1; } - else + else { - $this->error="Order not found"; + dolibarr_syslog('Commande::Fetch Error rowid='.$rowid.' numrows=0 sql='.$sql); + $this->error='Order with id '.$rowid.' not found sql='.$sql; return -2; } - } - else - { - dolibarr_print_error($this->db); - return -3; - } + } + else + { + dolibarr_syslog('Commande::Fetch Error rowid='.$rowid.' Erreur dans fetch de la commande'); + $this->error=$this->db->error(); + return -1; } +} /** @@ -1095,9 +1101,8 @@ class Commande extends CommonObject * \param only_product Ne renvoie que ligne liées à des produits physiques prédéfinis * \return array Tableau de CommandeLigne */ - function fetch_lignes($only_product=0) + function fetch_lines($only_product=0) { - $this->lignes = array(); $sql = 'SELECT l.rowid, l.fk_product, l.fk_commande, l.description, l.price, l.qty, l.tva_tx,'; $sql.= ' l.fk_remise_except, l.remise_percent, l.subprice, l.coef, l.rang, l.info_bits,'; $sql.= ' l.total_ht, l.total_ttc, l.total_tva,'; @@ -1110,12 +1115,12 @@ class Commande extends CommonObject $result = $this->db->query($sql); if ($result) - { - $num = $this->db->num_rows(); - $i = 0; - while ($i < $num) - { - $objp = $this->db->fetch_object($result); + { + $num = $this->db->num_rows($result); + $i = 0; + while ($i < $num) + { + $objp = $this->db->fetch_object($result); $ligne = new CommandeLigne($this->db); $ligne->rowid = $objp->rowid; @@ -1145,14 +1150,20 @@ class Commande extends CommonObject $this->lignes[$i] = $ligne; $i++; } - $this->db->free(); - } - return $this->lignes; + $this->db->free($result); + return 1; + } + else + { + $this->error=$this->db->error(); + dolibarr_syslog('Commande::fetch_lines: Error '.$this->error); + return -3; + } } /** - * \brief Renvoie nombre de lignes de type produits. Doit etre appelé après fetch_lignes + * \brief Renvoie nombre de lignes de type produits. Doit etre appelé après fetch_lines * \return int <0 si ko, Nbre de lignes produits sinon */ function getNbOfProductsLines() diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 46a4a6a8fae..4d3843cc1f4 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -590,7 +590,8 @@ if ($_POST['action'] == 'add' && $user->rights->facture->creer) $comm = New Commande($db); if ( $comm->fetch($_POST['commandeid']) ) { - $lines = $comm->fetch_lignes(); + $comm->fetch_lines(); + $lines = $comm->lignes; for ($i = 0 ; $i < sizeof($lines) ; $i++) { $desc=($lines[$i]->desc ? $lines[$i]->desc : $lines[$i]->libelle); @@ -2553,7 +2554,7 @@ else } // Valider - if ($fac->statut == 0 && $num_lignes > 0 && $fac->total_ttc >= 0) + if ($fac->statut == 0 && $num_lignes > 0 && (($fac->type < 2 && $fac->total_ttc >= 0) || ($fac->type == 2 && $fac->total_ttc <= 0))) { if ($user->rights->facture->valider) { diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php index 0d02f606357..19b703e8e52 100644 --- a/htdocs/expedition/expedition.class.php +++ b/htdocs/expedition/expedition.class.php @@ -97,7 +97,7 @@ class Expedition extends CommonObject $this->commande = new Commande($this->db); $this->commande->id = $this->commande_id; - $this->commande->fetch_lignes(); + $this->commande->fetch_lines(); /* * Insertion des produits dans la base diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index d971c8e516f..6bb48853e4b 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -77,7 +77,7 @@ if ($_POST["action"] == 'add') // avec qté à livrer $commande = new Commande($db); $commande->fetch($expedition->commande_id); - $commande->fetch_lignes(); + $commande->fetch_lines(); for ($i = 0 ; $i < sizeof($commande->lignes) ; $i++) { $qty = "qtyl".$i; @@ -271,7 +271,7 @@ if ($_GET["action"] == 'create') */ echo '
'; - $lignes = $commande->fetch_lignes(1); + $lignes = $commande->fetch_lines(1); /* Lecture des expeditions déjà effectuées */ $commande->loadExpeditions(); diff --git a/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php b/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php index 37224b00e7d..95df34cfb6a 100644 --- a/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php +++ b/htdocs/expedition/mods/pdf/pdf_expedition_merou.modules.php @@ -182,7 +182,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition //Generation du tableau $this->_tableau($pdf, $tab_top, $tab_height, $nexY); //Recuperation des produits de la commande. - $this->expe->commande->fetch_lignes(1); + $this->expe->commande->fetch_lines(1); $Produits = $this->expe->commande->lignes; $nblignes = sizeof($Produits); for ($i = 0 ; $i < $nblignes ; $i++){ diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 12626b8858f..df79fd4b0dc 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -467,34 +467,31 @@ class Facture extends CommonObject $this->lignes = array(); if ($this->commande_id) - { - $sql = "SELECT ref"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande"; - $sql.= " WHERE rowid = ".$this->commande_id; + { + $sql = "SELECT ref"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande"; + $sql.= " WHERE rowid = ".$this->commande_id; - $resqlcomm = $this->db->query($sql); + $resqlcomm = $this->db->query($sql); - if ($resqlcomm) - { - $objc = $this->db->fetch_object($resqlcomm); - $this->commande_ref = $objc->ref; - $this->db->free($resqlcomm); - } - } + if ($resqlcomm) + { + $objc = $this->db->fetch_object($resqlcomm); + $this->commande_ref = $objc->ref; + $this->db->free($resqlcomm); + } + } - if ($this->statut == 0) - { - $this->brouillon = 1; - } + if ($this->statut == 0) $this->brouillon = 1; /* * Lignes */ $result=$this->fetch_lines(); if ($result < 0) - { - return -3; - } + { + return -3; + } return 1; } else @@ -568,15 +565,15 @@ class Facture extends CommonObject $this->lignes[$i] = $faclig; $i++; } - $this->db->free($result); - return 1; - } - else - { - $this->error=$this->db->error(); - dolibarr_syslog('Facture::fetch_lines: Error '.$this->error); - return -3; - } + $this->db->free($result); + return 1; + } + else + { + $this->error=$this->db->error(); + dolibarr_syslog('Facture::fetch_lines: Error '.$this->error); + return -3; + } } /** diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index b84121a601b..a25d7389822 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -147,7 +147,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->fournisseur->commande->cree $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - commande_supplier_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); } else { @@ -179,7 +179,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->fournisseur->commande->c $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - commande_supplier_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); } else { @@ -206,7 +206,7 @@ if ($_GET['action'] == 'deleteline' && $user->rights->fournisseur->commande->cre $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - commande_supplier_pdf_create($db, $_GET['id'], $commande->modelpdf, $outputlangs); + supplier_order_pdf_create($db, $_GET['id'], $commande->modelpdf, $outputlangs); Header('Location: fiche.php?id='.$_GET['id']); exit; } @@ -220,7 +220,7 @@ if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user-> $result = $commande->valid($user); if ($result >= 0) { - commande_supplier_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); Header("Location: fiche.php?id=".$_GET["id"]); exit; } @@ -305,7 +305,7 @@ if ($_GET['action'] == 'up' && $user->rights->fournisseur->commande->creer) $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - commande_supplier_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'#'.$_GET['rowid']); exit; } @@ -320,7 +320,7 @@ if ($_GET['action'] == 'down' && $user->rights->fournisseur->commande->creer) $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - commande_supplier_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'#'.$_GET['rowid']); exit; } @@ -346,7 +346,7 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post $outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs"); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - $result=commande_supplier_pdf_create($db, $commande->id,$commande->modelpdf,$outputlangs); + $result=supplier_order_pdf_create($db, $commande->id,$commande->modelpdf,$outputlangs); if ($result <= 0) { dolibarr_print_error($db,$result); diff --git a/htdocs/fourn/commande/modules/mod_commande_fournisseur_muguet.php b/htdocs/fourn/commande/modules/mod_commande_fournisseur_muguet.php index 41fc42368fc..eda0bfe06c4 100644 --- a/htdocs/fourn/commande/modules/mod_commande_fournisseur_muguet.php +++ b/htdocs/fourn/commande/modules/mod_commande_fournisseur_muguet.php @@ -24,18 +24,17 @@ /** \file htdocs/four/commande/modules/mod_commande_fournisseur_muguet.php \ingroup commande - \brief Fichier contenant la classe du modèle de numérotation de référence de commande Muguet + \brief Fichier contenant la classe du modèle de numérotation de référence de commande fournisseur Muguet \version $Revision$ */ -//require_once(DOL_DOCUMENT_ROOT ."/fourn/commande/modules/mod_commande_fournisseur_muguet.php"); require_once(DOL_DOCUMENT_ROOT ."/fourn/commande/modules/modules_commandefournisseur.php"); /** \class mod_commande_fournisseur_muguet - \brief Classe du modèle de numérotation de référence de commande Marbre + \brief Classe du modèle de numérotation de référence de commande fournisseur Muguet */ -class mod_commande_fournisseur_muguet extends ModeleNumRefCommandesSuppliers +class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders { var $prefix='CF'; var $error=''; diff --git a/htdocs/fourn/commande/modules/mod_commande_fournisseur_rose.php b/htdocs/fourn/commande/modules/mod_commande_fournisseur_rose.php index a9541e95be9..f4fc1a36472 100644 --- a/htdocs/fourn/commande/modules/mod_commande_fournisseur_rose.php +++ b/htdocs/fourn/commande/modules/mod_commande_fournisseur_rose.php @@ -25,11 +25,12 @@ /** \file htdocs/fourn/commande/modules/pdf/mod_commande_fournisseur_rose.php \ingroup fournisseur - \brief Fichier contenant la classe du modèle de numérotation de référence de commande Rose + \brief Fichier contenant la classe du modèle de numérotation de référence de commande fournisseur Rose \version $Revision$ */ -include_once("modules_commandefournisseur.php"); + +require_once(DOL_DOCUMENT_ROOT ."/fourn/commande/modules/modules_commandefournisseur.php"); /** @@ -37,7 +38,7 @@ include_once("modules_commandefournisseur.php"); \brief Classe du modèle de numérotation de référence de commande fournisseur Rose */ -class mod_commande_fournisseur_rose extends ModeleNumRefCommandesSuppliers +class mod_commande_fournisseur_rose extends ModeleNumRefSuppliersOrders { /** \brief Constructeur diff --git a/htdocs/fourn/commande/modules/mod_commande_fournisseur_tulipe.php b/htdocs/fourn/commande/modules/mod_commande_fournisseur_tulipe.php index 1a174db681b..334d8840470 100644 --- a/htdocs/fourn/commande/modules/mod_commande_fournisseur_tulipe.php +++ b/htdocs/fourn/commande/modules/mod_commande_fournisseur_tulipe.php @@ -37,7 +37,7 @@ include_once("modules_commandefournisseur.php"); \brief Classe du modèle de numérotation de référence de commande fournisseur Tulipe */ -class mod_commande_fournisseur_tulipe extends ModeleNumRefCommandesSuppliers +class mod_commande_fournisseur_tulipe extends ModeleNumRefSuppliersOrders { /** diff --git a/htdocs/fourn/commande/modules/modules_commandefournisseur.php b/htdocs/fourn/commande/modules/modules_commandefournisseur.php index fed9fb4af54..76098f169ae 100644 --- a/htdocs/fourn/commande/modules/modules_commandefournisseur.php +++ b/htdocs/fourn/commande/modules/modules_commandefournisseur.php @@ -36,11 +36,11 @@ require_once(FPDF_PATH.'fpdi_protection.php'); /** - \class ModelePDFCommandesSuppliers - \brief Classe mère des modèles de commandes + \class ModelePDFSuppliersorders + \brief Classe mère des modèles de commandes fournisseurs */ -class ModelePDFCommandesSuppliers extends FPDF +class ModelePDFSuppliersOrders extends FPDF { var $error=''; @@ -88,11 +88,11 @@ class ModelePDFCommandesSuppliers extends FPDF /** - \class ModeleNumRefCommandesSuppliers + \class ModeleNumRefSuppliersOrders \brief Classe mère des modèles de numérotation des références de commandes fournisseurs */ -class ModeleNumRefCommandesSuppliers +class ModeleNumRefSuppliersOrders { var $error=''; @@ -137,7 +137,7 @@ class ModeleNumRefCommandesSuppliers } -function commande_supplier_pdf_create($db, $comid, $modele='',$outputlangs='') +function supplier_order_pdf_create($db, $comid, $modele='',$outputlangs='') { global $langs; $langs->load("suppliers"); @@ -169,12 +169,12 @@ function commande_supplier_pdf_create($db, $comid, $modele='',$outputlangs='') if ($obj->write_pdf_file($comid,$outputlangs) > 0) { // on supprime l'image correspondant au preview - commande_supplier_delete_preview($db, $comid); + supplier_order_delete_preview($db, $comid); return 1; } else { - dolibarr_syslog("Erreur dans commande_supplier_pdf_create"); + dolibarr_syslog("Erreur dans supplier_order_pdf_create"); dolibarr_print_error($db,$obj->pdferror()); return 0; } @@ -185,7 +185,7 @@ function commande_supplier_pdf_create($db, $comid, $modele='',$outputlangs='') return 0; } } -function commande_supplier_delete_preview($db, $propalid) +function supplier_order_delete_preview($db, $propalid) { global $langs,$conf; diff --git a/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php b/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php index 93af649554e..46a2115f746 100644 --- a/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php +++ b/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php @@ -40,7 +40,7 @@ require_once(DOL_DOCUMENT_ROOT."/product.class.php"); \brief Classe permettant de générer les commandes fournisseurs au modèle Muscadet */ -class pdf_muscadet extends ModelePDFCommandesSuppliers +class pdf_muscadet extends ModelePDFSuppliersOrders { /** diff --git a/htdocs/includes/modules/commande/mod_commande_saphir.php b/htdocs/includes/modules/commande/mod_commande_saphir.php index 6dcae19f473..b8fd007aabc 100644 --- a/htdocs/includes/modules/commande/mod_commande_saphir.php +++ b/htdocs/includes/modules/commande/mod_commande_saphir.php @@ -85,7 +85,7 @@ function info() $texte.= ''; $texte.= ''; $texte.= ''; - $texte.= ''; + $texte.= ''; $texte.= ''; $texte.= ''; $texte.= ''; @@ -378,7 +378,7 @@ function info() if ($row) $comyy = substr($row[0],0,-$posindice); } - if ($conf->global->PROPALE_NUM_DELTA != '') + if ($conf->global->COMMANDE_NUM_DELTA != '') { //on vérifie si il y a une année précédente //pour éviter que le delta soit appliqué de nouveau sur la nouvelle année @@ -408,7 +408,7 @@ function info() $max = $row[0]; } } - else if ($conf->global->PROPALE_NUM_DELTA != '' && !eregi('^'.$searchLastWithPreviousYear.'',$lastyy)) + else if ($conf->global->COMMANDE_NUM_DELTA != '' && !eregi('^'.$searchLastWithPreviousYear.'',$lastyy)) { // on applique le delta une seule fois $max=$conf->global->COMMANDE_NUM_DELTA?$conf->global->COMMANDE_NUM_DELTA-1:0; diff --git a/htdocs/includes/modules/commande/pdf_einstein.modules.php b/htdocs/includes/modules/commande/pdf_einstein.modules.php index 4be8f972d2b..6aef8e0a139 100644 --- a/htdocs/includes/modules/commande/pdf_einstein.modules.php +++ b/htdocs/includes/modules/commande/pdf_einstein.modules.php @@ -363,7 +363,7 @@ class pdf_einstein extends ModelePDFCommandes } // Affiche zone infos - $posy=$this->_tableau_tot($pdf, $com, $deja_regle, $bottomlasttab, $outputlangs); + $posy=$this->_tableau_info($pdf, $com, $bottomlasttab, $outputlangs); // Affiche zone totaux $posy=$this->_tableau_tot($pdf, $com, $deja_regle, $bottomlasttab, $outputlangs); diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index 0d969fa729e..f3f540ade54 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -2582,15 +2582,18 @@ function num_public_holiday($timestampStart, $timestampEnd) */ function num_between_day($timestampStart, $timestampEnd, $lastday=0) { - if ($lastday == 1) + if ($timestampStart < $timestampEnd) { - $bit = 0; + if ($lastday == 1) + { + $bit = 0; + } + else + { + $bit = 1; + } + $nbjours = round(($timestampEnd - $timestampStart)/(60*60*24)-$bit); } - else - { - $bit = 1; - } - $nbjours = round(($timestampEnd - $timestampStart)/(60*60*24)-$bit); return $nbjours; } @@ -2604,16 +2607,19 @@ function num_between_day($timestampStart, $timestampEnd, $lastday=0) */ function num_open_day($timestampStart, $timestampEnd,$inhour=0,$lastday=0) { - if ($lastday == 1) + if ($timestampStart < $timestampEnd) { - $bit = 1; + if ($lastday == 1) + { + $bit = 1; + } + else + { + $bit = 0; + } + $nbOpenDay = num_between_day($timestampStart, $timestampEnd, $bit) - num_public_holiday($timestampStart, $timestampEnd); + if ($inhour == 1) $nbOpenDay = $nbOpenDay*24; } - else - { - $bit = 0; - } - $nbOpenDay = num_between_day($timestampStart, $timestampEnd, $bit) - num_public_holiday($timestampStart, $timestampEnd); - if ($inhour == 1) $nbOpenDay = $nbOpenDay*24; return $nbOpenDay; } diff --git a/htdocs/livraison/fiche.php b/htdocs/livraison/fiche.php index 9141e74c7b3..0abc9386b1c 100644 --- a/htdocs/livraison/fiche.php +++ b/htdocs/livraison/fiche.php @@ -77,7 +77,7 @@ if ($_POST["action"] == 'add') // avec qté à livrer $commande = new Commande($db); $commande->fetch($livraison->commande_id); - $commande->fetch_lignes(); + $commande->fetch_lines(); for ($i = 0 ; $i < sizeof($commande->lignes) ; $i++) { $qty = "qtyl".$i; @@ -245,7 +245,7 @@ if ($_GET["action"] == 'create') */ echo '
Appliquer un offset sur le compteur
'.$form->textwithhelp('',$langs->trans("OffsetDesc"),1,1).'
'; - $lignes = $commande->fetch_lignes(1); + $lignes = $commande->fetch_lines(1); /* Lecture des livraisons déjà effectuées */ $commande->livraison_array(); diff --git a/htdocs/livraison/livraison.class.php b/htdocs/livraison/livraison.class.php index fb35e356f46..fc2d4c647c8 100644 --- a/htdocs/livraison/livraison.class.php +++ b/htdocs/livraison/livraison.class.php @@ -109,7 +109,7 @@ class Livraison extends CommonObject { $commande = new Commande($this->db); $commande->id = $this->commande_id; - $this->lignes = $commande->fetch_lignes(); + $this->lignes = $commande->fetch_lines(); }