diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index b8891938522..ccb8272e9a8 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -873,7 +873,7 @@ if ($_GET['action'] == 'down' && $user->rights->propale->creer) /* - * Affichage page + * View */ llxHeader('',$langs->trans('Proposal'),'Proposition'); @@ -1235,6 +1235,9 @@ if ($id > 0 || ! empty($ref)) $sql = 'SELECT pt.rowid, pt.description, pt.fk_product, pt.fk_remise_except,'; $sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,'; $sql.= ' pt.total_ht, pt.total_tva, pt.total_ttc, pt.marge_tx, pt.marque_tx, pt.pa_ht, pt.special_code,'; + $sql.= ' '.$db->pdate('pt.date_start').' as date_start,'; + $sql.= ' '.$db->pdate('pt.date_end').' as date_end,'; + $sql.= ' pt.product_type,'; $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid,'; $sql.= ' p.description as product_desc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt'; @@ -1269,6 +1272,13 @@ if ($id > 0 || ! empty($ref)) $objp = $db->fetch_object($resql); $var=!$var; + // Show product and description + $type=$objp->product_type?$objp->product_type:$objp->fk_product_type; + // Try to enhance type detection using date_start and date_end for free lines where type + // was not saved. + if (! empty($objp->date_start)) $type=1; + if (! empty($objp->date_end)) $type=1; + // Ligne en mode visu if ($_GET['action'] != 'editline' || $_GET['lineid'] != $objp->rowid) { @@ -1562,7 +1572,7 @@ if ($id > 0 || ! empty($ref)) } /* - * Ajouter une ligne + * Form to add new line */ if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] <> 'editline') { @@ -1570,7 +1580,7 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; print ''; // ancre - print $langs->trans('Description').''; + print $langs->trans('AddNewLine').' - '.$langs->trans("FreeZone").''; print ''.$langs->trans('VAT').''; print ''.$langs->trans('PriceUHT').''; print ''.$langs->trans('Qty').''; @@ -1578,16 +1588,18 @@ if ($id > 0 || ! empty($ref)) print ' '; print "\n"; - // Ajout produit produits/services personnalises + // Add free products/services form print '
'; print ''; print ''; $var=true; - print '\n"; print ''; - // editeur wysiwyg + + print $html->select_type_of_lines(-1,'type',1).'
'; + + // Editor wysiwyg if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) { require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); @@ -1599,15 +1611,11 @@ if ($id > 0 || ! empty($ref)) print ''; } print ''; - print ''; - if($societe->tva_assuj == "0") - { - print '0'; - } - else - { - $html->select_tva('np_tva_tx', $conf->defaulttx, $mysoc, $societe); - } + print ''; + //if ($societe->tva_assuj == "0") + //print '0'; + //else + $html->select_tva('np_tva_tx', $conf->defaulttx, $mysoc, $societe); print "\n"; print ''; print ''; @@ -1618,7 +1626,7 @@ if ($id > 0 || ! empty($ref)) print '
'; // Ajout de produits/services predefinis - if ($conf->produit->enabled) + if ($conf->produit->enabled || $conf->service->enabled) { if ($conf->global->PRODUIT_USE_MARKUP) { @@ -1630,6 +1638,7 @@ if ($id > 0 || ! empty($ref)) } print ''; print ''; + print $langs->trans("AddNewLine").' - '; if ($conf->service->enabled) { print $langs->trans('RecordedProductsAndServices'); @@ -1662,7 +1671,7 @@ if ($id > 0 || ! empty($ref)) } if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '
'; - // editeur wysiwyg + // Editor wysiwyg if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) { require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index f91a5102138..20c83cfbd05 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1665,14 +1665,14 @@ else } /* - * Ajouter une ligne + * Form to add new line */ if ($commande->statut == 0 && $user->rights->commande->creer && $_GET["action"] <> 'editline') { print ''; print ''; print ''; // ancre - print $langs->trans('Description').''; + print $langs->trans('AddNewLine').' - '.$langs->trans("FreeZone").''; print ''.$langs->trans('VAT').''; print ''.$langs->trans('PriceUHT').''; print ''.$langs->trans('Qty').''; @@ -1680,7 +1680,7 @@ else print ' '; print ''; - // Ajout produit produits/services personnalises + // Add free products/services form print '
'; print ''; print ''; @@ -1688,7 +1688,10 @@ else $var=true; print ''; print ''; - // editeur wysiwyg + + print $html->select_type_of_lines(-1,'type',1).'
'; + + // Editor wysiwyg if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) { require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); @@ -1700,10 +1703,10 @@ else print ''; } print ''; - print ''; - if($soc->tva_assuj == "0") - print '0'; - else + print ''; + //if($soc->tva_assuj == "0") + //print '0'; + //else print $html->select_tva('tva_tx',$conf->defaulttx,$mysoc,$soc); print ''; print ''; @@ -1727,10 +1730,11 @@ else print '
'; // Ajout de produits/services predefinis - if ($conf->produit->enabled) + if ($conf->produit->enabled || $conf->service->enabled) { print ''; print ''; + print $langs->trans("AddNewLine").' - '; if ($conf->service->enabled) { print $langs->trans('RecordedProductsAndServices'); @@ -1764,7 +1768,7 @@ else if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '
'; - // editeur wysiwyg + // Editor wysiwyg if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) { require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 88900e176e4..cf630b69eb1 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -2977,10 +2977,11 @@ else */ if ($fac->statut == 0 && $user->rights->facture->creer && $_GET['action'] <> 'valid' && $_GET['action'] <> 'editline') { + // Free zone form print ''; print ''; print ''; // ancre - print $langs->trans('AddNewLine').''; + print $langs->trans('AddNewLine').' - '.$langs->trans("FreeZone").''; print ''.$langs->trans('VAT').''; print ''.$langs->trans('PriceUHT').''; print ''.$langs->trans('Qty').''; @@ -2997,9 +2998,9 @@ else print ''; print ''; - print $html->select_type_of_lines(-1,'type',1); + print $html->select_type_of_lines(-1,'type',1).'
'; - // Editeur wysiwyg + // Editor wysiwyg if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) { require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); @@ -3012,6 +3013,9 @@ else } print ''; print ''; + //if($soc->tva_assuj == "0") + //print '0'; + //else $html->select_tva('tva_tx',$conf->defaulttx,$mysoc,$soc); print ''; print ''; @@ -3031,8 +3035,9 @@ else } print ''; - // Add predefined services/products form - if ($conf->produit->enabled) + + // Predefined services/products form + if ($conf->produit->enabled || $conf->service->enabled) { print ''; print ''; @@ -3070,7 +3075,7 @@ else if (! $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print '
'; - // éditeur wysiwyg + // Editor wysiwyg if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS) { require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index 5f5e6c1afce..5b0e36accf8 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -127,7 +127,7 @@ class Facture extends CommonObject /** * \brief Create invoice in database - * \param user Object uset that create + * \param user Object user that create * \param notrigger 1 ne declenche pas les triggers, 0 sinon * \return int <0 si ko, >0 si ok */ @@ -243,23 +243,17 @@ class Facture extends CommonObject } /* - * Insertion du detail des produits dans la base, - * si tableau products défini. + * Insert lines of invoices in database */ - for ($i = 0 ; $i < sizeof($this->products) ; $i++) + for ($i = 0 ; $i < sizeof($this->lignes) ; $i++) { - $result = $this->addline( - $this->id, - $this->products[$i]->desc, - $this->products[$i]->subprice, - $this->products[$i]->qty, - $this->products[$i]->tva_tx, - $this->products[$i]->fk_product, - $this->products[$i]->remise_percent, - $this->products[$i]->date_start, - $this->products[$i]->date_end - ); - + $newinvoiceline=new FactureLigne($this->db); + $newinvoiceline=$this->lignes[$i]; + $newinvoiceline->fk_facture=$this->id; + if ($result >= 0 && ($newinvoiceline->info_bits & 0x01) == 0) // We keep only lines with first bit = 0 + { + $result=$newinvoiceline->insert(); + } if ($result < 0) { $error++; @@ -362,6 +356,7 @@ class Facture extends CommonObject $facture->amount = $this->amount; $facture->remise_absolue = $this->remise_absolue; $facture->remise_percent = $this->remise_percent; + $facture->lignes = $this->lignes; // Tableau des lignes de factures $facture->products = $this->lignes; // Tant que products encore utilisé @@ -608,12 +603,12 @@ class Facture extends CommonObject /** - \brief Recupére les lignes de factures dans this->lignes - \return int 1 si ok, < 0 si erreur - */ + * \brief Recupére les lignes de factures dans this->lignes + * \return int 1 si ok, < 0 si erreur + */ function fetch_lines() { - $sql = 'SELECT l.rowid, l.fk_product, l.description, l.price, l.qty, l.tva_taux, '; + $sql = 'SELECT l.rowid, l.fk_product, l.description, l.product_type, l.price, l.qty, l.tva_taux, '; $sql.= ' l.remise, l.remise_percent, l.fk_remise_except, l.subprice,'; $sql.= ' '.$this->db->pdate('l.date_start').' as date_start,'.$this->db->pdate('l.date_end').' as date_end,'; $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_ttc, l.fk_code_ventilation, l.fk_export_compta,'; @@ -638,7 +633,7 @@ class Facture extends CommonObject $faclig->desc = $objp->description; // Description ligne $faclig->libelle = $objp->label; // Label produit $faclig->product_desc = $objp->product_desc; // Description produit - $faclig->product_type = $objp->fk_product_type; + $faclig->product_type = $objp->product_type; // Type of line $faclig->qty = $objp->qty; $faclig->subprice = $objp->subprice; $faclig->tva_tx = $objp->tva_taux; @@ -646,6 +641,7 @@ class Facture extends CommonObject $faclig->fk_remise_except = $objp->fk_remise_except; $faclig->produit_id = $objp->fk_product; $faclig->fk_product = $objp->fk_product; + $faclig->fk_product_type = $objp->fk_product_type; $faclig->date_start = $objp->date_start; $faclig->date_end = $objp->date_end; $faclig->date_start = $objp->date_start; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 04894411086..2e3cf4f3e2a 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -501,6 +501,7 @@ Informations=Informations Page=Page Notes=Notes AddNewLine=Add new line +FreeZone=Free text # Week day Day1=Monday Day2=Tuesday diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index c52226ad862..9441602572a 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -500,6 +500,7 @@ Informations=Informations Page=Page Notes=Notes AddNewLine=Ajout nouvelle ligne +FreeZone=Zone libre # Week day Day1=Lundi Day2=Mardi diff --git a/mysql/migration/2.5.0-2.6.0.sql b/mysql/migration/2.5.0-2.6.0.sql index 17d83ed5347..709175e1c90 100644 --- a/mysql/migration/2.5.0-2.6.0.sql +++ b/mysql/migration/2.5.0-2.6.0.sql @@ -86,6 +86,15 @@ drop table llx_don_projet; alter table llx_facture_fourn_det add column date_start datetime DEFAULT NULL; alter table llx_facture_fourn_det add column date_end datetime DEFAULT NULL; +alter table llx_commandedet add column product_type integer DEFAULT 0 after total_ttc; + +alter table llx_propaldet add column product_type integer DEFAULT 0 after total_ttc; +alter table llx_propaldet add column date_start datetime DEFAULT NULL after product_type; +alter table llx_propaldet add column date_end datetime DEFAULT NULL after date_start; + +alter table llx_commande_fournisseur add column product_type integer DEFAULT 0 after total_ttc; +alter table llx_commande_fournisseur add column date_start datetime DEFAULT NULL after product_type; +alter table llx_commande_fournisseur add column date_end datetime DEFAULT NULL after date_start; -- V4.1 delete from llx_projet_task where fk_projet not in (select rowid from llx_projet); -- V4.1 ALTER TABLE llx_projet_task ADD CONSTRAINT fk_projet_task_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid); diff --git a/mysql/tables/llx_commande_fournisseurdet.sql b/mysql/tables/llx_commande_fournisseurdet.sql index 40e7a27f9b9..ab12d187ff1 100644 --- a/mysql/tables/llx_commande_fournisseurdet.sql +++ b/mysql/tables/llx_commande_fournisseurdet.sql @@ -1,6 +1,6 @@ -- =================================================================== --- Copyright (C) 2007 Rodolphe Quiedeville --- Copyright (C) 2007 Laurent Destailleur +-- Copyright (C) 2007 Rodolphe Quiedeville +-- Copyright (C) 2007-2009 Laurent Destailleur -- -- 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 @@ -35,5 +35,8 @@ create table llx_commande_fournisseurdet total_ht double(24,8) DEFAULT 0, -- Total HT de la ligne toute quantité et incluant remise ligne et globale total_tva double(24,8) DEFAULT 0, -- Total TVA de la ligne toute quantité et incluant remise ligne et globale total_ttc double(24,8) DEFAULT 0, -- Total TTC de la ligne toute quantité et incluant remise ligne et globale + product_type integer DEFAULT 0, + date_start datetime DEFAULT NULL, -- date debut si service + date_end datetime DEFAULT NULL, -- date fin si service info_bits integer DEFAULT 0 -- TVA NPR ou non )type=innodb; diff --git a/mysql/tables/llx_commandedet.sql b/mysql/tables/llx_commandedet.sql index bcc575f7b65..27e4a0a1f26 100644 --- a/mysql/tables/llx_commandedet.sql +++ b/mysql/tables/llx_commandedet.sql @@ -35,6 +35,7 @@ create table llx_commandedet total_ht double(24,8) DEFAULT 0, -- Total HT de la ligne toute quantité et incluant remise ligne et globale total_tva double(24,8) DEFAULT 0, -- Total TVA de la ligne toute quantité et incluant remise ligne et globale total_ttc double(24,8) DEFAULT 0, -- Total TTC de la ligne toute quantité et incluant remise ligne et globale + product_type integer DEFAULT 0, date_start datetime DEFAULT NULL, -- date debut si service date_end datetime DEFAULT NULL, -- date fin si service info_bits integer DEFAULT 0, -- TVA NPR ou non diff --git a/mysql/tables/llx_facture_fourn_det.sql b/mysql/tables/llx_facture_fourn_det.sql index b68ea821f85..6dc58145384 100644 --- a/mysql/tables/llx_facture_fourn_det.sql +++ b/mysql/tables/llx_facture_fourn_det.sql @@ -1,5 +1,6 @@ -- =================================================================== -- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2009 Laurent Destailleur -- -- 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 diff --git a/mysql/tables/llx_propaldet.sql b/mysql/tables/llx_propaldet.sql index 3870390546b..05d90bddded 100644 --- a/mysql/tables/llx_propaldet.sql +++ b/mysql/tables/llx_propaldet.sql @@ -26,7 +26,7 @@ create table llx_propaldet description text, fk_remise_except integer NULL, -- Lien vers table des remises fixes tva_tx double(6,3) DEFAULT 0, -- taux tva - qty real, -- quantité + qty real, -- quantity remise_percent real DEFAULT 0, -- pourcentage de remise remise real DEFAULT 0, -- montant de la remise (obsolete) price real, -- prix final (obsolete) @@ -34,10 +34,15 @@ create table llx_propaldet total_ht double(24,8) DEFAULT 0, -- Total HT de la ligne toute quantité et incluant remise ligne et globale total_tva double(24,8) DEFAULT 0, -- Total TVA de la ligne toute quantité et incluant remise ligne et globale total_ttc double(24,8) DEFAULT 0, -- Total TTC de la ligne toute quantité et incluant remise ligne et globale + product_type integer DEFAULT 0, + date_start datetime DEFAULT NULL, -- date debut si service + date_end datetime DEFAULT NULL, -- date fin si service info_bits integer DEFAULT 0, -- TVA NPR ou non + pa_ht double(24,8) DEFAULT 0, -- prix d'achat HT marge_tx double(6,3) DEFAULT 0, -- taux de marge (marge sur prix d'achat) marque_tx double(6,3) DEFAULT 0, -- taux de marque (marge sur prix de vente) + special_code tinyint(4) UNSIGNED DEFAULT 0, -- code pour les lignes speciales rang integer DEFAULT 0 -- ordre affichage sur la propal )type=innodb;