diff --git a/htdocs/comm/propal/class/actions_proposal.class.php b/htdocs/comm/propal/class/actions_proposal.class.php new file mode 100644 index 00000000000..061b14c6a38 --- /dev/null +++ b/htdocs/comm/propal/class/actions_proposal.class.php @@ -0,0 +1,49 @@ + + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file htdocs/comm/propal/actions_proposal.class.php + * \ingroup proposal + * \brief Fichier de la classe des actions des propales + * \version $Id$ + */ + +require_once(DOL_DOCUMENT_ROOT ."/core/class/actions_commonobject.class.php"); +require_once(DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'); + +/** + * \class ActionsProposal + * \brief Classe permettant la gestion des actions des propales + */ +class ActionsProposal extends ActionsCommonObject +{ + var $db; + var $object; + + /** + * Constructeur de la classe + * @param DB Handler acces base de donnees + */ + function ActionsProposal($DB) + { + $this->db = $DB; + } + +} + +?> \ No newline at end of file diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 6f9e6a207ad..e5ce64715e6 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1024,7 +1024,8 @@ class Propal extends CommonObject $line->fk_product = $objp->fk_product; - $line->libelle = $objp->label; // Label produit + $line->libelle = $objp->label; // TODO deprecated + $line->label = $objp->label; // Label produit $line->product_desc = $objp->product_desc; // Description produit $line->ref = $objp->ref; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index e39fea44603..b6a201ab167 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -1390,7 +1390,7 @@ if ($_GET['action'] == 'create') if ($element == 'order') { $element = $subelement = 'commande'; } if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } if ($element == 'contract') { $element = $subelement = 'contrat'; } - + require_once(DOL_DOCUMENT_ROOT.'/'.$element.'/class/'.$subelement.'.class.php'); $classname = ucfirst($subelement); $objectsrc = new $classname($db); @@ -1780,6 +1780,8 @@ if ($_GET['action'] == 'create') // TODO deplacer dans la classe if ($_GET['origin'] == 'propal') { + //$objectsrc->printOriginLinesList(); + $title=$langs->trans('ProductsAndServices'); $sql = 'SELECT pt.rowid, pt.description, pt.fk_remise_except,'; diff --git a/htdocs/core/class/actions_commonobject.class.php b/htdocs/core/class/actions_commonobject.class.php new file mode 100644 index 00000000000..c991d49ff1e --- /dev/null +++ b/htdocs/core/class/actions_commonobject.class.php @@ -0,0 +1,50 @@ + + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file htdocs/core/class/actions_commonobject.class.php + * \ingroup core + * \brief Fichier de la classe mere des classes metiers (facture, contrat, propal, commande, etc...) + * \version $Id$ + */ + + +/** + * \class ActionsCommonObject + * \brief Classe mere pour heritage des classes metiers + */ + +class ActionsCommonObject +{ + var $db; + + // Instantiate hook classe of thirdparty module + var $hooks=array(); + + /** + * Constructeur de la classe + * @param DB Handler acces base de donnees + */ + function AnctionsCommonObject($DB) + { + $this->db = $DB; + } + +} + +?> diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 42a35bcb73a..d7db5b9fd5f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1501,6 +1501,113 @@ class CommonObject } } } + + /** + * Return HTML with list of origin lines + */ + function printOriginLinesList() + { + $num = count($this->lines); + $var = true; + $i = 0; + + foreach ($this->lines as $line) + { + $var=!$var; + + if ($line->product_type == 9 && ! empty($line->special_code)) + { + //$this->hooks[$line->special_code]->printObjectLine($this,$line,$num,$i); + } + else + { + $this->printOriginLine($line,$var); + } + + $i++; + } + } + + /** + * Return HTML with origin line + * @param element Element type + * @param id Element id + */ + function printOriginLine($line,$var) + { + global $langs,$bc; + + $var=!$var; + + $date_start=$line->date_debut_prevue; + if ($line->date_debut_reel) $date_start=$line->date_debut_reel; + $date_end=$line->date_fin_prevue; + if ($line->date_fin_reel) $date_end=$line->date_fin_reel; + + print ''; + if (($line->info_bits & 2) == 2) + { + print ''; + print img_object($langs->trans("ShowReduc"),'reduc').' '.$langs->trans("Discount"); + print ''; + } + else if ($line->fk_product) + { + print ''; + print ($line->fk_product_type == 1 ? img_object($langs->trans(''),'service') : img_object($langs->trans(''),'product')); + print ' '.$line->ref.''; + print $line->label?' - '.$line->label:''; + // Dates + if ($date_start || $date_end) + { + print_date_range($date_start,$date_end); + } + } + else + { + print ($line->product_type == -1 ? ' ' : ($line->product_type == 1 ? img_object($langs->trans(''),'service') : img_object($langs->trans(''),'product'))); + // Dates + if ($date_start || $date_end) + { + print_date_range($date_start,$date_end); + } + } + print "\n"; + print ''; + if ($line->desc) + { + if ($line->desc == '(CREDIT_NOTE)') + { + $discount=new DiscountAbsolute($db); + $discount->fetch($line->fk_remise_except); + print $langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0)); + } + elseif ($line->desc == '(DEPOSIT)') + { + $discount=new DiscountAbsolute($db); + $discount->fetch($line->fk_remise_except); + print $langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0)); + } + else + { + print dol_trunc($line->desc,60); + } + } + else + { + print ' '; + } + print ''; + print ''.vatrate($line->tva_tx).'%'; + print ''.price($line->subprice).''; + print ''; + print (($line->info_bits & 2) != 2) ? $line->qty : ' '; + print ''; + print ''; + print (($line->info_bits & 2) != 2) ? $line->remise_percent.'%' : ' '; + print ''; + print ''; + } }