From 867baecae6f4be7c8f375baa06f965053b7b7dbe Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Wed, 6 Dec 2006 18:52:41 +0000 Subject: [PATCH] Gestion des dates par smarty --- htdocs/product/canvas/livre/livre-create.tpl | 5 +-- htdocs/product/canvas/livre/livre-view.tpl | 11 ++++- .../canvas/livrecontrat/livrecontrat-view.tpl | 38 +++++++++++++--- .../livrecouverture/livrecouverture-view.tpl | 45 +++++++++++-------- htdocs/product/canvas/product.livre.class.php | 25 +++++------ .../canvas/product.livrecontrat.class.php | 43 ++++++++++-------- .../canvas/product.livrecouverture.class.php | 43 ++++++++---------- 7 files changed, 124 insertions(+), 86 deletions(-) diff --git a/htdocs/product/canvas/livre/livre-create.tpl b/htdocs/product/canvas/livre/livre-create.tpl index 5c8ffd8dc72..2f2e1c7189f 100644 --- a/htdocs/product/canvas/livre/livre-create.tpl +++ b/htdocs/product/canvas/livre/livre-create.tpl @@ -125,10 +125,7 @@ class="normal" onfocus="this.className='focus';" onblur="this.className='normal';"> Date d'application - - - + {html_select_date field_order='DMY' start_year='-10' reverse_years=True} diff --git a/htdocs/product/canvas/livre/livre-view.tpl b/htdocs/product/canvas/livre/livre-view.tpl index de6821cba23..33383604f65 100644 --- a/htdocs/product/canvas/livre/livre-view.tpl +++ b/htdocs/product/canvas/livre/livre-view.tpl @@ -1,6 +1,13 @@ - + + + + + + @@ -10,8 +17,8 @@ - + diff --git a/htdocs/product/canvas/livrecontrat/livrecontrat-view.tpl b/htdocs/product/canvas/livrecontrat/livrecontrat-view.tpl index 85e99aa28a2..0f0029c3e1e 100644 --- a/htdocs/product/canvas/livrecontrat/livrecontrat-view.tpl +++ b/htdocs/product/canvas/livrecontrat/livrecontrat-view.tpl @@ -1,14 +1,21 @@ -
Référence{$prod_ref} + {$fiche_cursor_prev}{$fiche_cursor_next} +
Titre {$prod_label}{$prod_isbn} ISBN-13 {$prod_isbn13}
EAN {$prod_ean}
+ + + + + + - -
Référence{$prod_ref} + {$fiche_cursor_prev}{$fiche_cursor_next} +
Titre {$prod_label}
-
+ +
+ @@ -27,11 +34,17 @@ +
{$prod_stock_in_command}
+ +
+ + + - + @@ -43,4 +56,19 @@
Durée du contrat : {$prod_contrat_duree} Date d'application{$prod_contrat_date_app|date_format:"%e %B %Y"}
+
+ + + + + + + + + + + + + +
Description{$prod_description|nl2br}
Note (non visible sur les factures, propals...){$prod_note|nl2br}
\ No newline at end of file diff --git a/htdocs/product/canvas/livrecouverture/livrecouverture-view.tpl b/htdocs/product/canvas/livrecouverture/livrecouverture-view.tpl index 99ed7adfa31..afe2ddec5c6 100644 --- a/htdocs/product/canvas/livrecouverture/livrecouverture-view.tpl +++ b/htdocs/product/canvas/livrecouverture/livrecouverture-view.tpl @@ -1,9 +1,16 @@ - + + + + + + - +
Référence{$prod_ref} + {$fiche_cursor_prev}{$fiche_cursor_next} +
Titre du livre{$prod_label}{$prod_label}
@@ -13,9 +20,7 @@ Stock - - {$prod_stock_dispo} - + {$prod_stock_dispo} Seuil d'alerte {$prod_stock_alert} @@ -32,22 +37,24 @@
+ + + + - - - - - - + + + + + + + + + + +
DescriptionPhoto
Stock - {$prod_stock_dispo} - Seuil d'alerte{$prod_stock_alert}
{$prod_description|nl2br}
Note (non visible sur les factures, propals...) +
{$prod_note|nl2br}
- - Stock réel - {$prod_stock_reel} - Exemplaires en commande - {$prod_stock_in_command} - diff --git a/htdocs/product/canvas/product.livre.class.php b/htdocs/product/canvas/product.livre.class.php index ad61b66401a..1bc3d518764 100644 --- a/htdocs/product/canvas/product.livre.class.php +++ b/htdocs/product/canvas/product.livre.class.php @@ -334,25 +334,25 @@ class ProductLivre extends Product */ function assign_values(&$smarty) { - $smarty->assign('prod_canvas', 'livre'); - $smarty->assign('prod_id', $this->id); + $smarty->assign('prod_id', $this->id); + $smarty->assign('prod_ref', $this->ref); + $smarty->assign('prod_label', $this->libelle); + $smarty->assign('prod_note', $this->note); + $smarty->assign('prod_description', $this->description); + $smarty->assign('prod_canvas', $this->canvas); - $smarty->assign('prod_isbn', $this->isbn); + $smarty->assign('prod_isbn', $this->isbn); $isbn_parts = explode('-',$this->isbn); - $smarty->assign('prod_isbna', $isbn_parts[0]); - $smarty->assign('prod_isbnb', $isbn_parts[1]); - $smarty->assign('prod_isbnc', $isbn_parts[2]); + $smarty->assign('prod_isbna', $isbn_parts[0]); + $smarty->assign('prod_isbnb', $isbn_parts[1]); + $smarty->assign('prod_isbnc', $isbn_parts[2]); + $smarty->assign('prod_ean', $this->ean); - $smarty->assign('prod_ean', $this->ean); + $smarty->assign('prod_isbn13', '978-'.substr($this->isbn,0,12).substr($this->ean,-1,1)); - $smarty->assign('prod_isbn13', '978-'.substr($this->isbn,0,12).substr($this->ean,-1,1)); - - $smarty->assign('prod_ref', $this->ref); $smarty->assign('prod_tva_tx', $this->tva_tx); - $smarty->assign('prod_description', $this->description); - $smarty->assign('prod_note', $this->note); $smarty->assign('prod_pages', $this->pages); $smarty->assign('prod_format', $this->format); @@ -362,7 +362,6 @@ class ProductLivre extends Product $smarty->assign('prod_pxrevient', price($this->px_revient)); $smarty->assign('prod_pxvente', price($this->price)); - $smarty->assign('prod_label', $this->libelle); $smarty->assign('prod_contrat_taux', $this->contrat->taux); $smarty->assign('prod_contrat_duree', $this->contrat_duree); diff --git a/htdocs/product/canvas/product.livrecontrat.class.php b/htdocs/product/canvas/product.livrecontrat.class.php index 2de836ea679..1510a7ba93d 100644 --- a/htdocs/product/canvas/product.livrecontrat.class.php +++ b/htdocs/product/canvas/product.livrecontrat.class.php @@ -26,6 +26,8 @@ \version $Revision$ */ +require_once(DOL_DOCUMENT_ROOT.'/product/canvas/product.livre.class.php'); + /** \class ProductLivreContrat \brief Classe permettant la gestion des livres, cette classe surcharge la classe produit @@ -114,6 +116,7 @@ class ProductLivreContrat extends Product * \brief Lecture des donnees dans la base * \param id Id livre ('' par defaut) * \param ref Reference du livre ('' par defaut) + * \todo Rodo Resoudre le probleme de boucle infinie avec le livre */ function FetchCanvas($id='', $ref='') { @@ -121,7 +124,8 @@ class ProductLivreContrat extends Product if ($result >= 0) { - $sql = "SELECT taux,quantite,duree"; + $sql = "SELECT fk_cnv_livre,taux,quantite,duree,"; + $sql.= $this->db->pdate('date_app') ." as date_app"; $sql.= " FROM ".MAIN_DB_PREFIX."product_cnv_livre_contrat"; if ($id) $sql.= " WHERE rowid = '".$id."'"; if ($ref) $sql.= " WHERE ref = '".addslashes($ref)."'"; @@ -135,6 +139,12 @@ class ProductLivreContrat extends Product $this->taux = $result["taux"]; $this->quantite = $result["quantite"]; $this->duree = $result["duree"]; + $this->date_app = $result["date_app"]; + + // On charge le livre pour avoir le titre + // ne pas utiliser FetchCanvas qui cree une boucle infinie + $this->livre = new ProductLivre($this->db); + $this->livre->Fetch($result["fk_cnv_livre"]); $this->db->free(); } @@ -152,11 +162,13 @@ class ProductLivreContrat extends Product $quant = trim($datas["contrat_quant"]); $duree = trim($datas["contrat_duree"]); + $date_app = mktime(1,1,1,$datas["Date_Month"],$datas["Date_Day"],$datas["Date_Year"]); + $sql = "UPDATE ".MAIN_DB_PREFIX."product_cnv_livre_contrat "; $sql .= " SET taux = '$taux'"; $sql .= " , quantite = '$quant'"; $sql .= " , duree = '$duree'"; - $sql .= " , date_app = '$date_app'"; + $sql .= " , date_app = '".$this->db->idate($date_app)."'"; $sql .= " WHERE rowid = " . $this->id; if ( $this->db->query($sql) ) @@ -176,24 +188,18 @@ class ProductLivreContrat extends Product */ function assign_values(&$smarty) { - $smarty->assign('prod_canvas', 'livre'); - $smarty->assign('prod_id', $this->id); + $smarty->assign('prod_id', $this->id); + $smarty->assign('prod_ref', $this->ref); + $smarty->assign('prod_label', $this->livre->libelle); + $smarty->assign('prod_note', $this->note); + $smarty->assign('prod_description', $this->description); - $smarty->assign('prod_isbn', $this->isbn); + $smarty->assign('prod_canvas', $this->canvas); - $isbn_parts = explode('-',$this->isbn); - - $smarty->assign('prod_isbna', $isbn_parts[0]); - $smarty->assign('prod_isbnb', $isbn_parts[1]); - $smarty->assign('prod_isbnc', $isbn_parts[2]); - - $smarty->assign('prod_ean', $this->ean); - - $smarty->assign('prod_isbn13', '978-'.substr($this->isbn,0,12).substr($this->ean,-1,1)); - - $smarty->assign('prod_contrat_taux', $this->contrat->taux); - $smarty->assign('prod_contrat_duree', $this->contrat_duree); - $smarty->assign('prod_contrat_quant', $this->contrat_quantite); + $smarty->assign('prod_contrat_taux', $this->taux); + $smarty->assign('prod_contrat_duree', $this->duree); + $smarty->assign('prod_contrat_date_app', $this->date_app); + $smarty->assign('prod_contrat_quant', $this->quantite); $smarty->assign('prod_stock_reel', $this->stock_reel); $smarty->assign('prod_stock_dispo', ($this->stock_reel - $this->stock_in_command)); @@ -205,6 +211,5 @@ class ProductLivreContrat extends Product $smarty->assign('smarty_stock_dispo_class', 'class="alerte"'); } } - } ?> diff --git a/htdocs/product/canvas/product.livrecouverture.class.php b/htdocs/product/canvas/product.livrecouverture.class.php index fe1006b3d8b..f3971983183 100644 --- a/htdocs/product/canvas/product.livrecouverture.class.php +++ b/htdocs/product/canvas/product.livrecouverture.class.php @@ -26,6 +26,8 @@ \version $Revision$ */ +require_once(DOL_DOCUMENT_ROOT.'/product/canvas/product.livre.class.php'); + /** \class ProductLivreCouverture \brief Classe permettant la gestion des livres, cette classe surcharge la classe produit @@ -80,6 +82,11 @@ class ProductLivreCouverture extends Product { $result = $this->fetch($id,$ref); + // On charge le livre pour avoir le titre + // ne pas utiliser FetchCanvas qui cree une boucle infinie + $this->livre = new ProductLivre($this->db); + //$this->livre->Fetch($result["fk_cnv_livre"]); + return $result; } /** @@ -98,36 +105,24 @@ class ProductLivreCouverture extends Product */ function assign_values(&$smarty) { - $smarty->assign('prod_canvas', 'livre'); - $smarty->assign('prod_id', $this->id); + $smarty->assign('prod_id', $this->id); + $smarty->assign('prod_ref', $this->ref); + $smarty->assign('prod_label', $this->livre->libelle); + $smarty->assign('prod_note', $this->note); + $smarty->assign('prod_description', $this->description); + $smarty->assign('prod_canvas', $this->canvas); - $smarty->assign('prod_isbn', $this->isbn); + $this->stock_dispo = ($this->stock_reel - $this->stock_in_command); - $isbn_parts = explode('-',$this->isbn); - - $smarty->assign('prod_isbna', $isbn_parts[0]); - $smarty->assign('prod_isbnb', $isbn_parts[1]); - $smarty->assign('prod_isbnc', $isbn_parts[2]); + $smarty->assign('prod_stock_reel', $this->stock_reel); + $smarty->assign('prod_stock_dispo', $this->stock_dispo); + $smarty->assign('prod_stock_in_command', $this->stock_in_command); + $smarty->assign('prod_stock_alert', $this->seuil_stock_alerte); - $smarty->assign('prod_ean', $this->ean); - - $smarty->assign('prod_isbn13', '978-'.substr($this->isbn,0,12).substr($this->ean,-1,1)); - - $smarty->assign('prod_contrat_taux', $this->contrat->taux); - $smarty->assign('prod_contrat_duree', $this->contrat_duree); - $smarty->assign('prod_contrat_quant', $this->contrat_quantite); - - $smarty->assign('prod_stock_reel', $this->stock_reel); - $smarty->assign('prod_stock_dispo', ($this->stock_reel - $this->stock_in_command)); - $smarty->assign('prod_stock_in_command', $this->stock_in_command); - $smarty->assign('prod_stock_alert', $this->seuil_stock_alerte); - - if ($this->seuil_stock_alerte > ($this->stock_reel - $this->stock_in_command) && $this->status == 1) + if ( ($this->seuil_stock_alerte > $this->stock_dispo) && ($this->status == 1) ) { $smarty->assign('smarty_stock_dispo_class', 'class="alerte"'); } } - - } ?>