diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index b4c417df113..66fd817d32e 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -1,7 +1,8 @@ * Copyright (C) 2004-2007 Laurent Destailleur - * Copyright (C) 2005 Eric Seigne + * Copyright (C) 2005 Eric Seigne + * Copyright (C) 2005-2007 Regis Houssin * * 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 @@ -90,18 +91,18 @@ if ($_REQUEST['action'] == 'setremisepercent' && $user->rights->fournisseur->com */ if ($_POST['action'] == 'addligne' && $user->rights->fournisseur->commande->creer) { - if ($_POST['qty'] && (($_POST['pu'] && $_POST['desc']) || $_POST['idprodfournprice'])) + if ($_POST['qty'] && (($_POST['pu'] && ($_POST['np_desc'] || $_POST['dp_desc'])) || $_POST['idprodfournprice'])) { $commande = new CommandeFournisseur($db); $ret=$commande->fetch($_POST["id"]); - - $soc = new Societe($db, $commande->socid); - $soc->fetch($commande->socid); if ($ret < 0) { dolibarr_print_error($db,$commande->error); exit; } + + $soc = new Societe($db, $commande->socid); + $soc->fetch($commande->socid); // Ecrase $pu par celui du produit // Ecrase $desc par celui du produit @@ -116,17 +117,17 @@ if ($_POST['action'] == 'addligne' && $user->rights->fournisseur->commande->cree $libelle = $prod->libelle; - $desc = $prod->description; - $desc.= $prod->description && $_POST['np_desc'] ? "\n" : ""; - $desc.= $_POST['np_desc']; + $desc = $prod->description; + $desc.= $prod->description && $_POST['np_desc'] ? "\n" : ""; + $desc.= $_POST['np_desc']; - $tva_tx = get_default_tva($soc,$mysoc,$prod->tva_tx); + $tva_tx = get_default_tva($soc,$mysoc,$prod->tva_tx); } else { $pu=$_POST['pu']; $tva_tx=$_POST['tva_tx']; - $desc=$_POST['desc']; + $desc=$_POST['dp_desc']; } $result=$commande->addline( @@ -158,7 +159,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->fournisseur->commande->cree } /* - * Mise à jour d'une ligne dans la propale + * Mise à jour d'une ligne dans la commande */ if ($_POST['action'] == 'updateligne' && $user->rights->fournisseur->commande->creer && $_POST['save'] == $langs->trans('Save')) { @@ -166,7 +167,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->fournisseur->commande->c if ($commande->fetch($_POST['id']) < 0) dolibarr_print_error($db); $result = $commande->updateline($_POST['elrowid'], - $_POST['desc'], + $_POST['eldesc'], $_POST['pu'], $_POST['qty'], $_POST['remise_percent'], @@ -622,7 +623,8 @@ else $sql = "SELECT l.ref as ref_fourn, l.fk_product, l.description, l.price, l.qty"; $sql.= ", l.rowid, l.tva_tx, l.remise_percent, l.subprice"; - $sql.= ", p.rowid as product_id, p.label, p.ref"; + $sql.= ", l.total_ht, l.total_tva, l.total_ttc"; + $sql.= ", p.rowid as product_id, p.label as product, p.ref"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; $sql.= " WHERE l.fk_commande = ".$commande->id; @@ -630,83 +632,132 @@ else $resql = $db->query($sql); if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; $total = 0; + + if ($num) { - $num = $db->num_rows($resql); - $i = 0; $total = 0; - - if ($num) - { - print ''; - print ''.$langs->trans('Description').''; - print ''.$langs->trans('VAT').''; - print ''.$langs->trans('PriceUHT').''; - print ''.$langs->trans('Qty').''; - print ''.$langs->trans('ReductionShort').''; - print ''.$langs->trans('AmountHT').''; - print ' '; - print "\n"; - } - $var=false; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - print ""; - print ''; - print ''.img_object($langs->trans("ShowProduct"),'product').' '.$objp->ref_fourn.''; - print ' ('.$objp->ref.')'; - print ' - '.$objp->label; - if ($objp->description) print '
'.nl2br($objp->description); - print ""; - print ''.vatrate($objp->tva_tx).'%'; - print ''.price($objp->subprice)."\n"; - print ''.$objp->qty.''; - if ($objp->remise_percent > 0) - { - print ''.$objp->remise_percent."%\n"; - } - else - { - print ' '; - } - print ''.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100).''; - if ($commande->statut == 0 && $user->rights->fournisseur->commande->creer && $_GET["action"] <> 'valid' && $_GET["action"] != 'editline') + print ''; + print ''.$langs->trans('Description').''; + print ''.$langs->trans('VAT').''; + print ''.$langs->trans('PriceUHT').''; + print ''.$langs->trans('Qty').''; + print ''.$langs->trans('ReductionShort').''; + print ''.$langs->trans('AmountHT').''; + print ' '; + print "\n"; + } + $var=true; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $var=!$var; + + // Ligne en mode visu + if ($_GET['action'] != 'editline' || $_GET['rowid'] != $objp->rowid) + { + print ''; + if ($objp->fk_product > 0) + { + print ''; + print ''; // ancre pour retourner sur la ligne + + // Affiche ligne produit + $text = ''; + $text.= img_object($langs->trans('ShowProduct'),'product'); + $text.= ' '.$objp->ref_fourn.''; + $text.= ' ('.$objp->ref.')'; + $text.= ' - '.$objp->product; + $description=($conf->global->PRODUIT_DESC_IN_FORM?'':$objp->description); + print $html->textwithtooltip($text,$description,3,'','',$i); + if ($conf->global->PRODUIT_DESC_IN_FORM) + { + print ($objp->description && $objp->description!=$objp->product)?'
'.stripslashes(nl2br($objp->description)):''; + } + + print ""; + } + else + { + print ''; + print ''; // ancre pour retourner sur la ligne + print nl2br($objp->description); + print ''; + } + print ''.vatrate($objp->tva_tx).'%'; + print ''.price($objp->subprice)."\n"; + print ''.$objp->qty.''; + if ($objp->remise_percent > 0) + { + print ''.dolibarr_print_reduction($objp->remise_percent)."\n"; + } + else + { + print ' '; + } + //Todo: Modifier la classe pour utiliser le champ total_ttc + print ''.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100).''; + if ($commande->statut == 0 && $user->rights->fournisseur->commande->creer) + { + print 'rowid.'#'.$objp->rowid.'">'; + print img_edit(); + print ''; + + print 'rowid.'">'; + print img_delete(); + print ''; + } + else + { + print '  '; + } + print ""; + } + + // Ligne en mode update + if ($_GET["action"] == 'editline' && $user->rights->fournisseur->commande->creer && $_GET["rowid"] == $objp->rowid) { - print 'rowid.'#'.$objp->rowid.'">'; - print img_edit(); - print ''; - - print 'rowid.'">'; - print img_delete(); - print ''; - } - else - { - print '  '; - } - print ""; - - if ($_GET["action"] == 'editline' && $_GET["rowid"] == $objp->rowid) - { - print "
id\" method=\"post\">"; - print ""; - print ''; - print ''; - print ''; - print ''; + print 'rowid.'" method="post">'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; // ancre pour retourner sur la ligne + if ($objp->fk_product > 0) + { + print ''; + print img_object($langs->trans('ShowProduct'),'product'); + print ' '.$objp->ref_fourn.''; + print ' ('.$objp->ref.')'; + print ' - '.nl2br($objp->product); + print '
'; + } + // éditeur wysiwyg + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('eldesc',$objp->description,200,'dolibarr_details'); + $doleditor->Create(); + } + else + { + print ''; + } print ''; print ''; $html->select_tva('tva_tx',$objp->tva_tx); print ''; - print ''; - print '%'; - print ''; + print ''; + print ''; + print '%'; print ''; print '
'; print '' . "\n"; print "
\n"; } $i++; - $var=!$var; } $db->free(); } @@ -718,41 +769,112 @@ else /* * Ajouter une ligne */ - if ($commande->statut == 0 && $user->rights->fournisseur->commande->creer && ($_GET["action"] <> 'valid' || $_GET['action'] == 'builddoc')) + if ($commande->statut == 0 && $user->rights->fournisseur->commande->creer && $_GET["action"] <> 'editline') { - print '
'; - print ''; - print ''; - print ''; - print ''.$langs->trans('Description').''; + print ''; + print ''; // ancre + print $langs->trans('Description').''; print ''.$langs->trans('VAT').''; print ''.$langs->trans('PriceUHT').''; print ''.$langs->trans('Qty').''; print ''.$langs->trans('ReductionShort').''; print ' '; print ''; - - $var=false; - print "".''; - $html->select_produits_fournisseurs($commande->fourn_id,'','idprodfournprice',$filtre); - print ''; - print ''; - print '%'; - print ''; - print "\n"; - - print "
"; - } - - print ""; - print ''; + + // Ajout produit produits/services personnalisés + print '
'; + print ''; + print ''; + + $var=true; + print ''; + print ''; + // éditeur wysiwyg + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS_PERSO) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('dp_desc','',100,'dolibarr_details'); + $doleditor->Create(); + } + else + { + print ''; + } + print ''; + print ''; + if($soc->tva_assuj == "0") + print '0'; + else + print $html->select_tva('tva_tx',$conf->defaulttx,$mysoc,$soc); + print ''; + print ''; + print ''; + print '%'; + print ''; + print ''; + + print '
'; + + // Ajout de produits/services prédéfinis + if ($conf->produit->enabled) + { + print ''; + print ''; + if ($conf->service->enabled) + { + print $langs->trans('RecordedProductsAndServices'); + } + else + { + print $langs->trans('RecordedProducts'); + } + print ''; + print ''.$langs->trans('Qty').''; + print ''.$langs->trans('ReductionShort').''; + print ' '; + print ''; + + print '
'; + print ''; + print ''; + + $var=!$var; + print ''; + print ''; + $html->select_produits_fournisseurs($commande->fourn_id,'','idprodfournprice'); + + if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '
'; + + // éditeur wysiwyg + if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS_PERSO) + { + require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); + $doleditor=new DolEditor('np_desc','',100,'dolibarr_details'); + $doleditor->Create(); + } + else + { + print ''; + } + + print ''; + print ''; + print '%'; + print ''; + print ''; + + print '
'; + } + } + print ''; + print ''; /** * Boutons actions */ - if ($user->societe_id == 0 && $commande->statut < 3 && ($_GET["action"] <> 'valid' || $_GET['action'] == 'builddoc')) + if ($user->societe_id == 0 && $commande->statut < 3 && $_GET['action'] <> 'editline') { print '
'; @@ -800,6 +922,7 @@ else } print '
'; + print ''; // ancre /* * Documents générés diff --git a/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php b/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php index 1da4a3f2020..c5b2f7c7707 100644 --- a/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php +++ b/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php @@ -108,20 +108,6 @@ class pdf_muscadet extends ModelePDFSuppliersOrders \brief Fonction générant la commande sur le disque \param id Id de la commande à générer \return int 1=ok, 0=ko - \remarks Variables utilisées - \remarks MAIN_INFO_SOCIETE_NOM - \remarks MAIN_INFO_ADRESSE - \remarks MAIN_INFO_CP - \remarks MAIN_INFO_VILLE - \remarks MAIN_INFO_TEL - \remarks MAIN_INFO_FAX - \remarks MAIN_INFO_WEB - \remarks MAIN_INFO_SIRET - \remarks MAIN_INFO_SIREN - \remarks MAIN_INFO_RCS - \remarks MAIN_INFO_CAPITAL - \remarks MAIN_INFO_TVAINTRA - \remarks MAIN_INFO_LOGO */ function write_file($com,$outputlangs='') { @@ -195,7 +181,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetDrawColor(128,128,128); $pdf->SetTitle($com->ref); - $pdf->SetSubject($outputlangs->transnoentities("Bill")); + $pdf->SetSubject($outputlangs->transnoentities("Order")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($user->fullname); @@ -218,6 +204,29 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $tab_top_newpage = 50; $tab_height = 110; $tab_height_newpage = 180; + + // Affiche notes + if ($com->note_public) + { + $tab_top = 88; + + $pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page + $pdf->SetXY ($this->posxdesc-1, $tab_top); + $pdf->MultiCell(190, 3, $com->note_public, 0, 'J'); + $nexY = $pdf->GetY(); + $height_note=$nexY-$tab_top; + + // Rect prend une longueur en 3eme param + $pdf->SetDrawColor(192,192,192); + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + + $tab_height = $tab_height - $height_note; + $tab_top = $nexY+6; + } + else + { + $height_note=0; + } $iniY = $tab_top + 8; $curY = $tab_top + 8; @@ -229,34 +238,28 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $curY = $nexY; // Description de la ligne produit - $libelleproduitservice=$com->lignes[$i]->libelle; + $libelleproduitservice=dol_htmlentities($com->lignes[$i]->libelle); if ($com->lignes[$i]->desc&&$com->lignes[$i]->desc!=$com->lignes[$i]->libelle) { if ($libelleproduitservice) $libelleproduitservice.="\n"; - $libelleproduitservice.=$com->lignes[$i]->desc; + $libelleproduitservice.=dol_htmlentities($com->lignes[$i]->desc); } // Si ligne associée à un code produit if ($com->lignes[$i]->fk_product) { - $libelleproduitservice=$outputlangs->transnoentities("Product")." ".$com->lignes[$i]->ref_fourn." - ".$libelleproduitservice; - - // Ajoute description du produit - if ($com->lignes[$i]->product_desc&&$com->lignes[$i]->product_desc!=$fac->lignes[$i]->libelle&&$com->lignes[$i]->product_desc!=$com->lignes[$i]->desc) - { - if ($libelleproduitservice) $libelleproduitservice.="\n"; - $libelleproduitservice.=$com->lignes[$i]->product_desc; - } + $libelleproduitservice=$outputlangs->transnoentities("Product")." ".$com->lignes[$i]->ref_fourn." - ".$libelleproduitservice; } if ($com->lignes[$i]->date_start && $com->lignes[$i]->date_end) { // Affichage durée si il y en a une - $libelleproduitservice.="\n(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($com->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($com->lignes[$i]->date_end).")"; + $libelleproduitservice.=dol_htmlentities("\n(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($com->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($com->lignes[$i]->date_end).")"); } $pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page - $pdf->SetXY ($this->posxdesc-1, $curY); - $pdf->MultiCell(108, 4, $libelleproduitservice, 0, 'J'); + $pdf->writeHTMLCell(108, 4, $this->posxdesc-1, $curY, $libelleproduitservice, 0, 1); + + $pdf->SetFont('Arial','', 9); // On repositionne la police par défaut $nexY = $pdf->GetY(); diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php index dfc87baa8f7..75f15b59d05 100644 --- a/htdocs/fourn/fournisseur.commande.class.php +++ b/htdocs/fourn/fournisseur.commande.class.php @@ -685,7 +685,6 @@ class CommandeFournisseur extends Commande if ($result > 0) { $label = $prod->libelle; - $desc = $prod->description; $txtva = $prod->tva_tx; $pu = $prod->fourn_pu; $ref = $prod->ref_fourn; @@ -723,10 +722,17 @@ class CommandeFournisseur extends Commande $price = $pu - $remise; } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet (fk_commande,label,description,fk_product, price, qty, tva_tx, remise_percent, subprice, remise, ref)"; - $sql .= " VALUES (".$this->id.", '" . addslashes($label) . "','" . addslashes($desc) . "',".$fk_product.",".price2num($price,'MU').", '$qty', $txtva, $remise_percent,'".price2num($subprice,'MU')."','".price2num($remise)."','".$ref."') ;"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."commande_fournisseurdet"; + $sql.= " (fk_commande,label, description,"; + $sql.= " fk_product,"; + $sql.= " price, qty, tva_tx, remise_percent, subprice, remise, ref)"; + $sql.= " VALUES (".$this->id.", '" . addslashes($label) . "','" . addslashes($desc) . "',"; + if ($fk_product) { $sql.= $fk_product.","; } + else { $sql.= "null,"; } + $sql.= price2num($price,'MU').", '$qty', $txtva, $remise_percent,'".price2num($subprice,'MU')."','".price2num($remise)."','".$ref."') ;"; dolibarr_syslog('Fournisseur.commande.class::addline sql='.$sql); $resql=$this->db->query($sql); + //print $sql; if ($resql) { $this->update_price(); diff --git a/mysql/migration/2.1.0-2.2.0.sql b/mysql/migration/2.1.0-2.2.0.sql index 3ea98fcb4ec..28686c95ef7 100644 --- a/mysql/migration/2.1.0-2.2.0.sql +++ b/mysql/migration/2.1.0-2.2.0.sql @@ -1163,4 +1163,6 @@ ALTER TABLE llx_societe_remise_except ADD CONSTRAINT fk_societe_remise_fk_factur -- V4.1 update llx_societe_remise_except as re set re.fk_facture = (select fk_facture from llx_facturedet as fd where fd.rowid = re.fk_facture_line), re.fk_facture_line = NULL where re.fk_facture_line in (select rowid from llx_facturedet where description = '(CREDIT_NOTE)'); -- V4.1 delete from llx_facturedet where description = '(CREDIT_NOTE)'; -DELETE FROM llx_const WHERE name = 'PRODUIT_CHANGE_PROD_DESC'; \ No newline at end of file +DELETE FROM llx_const WHERE name = 'PRODUIT_CHANGE_PROD_DESC'; + +ALTER TABLE llx_commande_fournisseurdet MODIFY fk_product integer; \ No newline at end of file diff --git a/mysql/tables/llx_commande_fournisseurdet.sql b/mysql/tables/llx_commande_fournisseurdet.sql index 7a2a9a95823..bfc4419f708 100644 --- a/mysql/tables/llx_commande_fournisseurdet.sql +++ b/mysql/tables/llx_commande_fournisseurdet.sql @@ -23,7 +23,7 @@ create table llx_commande_fournisseurdet ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_commande integer NOT NULL, - fk_product integer NOT NULL, + fk_product integer, ref varchar(50), label varchar(255), description text,