diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 02108ecd4d8..99d47d704fc 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -73,9 +73,6 @@ $socid = restrictedArea($user, $module, $objectid, $dbtable); // Nombre de ligne pour choix de produit/service predefinis $NBLINES=4; -$form=new Form($db); - - /******************************************************************************/ /* Actions */ @@ -854,11 +851,11 @@ if ($_GET['propalid'] > 0) print ''; if ($conf->projet->enabled) $rowspan++; - if ($conf->expedition->enabled) - { - if ($conf->global->PROPALE_ADD_SHIPPING_DATE) $rowspan++; - if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS) $rowspan++; - } + if ($conf->expedition->enabled || $conf->livraison->enabled) + { + if ($conf->global->PROPALE_ADD_SHIPPING_DATE || !$conf->commande->enabled) $rowspan++; + if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS || !$conf->commande->enabled) $rowspan++; + } // Notes print ''.$langs->trans('NotePublic').' :
'. nl2br($propal->note_public).''; @@ -901,7 +898,7 @@ if ($_GET['propalid'] > 0) // gerer par les commandes et non les propales if ($conf->expedition->enabled || $conf->livraison->enabled) { - if ($conf->global->PROPALE_ADD_SHIPPING_DATE) + if ($conf->global->PROPALE_ADD_SHIPPING_DATE || !$conf->commande->enabled) { $langs->load('deliveries'); print ''; @@ -928,7 +925,7 @@ if ($_GET['propalid'] > 0) } // adresse de livraison - if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS) + if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS || !$conf->commande->enabled) { print ''; print ''; } diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 49c363384c1..1b74e62f659 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -1207,7 +1207,7 @@ class Commande extends CommonObject $sql = 'SELECT fk_product, sum(ed.qty)'; $sql.=' FROM '.MAIN_DB_PREFIX.'expeditiondet as ed, '.MAIN_DB_PREFIX.'expedition as e, '.MAIN_DB_PREFIX.'commande as c, '.MAIN_DB_PREFIX.'commandedet as cd'; - $sql.=' WHERE ed.fk_expedition = e.rowid AND ed.fk_commande_ligne = cd .rowid AND cd.fk_commande = c.rowid'; + $sql.=' WHERE ed.fk_expedition = e.rowid AND ed.fk_origin_line = cd.rowid AND cd.fk_commande = c.rowid'; $sql.=' AND cd.fk_commande =' .$this->id; if ($filtre_statut >= 0) $sql.=' AND e.fk_statut = '.$filtre_statut; $sql .= ' GROUP BY fk_product '; @@ -2401,28 +2401,28 @@ class CommandeLigne if ($result) { $objp = $this->db->fetch_object($result); - $this->rowid = $objp->rowid; - $this->fk_propal = $objp->fk_propal; - $this->desc = $objp->description; - $this->qty = $objp->qty; - $this->price = $objp->price; - $this->subprice = $objp->subprice; - $this->tva_tx = $objp->tva_tx; - $this->remise = $objp->remise; - $this->remise_percent = $objp->remise_percent; + $this->rowid = $objp->rowid; + $this->fk_commande = $objp->fk_commande; + $this->desc = $objp->description; + $this->qty = $objp->qty; + $this->price = $objp->price; + $this->subprice = $objp->subprice; + $this->tva_tx = $objp->tva_tx; + $this->remise = $objp->remise; + $this->remise_percent = $objp->remise_percent; $this->fk_remise_except = $objp->fk_remise_except; - $this->produit_id = $objp->fk_product; - $this->info_bits = $objp->info_bits; - $this->total_ht = $objp->total_ht; - $this->total_tva = $objp->total_tva; - $this->total_ttc = $objp->total_ttc; - $this->marge_tx = $objp->marge_tx; - $this->marque_tx = $objp->marque_tx; - $this->rang = $objp->rang; + $this->produit_id = $objp->fk_product; + $this->info_bits = $objp->info_bits; + $this->total_ht = $objp->total_ht; + $this->total_tva = $objp->total_tva; + $this->total_ttc = $objp->total_ttc; + $this->marge_tx = $objp->marge_tx; + $this->marque_tx = $objp->marque_tx; + $this->rang = $objp->rang; - $this->ref = $objp->product_ref; - $this->product_libelle = $objp->product_libelle; - $this->product_desc = $objp->product_desc; + $this->ref = $objp->product_ref; + $this->product_libelle = $objp->product_libelle; + $this->product_desc = $objp->product_desc; $this->db->free($result); } diff --git a/htdocs/expedition/commande.php b/htdocs/expedition/commande.php index 7e25c6134ea..7730a039ddb 100644 --- a/htdocs/expedition/commande.php +++ b/htdocs/expedition/commande.php @@ -1,7 +1,7 @@ * Copyright (C) 2005 Laurent Destailleur - * Copyright (C) 2005-2006 Regis Houssin + * Copyright (C) 2005-2008 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 @@ -81,95 +81,94 @@ llxHeader('',$langs->trans("OrderCard")); if ($_GET["id"] > 0) { - $commande = New Commande($db); - if ( $commande->fetch($_GET["id"]) > 0) - { - $commande->loadExpeditions(1); + $commande = New Commande($db); + if ( $commande->fetch($_GET["id"]) > 0) + { + $commande->loadExpeditions(1); - $soc = new Societe($db); - $soc->fetch($commande->socid); + $soc = new Societe($db); + $soc->fetch($commande->socid); - $author = new User($db); - $author->id = $commande->user_author_id; - $author->fetch(); + $author = new User($db); + $author->id = $commande->user_author_id; + $author->fetch(); $head = commande_prepare_head($commande); - dolibarr_fiche_head($head, 'shipping', $langs->trans("CustomerOrder")); + dolibarr_fiche_head($head, 'shipping', $langs->trans("CustomerOrder")); - /* - * Confirmation de la validation - * - */ - if ($_GET["action"] == 'cloture') - { - $html->form_confirm("commande.php?id=".$_GET["id"],"Clôturer la commande","Etes-vous sûr de vouloir clôturer cette commande ?","confirm_cloture"); - print "
"; - } - - // Onglet commande - $nbrow=8; - if ($conf->projet->enabled) $nbrow++; - - print '
'; @@ -1014,11 +1011,11 @@ if ($_GET['propalid'] > 0) print ''; if ($_GET['action'] == 'classer') { - $form->form_project($_SERVER['PHP_SELF'].'?propalid='.$propal->id, $propal->socid, $propal->projetidp, 'projetidp'); + $html->form_project($_SERVER['PHP_SELF'].'?propalid='.$propal->id, $propal->socid, $propal->projetidp, 'projetidp'); } else { - $form->form_project($_SERVER['PHP_SELF'].'?propalid='.$propal->id, $propal->socid, $propal->projetidp, 'none'); + $html->form_project($_SERVER['PHP_SELF'].'?propalid='.$propal->id, $propal->socid, $propal->projetidp, 'none'); } print '
'; - - // Ref - print ''; - print ''; - print ''; - - // Ref commande client - print '
'.$langs->trans('Ref').''.$commande->ref.'
'; - print ''; - if ($_GET['action'] != 'RefCustomerOrder' && $commande->brouillon) print ''; - print '
'; - print $langs->trans('RefCustomer').''; - print ''.img_edit($langs->trans('Modify')).'
'; - print '
'; - if ($user->rights->commande->creer && $_GET['action'] == 'RefCustomerOrder') + /* + * Confirmation de la validation + * + */ + if ($_GET["action"] == 'cloture') + { + $html->form_confirm("commande.php?id=".$_GET["id"],"Clôturer la commande","Etes-vous sûr de vouloir clôturer cette commande ?","confirm_cloture"); + print "
"; + } + + // Onglet commande + $nbrow=8; + if ($conf->projet->enabled) $nbrow++; + + print ''; + + // Ref + print ''; + print ''; + print ''; + + // Ref commande client + print ''; - print ''; - - - // Société - print ''; - print ''; - print ''; - - // Date - print ''; - print ''; - print ''; + print ''; + + // Société + print ''; + print ''; + print ''; + + // Date + print ''; + print ''; + print ''; - print ''; - - // Date de livraison - print ''; + print ''; + + // Date de livraison + print ''; - print ''; - print ''; - - - // Adresse de livraison - print ''; + print ''; + print ''; + + // Adresse de livraison + print ''; - - // Conditions et modes de réglement - print ''; + print ''; + + // Projet + if ($conf->projet->enabled) + { + $langs->load('projects'); + print ''; + } + + // Lignes de 3 colonnes - // Projet - if ($conf->projet->enabled) - { - $langs->load('projects'); - print ''; - } + // Total HT + print ''; + print ''; + print ''; - // Lignes de 3 colonnes + // Total TVA + print ''; + print ''; + + // Total TTC + print ''; + print ''; - // Total HT - print ''; - print ''; - print ''; - - // Total TVA - print ''; - print ''; + // Statut + print ''; + print ''; + print ''; - // Total TTC - print ''; - print ''; - - // Statut - print ''; - print ''; - print ''; - - print '
'.$langs->trans('Ref').''.$commande->ref.'
'; + print ''; + if ($_GET['action'] != 'RefCustomerOrder' && $commande->brouillon) print ''; + print '
'; + print $langs->trans('RefCustomer').''; + print ''.img_edit($langs->trans('Modify')).'
'; + print '
'; + if ($user->rights->commande->creer && $_GET['action'] == 'RefCustomerOrder') { - print '
'; + print ''; print ''; print ''; print ' '; print '
'; } - else + else { print $commande->ref_client; } - print '
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
'.$langs->trans('Date').''.dolibarr_print_date($commande->date,'daytext').''.$langs->trans('Source').' : ' . $commande->sources[$commande->source] ; - if ($commande->source == 0) + print '
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
'.$langs->trans('Date').''.dolibarr_print_date($commande->date,'daytext').''.$langs->trans('Source').' : ' . $commande->sources[$commande->source] ; + if ($commande->source == 0) { // Si source = propal $propal = new Propal($db); $propal->fetch($commande->propale_id); print ' -> '.$propal->ref.''; } - print '
'; - print ''; - - if ($_GET['action'] != 'editdate_livraison' && $commande->brouillon) print ''; - print '
'; - print $langs->trans('DeliveryDate'); - print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'
'; - print '
'; - if ($_GET['action'] == 'editdate_livraison') + print '
'; + print ''; + + if ($_GET['action'] != 'editdate_livraison' && $commande->brouillon) print ''; + print '
'; + print $langs->trans('DeliveryDate'); + print 'id.'">'.img_edit($langs->trans('SetDeliveryDate'),1).'
'; + print '
'; + if ($_GET['action'] == 'editdate_livraison') { print '
'; print ''; @@ -177,314 +176,308 @@ if ($_GET["id"] > 0) print ''; print '
'; } - else + else { print dolibarr_print_date($commande->date_livraison,'daytext'); } - print '
'.$langs->trans('NotePublic').' :
'; - print nl2br($commande->note_public); - print '
'; - print ''; - - if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print ''; - print '
'; - print $langs->trans('DeliveryAddress'); - print 'socid.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'
'; - print '
'; - - if ($_GET['action'] == 'editdelivery_adress') + print ''.$langs->trans('NotePublic').' :
'; + print nl2br($commande->note_public); + print '
'; + print ''; + + if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print ''; + print '
'; + print $langs->trans('DeliveryAddress'); + print 'socid.'&id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'
'; + print '
'; + + if ($_GET['action'] == 'editdelivery_adress') { $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id','commande',$commande->id); } - else + else { $html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'none','commande',$commande->id); } - print '
'; - print ''; + print ''; + + // Conditions et modes de réglement + print ''; - print ''; + if ($_GET['action'] != 'editconditions' && $commande->brouillon) print ''; + print '
'; - print $langs->trans('PaymentConditionsShort'); - print '
'; + print ''; - if ($_GET['action'] != 'editconditions' && $commande->brouillon) print ''; - print '
'; + print $langs->trans('PaymentConditionsShort'); + print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; - print '
'; - if ($_GET['action'] == 'editconditions') - { - $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->cond_reglement_id,'cond_reglement_id'); - } - else - { - $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->cond_reglement_id,'none'); - } - print '
'; - print ''; - if ($_GET['action'] != 'editmode' && $commande->brouillon) print ''; - print '
'; - print $langs->trans('PaymentMode'); - print 'id.'">'.img_edit($langs->trans('SetMode'),1).'
'; - print '
'; - if ($_GET['action'] == 'editmode') - { - $html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->mode_reglement_id,'mode_reglement_id'); - } - else - { - $html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->mode_reglement_id,'none'); - } - print '
id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; + print '
'; + if ($_GET['action'] == 'editconditions') + { + $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->cond_reglement_id,'cond_reglement_id'); + } + else + { + $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->cond_reglement_id,'none'); + } + print '
'; + print ''; + if ($_GET['action'] != 'editmode' && $commande->brouillon) print ''; + print '
'; + print $langs->trans('PaymentMode'); + print 'id.'">'.img_edit($langs->trans('SetMode'),1).'
'; + print '
'; + if ($_GET['action'] == 'editmode') + { + $html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->mode_reglement_id,'mode_reglement_id'); + } + else + { + $html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->mode_reglement_id,'none'); + } + print '
'; + print ''; + if ($_GET['action'] != 'classer' && $commande->brouillon) print ''; + print '
'; + print $langs->trans('Project'); + print ''.img_edit($langs->trans('SetProject')).'
'; + print '
'; + if ($_GET['action'] == 'classer') + { + $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'projetid'); + } + else + { + $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'none'); + } + print '
'; - print ''; - if ($_GET['action'] != 'classer' && $commande->brouillon) print ''; - print '
'; - print $langs->trans('Project'); - print ''.img_edit($langs->trans('SetProject')).'
'; - print '
'; - if ($_GET['action'] == 'classer') - { - $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'projetid'); - } - else - { - $html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->socid, $commande->projet_id, 'none'); - } - print '
'.$langs->trans('AmountHT').''.price($commande->total_ht).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('AmountVAT').''.price($commande->total_tva).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('AmountTTC').''.price($commande->total_ttc).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('AmountHT').''.price($commande->total_ht).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('AmountVAT').''.price($commande->total_tva).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('Status').''.$commande->getLibStatut(4).'
'.$langs->trans('AmountTTC').''.price($commande->total_ttc).''.$langs->trans('Currency'.$conf->monnaie).'
'.$langs->trans('Status').''.$commande->getLibStatut(4).'

'; + print '

'; - /** - * Lignes de commandes avec quantité livrées et reste à livrer - * Les quantités livrées sont stockées dans $commande->expeditions[fk_product] - */ - echo ''; + /** + * Lignes de commandes avec quantité livrées et reste à livrer + * Les quantités livrées sont stockées dans $commande->expeditions[fk_product] + */ + print '
'; - $sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.subprice"; - $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as l "; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product = p.rowid"; - $sql.= " WHERE l.fk_commande = ".$commande->id; - $sql.= " AND p.fk_product_type <> 1"; - $sql.= " ORDER BY l.rowid"; + $sql = "SELECT cd.fk_product, cd.description, cd.price, cd.qty, cd.rowid, cd.tva_tx, cd.subprice"; + $sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd "; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid"; + $sql.= " WHERE cd.fk_commande = ".$commande->id; + $sql.= " AND p.fk_product_type <> 1"; + $sql.= " ORDER BY cd.rowid"; - $resql = $db->query($sql); - if ($resql) + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + print ''; + print ''; + print ''; + print ''; + print ''; + if ($conf->stock->enabled) + { + print ''; + } + else + { + print ''; + } + print "\n"; + + $var=true; + $reste_a_livrer = array(); + while ($i < $num) + { + $objp = $db->fetch_object($resql); + + $var=!$var; + print ""; + if ($objp->fk_product > 0) { - $num = $db->num_rows($resql); - $i = 0; - - print ''; - print ''; - print ''; - print ''; - print ''; - if ($conf->stock->enabled) - { - print ''; - } - else - { - print ''; - } - print "\n"; - - $var=true; - $reste_a_livrer = array(); - while ($i < $num) - { - $objp = $db->fetch_object($resql); - - $var=!$var; - print ""; - if ($objp->fk_product > 0) - { - $product = new Product($db); - $product->fetch($objp->fk_product); - print ''; - } - else - { - print "\n"; - } - - print ''; - - print ''; - - $reste_a_livrer[$objp->fk_product] = $objp->qty - $quantite_livree; - $reste_a_livrer_total = $reste_a_livrer_total + $reste_a_livrer[$objp->fk_product]; - print ''; - - if ($conf->stock->enabled) - { - print ''; - } - else - { - print ''; - } - print ""; - - $i++; - $var=!$var; - } - $db->free($resql); - - if (! $num) - { - print '
'.$langs->trans("Description").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyShipped").''.$langs->trans("KeepToShip").''.$langs->trans("Stock").' 
'.$langs->trans("Description").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyShipped").''.$langs->trans("KeepToShip").''.$langs->trans("Stock").' 
'; - print ''; - print img_object($langs->trans("Product"),"product").' '.$product->ref.''; - print $product->libelle?' - '.$product->libelle:''; - print '".nl2br($objp->description)."'.$objp->qty.''; - $quantite_livree = $commande->expeditions[$objp->fk_product]; - print $quantite_livree; - print ''; - print $reste_a_livrer[$objp->fk_product]; - print ''; - print $product->stock_reel; - if ($product->stock_reel < $reste_a_livrer[$objp->fk_product]) - { - print ' '.img_warning($langs->trans("StockTooLow")); - } - print ' 
'.$langs->trans("NoArticleOfTypeProduct").'
'; - } - - print "
"; + $product = new Product($db); + $product->fetch($objp->fk_product); + print ''; + print ''; + print img_object($langs->trans("Product"),"product").' '.$product->ref.''; + print $product->libelle?' - '.$product->libelle:''; + print ''; } else { - dolibarr_print_error($db); + print "".nl2br($objp->description)."\n"; } - - print ''; - - /* - * Boutons Actions - */ - if ($user->societe_id == 0) - { - print '
'; + print ''.$objp->qty.''; - // Bouton expedier sans gestion des stocks - if (! $conf->stock->enabled && $reste_a_livrer_total > 0 && ! $commande->brouillon && $user->rights->expedition->creer) - { - print ''.$langs->trans("NewSending").''; - } + print ''; + $quantite_livree = $commande->expeditions[$objp->fk_product]; + print $quantite_livree; + print ''; - print "
"; + $reste_a_livrer[$objp->fk_product] = $objp->qty - $quantite_livree; + $reste_a_livrer_total = $reste_a_livrer_total + $reste_a_livrer[$objp->fk_product]; + print ''; + print $reste_a_livrer[$objp->fk_product]; + print ''; - } - - print ''; } + else + { + print ''; + } + print ""; + + $i++; + $var=!$var; + } + $db->free($resql); + + if (! $num) + { + print '
'; - - /* - * Documents générés - * - */ - $comref = sanitize_string($commande->ref); - $file = $conf->commande->dir_output . '/' . $comref . '/' . $comref . '.pdf'; - $relativepath = $comref.'/'.$comref.'.pdf'; - $filedir = $conf->commande->dir_output . '/' . $comref; - $urlsource=$_SERVER["PHP_SELF"]."?id=".$commande->id; - $genallowed=0; - $delallowed=0; - - $somethingshown=$html->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf); - - - print ''; - - - // Bouton expedier avec gestion des stocks - if ($conf->stock->enabled && $reste_a_livrer_total > 0 && $commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer) + if ($conf->stock->enabled) { - print_titre($langs->trans("NewSending")); - - print '
'; - print ''; - print ''; - print ''; - print ''; - - $entrepot = new Entrepot($db); - $langs->load("stocks"); - - - - print ''; - print ''; - print ''; - /* - print ''; - print ''; - */ - - print ''; - - print "
'.$langs->trans("Warehouse").''; - - if (sizeof($user->entrepots) === 1) - { - $uentrepot = array(); - $uentrepot[$user->entrepots[0]['id']] = $user->entrepots[0]['label']; - $html->select_array("entrepot_id",$uentrepot); - } - else - { - $html->select_array("entrepot_id",$entrepot->list_array()); - } - - if (sizeof($entrepot->list_array()) <= 0) - { - print '   Aucun entrepôt définit, definissez en un'; - } - print '
Mode d\'expédition'; - $html->select_array("entrepot_id",$entrepot->list_array()); - print '
'; - print ''; - print '
"; - print "
\n"; - - $somethingshown=1; + print '
'; + print $product->stock_reel; + if ($product->stock_reel < $reste_a_livrer[$objp->fk_product]) + { + print ' '.img_warning($langs->trans("StockTooLow")); + } + print ' 
'.$langs->trans("NoArticleOfTypeProduct").'
'; + } + + print "
"; + } + else + { + dolibarr_print_error($db); + } + + print ''; + + + /* + * Boutons Actions + */ + if ($user->societe_id == 0) + { + print '
'; + + // Bouton expedier sans gestion des stocks + if (! $conf->stock->enabled && $reste_a_livrer_total > 0 && ! $commande->brouillon && $user->rights->expedition->creer) + { + print ''.$langs->trans("NewSending").''; + } + print "
"; + } + + print ''; + print ''; + print ''; + /* + print ''; + print ''; + */ + + print ''; + + print "
'; + + /* + * Documents générés + * + */ + $comref = sanitize_string($commande->ref); + $file = $conf->commande->dir_output . '/' . $comref . '/' . $comref . '.pdf'; + $relativepath = $comref.'/'.$comref.'.pdf'; + $filedir = $conf->commande->dir_output . '/' . $comref; + $urlsource=$_SERVER["PHP_SELF"]."?id=".$commande->id; + $genallowed=0; + $delallowed=0; + + $somethingshown=$html->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf); + + print ''; + + // Bouton expedier avec gestion des stocks + if ($conf->stock->enabled && $reste_a_livrer_total > 0 && $commande->statut > 0 && $commande->statut < 3 && $user->rights->expedition->creer) + { + print_titre($langs->trans("NewSending")); + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; - print "
"; + $entrepot = new Entrepot($db); + $langs->load("stocks"); + + print '
'.$langs->trans("Warehouse").''; + + if (sizeof($user->entrepots) === 1) + { + $uentrepot = array(); + $uentrepot[$user->entrepots[0]['id']] = $user->entrepots[0]['label']; + $html->select_array("entrepot_id",$uentrepot); + } + else + { + $html->select_array("entrepot_id",$entrepot->list_array()); + } + + if (sizeof($entrepot->list_array()) <= 0) + { + print '   Aucun entrepôt définit, definissez en un'; + } + print '
Mode d\'expédition'; + $html->select_array("entrepot_id",$entrepot->list_array()); + print '
'; + print ''; + print '
"; + print "\n"; + + $somethingshown=1; + } + + print ""; /* @@ -498,7 +491,7 @@ if ($_GET["id"] > 0) $sql .= " , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e"; if ($conf->livraison->enabled) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON l.fk_expedition = e.rowid"; $sql .= " WHERE cd.fk_commande = ".$commande->id; - $sql .= " AND cd.rowid = ed.fk_commande_ligne"; + $sql .= " AND cd.rowid = ed.fk_origin_line"; $sql .= " AND ed.fk_expedition = e.rowid"; $sql .= " ORDER BY cd.fk_product"; diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php index b5de9d43c50..bd7f685a811 100644 --- a/htdocs/expedition/expedition.class.php +++ b/htdocs/expedition/expedition.class.php @@ -1,7 +1,8 @@ - * Copyright (C) 2006 Laurent Destailleur - * Copyright (C) 2007 Franky Van Liedekerke +/* Copyright (C) 2003 Rodolphe Quiedeville + * Copyright (C) 2006 Laurent Destailleur + * Copyright (C) 2007 Franky Van Liedekerke + * Copyright (C) 2005-2008 Régis 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 @@ -29,7 +30,8 @@ */ require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php"); -require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php"); +if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); +if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php"); /** @@ -40,9 +42,12 @@ class Expedition extends CommonObject { var $db; var $id; + var $socid; var $brouillon; var $entrepot_id; var $modelpdf; + var $origin; + var $origin_id; /** @@ -50,8 +55,8 @@ class Expedition extends CommonObject * */ function Expedition($DB) - { - global $langs; + { + global $langs; $this->db = $DB; $this->lignes = array(); @@ -61,7 +66,7 @@ class Expedition extends CommonObject $this->statuts[1] = $langs->trans("Validated"); $this->products = array(); - } + } /** * \brief Créé expédition en base @@ -69,115 +74,125 @@ class Expedition extends CommonObject * \return int <0 si erreur, id expédition créée si ok */ function create($user) + { + global $conf; + + require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php"; + $error = 0; + /* On positionne en mode brouillon l'expedition */ + $this->brouillon = 1; + + $this->user = $user; + + $this->db->begin(); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (date_creation, fk_user_author, date_expedition"; + $sql.= ", fk_soc"; + $sql.= ")"; + $sql.= " VALUES (now(), $user->id, ".$this->db->idate($this->date_expedition); + $sql.= ", ".$this->socid; + $sql.= ")"; + + $resql=$this->db->query($sql); + if ($resql) { - require_once DOL_DOCUMENT_ROOT ."/product/stock/mouvementstock.class.php"; - $error = 0; - /* On positionne en mode brouillon la commande */ - $this->brouillon = 1; + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expedition"); - $this->user = $user; - - $this->db->begin(); - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition (date_creation, fk_user_author, date_expedition, fk_commande"; - if ($this->entrepot_id) $sql.= ", fk_entrepot"; - $sql.= ")"; - $sql.= " VALUES (now(), $user->id, ".$this->db->idate($this->date_expedition).",$this->commande_id"; - if ($this->entrepot_id) $sql.= ", $this->entrepot_id"; - $sql.= ")"; - - $resql=$this->db->query($sql); - if ($resql) + $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id; + if ($this->db->query($sql)) + { + // Insertion des lignes + for ($i = 0 ; $i < sizeof($this->lignes) ; $i++) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."expedition"); - - $sql = "UPDATE ".MAIN_DB_PREFIX."expedition SET ref='(PROV".$this->id.")' WHERE rowid=".$this->id; - if ($this->db->query($sql)) - { - - $this->commande = new Commande($this->db); - $this->commande->id = $this->commande_id; - $this->commande->fetch_lines(); - - // Insertion des lignes - for ($i = 0 ; $i < sizeof($this->lignes) ; $i++) - { - if (! $this->create_line(0, $this->lignes[$i]->commande_ligne_id, $this->lignes[$i]->qty)) - { - $error++; - } - } - - /* - * - */ - $sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 2 WHERE rowid=".$this->commande_id; - if (! $this->db->query($sql)) - { - $error++; - } + if (! $this->create_line($this->lignes[$i]->entrepot_id, $this->lignes[$i]->origin_line_id, $this->lignes[$i]->qty)) + { + $error++; + } + } - if ($error==0) - { - $this->db->commit(); - return $this->id; - } - else - { - $error++; - $this->error=$this->db->error()." - sql=$sql"; - $this->db->rollback(); - return -3; - } - } - else - { - $error++; - $this->error=$this->db->error()." - sql=$sql"; - $this->db->rollback(); - return -2; - } + if ($this->id && $this->origin_id) + { + if ($conf->commande->enabled) + { + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'co_exp (fk_expedition, fk_commande) VALUES ('.$this->id.','.$this->origin_id.')'; + if (!$this->db->query($sql)) + { + $error++; + } + + $sql = "UPDATE ".MAIN_DB_PREFIX."commande SET fk_statut = 2 WHERE rowid=".$this->origin_id; + if (! $this->db->query($sql)) + { + $error++; + } + } + else + { + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'pr_exp (fk_expedition, fk_propal) VALUES ('.$this->id.','.$this->origin_id.')'; + if (!$this->db->query($sql)) + { + $error++; + } + + //Todo: definir un statut + $sql = "UPDATE ".MAIN_DB_PREFIX."propal SET fk_statut = 9 WHERE rowid=".$this->origin_id; + if (! $this->db->query($sql)) + { + $error++; + } + } + } + + if ($error==0) + { + $this->db->commit(); + return $this->id; } else { - $error++; - $this->error=$this->db->error()." - sql=$sql"; - $this->db->rollback(); - return -1; + $error++; + $this->error=$this->db->error()." - sql=$sql"; + $this->db->rollback(); + return -3; } + } + else + { + $error++; + $this->error=$this->db->error()." - sql=$sql"; + $this->db->rollback(); + return -2; + } } + else + { + $error++; + $this->error=$this->db->error()." - sql=$sql"; + $this->db->rollback(); + return -1; + } + } /** * * */ - function create_line($transaction, $commande_ligne_id, $qty) + function create_line($entrepot_id, $origin_line_id, $qty) { - $error = 0; + $error = 0; - $idprod = 0; - $j = 0; - while (($j < sizeof($this->commande->lignes)) && idprod == 0) - { - if ($this->commande->lignes[$j]->id == $commande_ligne_id) - { - $idprod = $this->commande->lignes[$j]->fk_product; - } - $j++; - } - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet (fk_expedition, fk_commande_ligne, qty)"; - $sql .= " VALUES ($this->id,".$commande_ligne_id.",".$qty.")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."expeditiondet (fk_expedition, fk_entrepot, fk_origin_line, qty)"; + $sql .= " VALUES (".$this->id.", ".$entrepot_id.", ".$origin_line_id.", ".$qty.")"; if (! $this->db->query($sql) ) - { - $error++; - } + { + $error++; + } if ($error == 0 ) - { - return 1; - } + { + return 1; + } } /** @@ -188,16 +203,16 @@ class Expedition extends CommonObject { global $conf; - $sql = "SELECT e.rowid, e.date_creation, e.ref, e.fk_user_author, e.fk_statut, e.fk_commande, e.fk_entrepot,"; - $sql.= " ".$this->db->pdate("e.date_expedition")." as date_expedition, e.model_pdf,"; - $sql.= " c.fk_adresse_livraison"; + $sql = "SELECT e.rowid, e.fk_soc as socid, e.date_creation, e.ref, e.fk_user_author, e.fk_statut"; + $sql.= ", ".$this->db->pdate("e.date_expedition")." as date_expedition, e.model_pdf, e.fk_adresse_livraison"; + if ($conf->commande->enabled) $sql.=", ce.fk_commande as origin_id"; if ($conf->livraison->enabled) $sql.=", l.rowid as livraison_id"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande as c,"; - $sql.= " ".MAIN_DB_PREFIX."expedition as e"; + $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."co_exp as ce ON e.rowid = ce.fk_expedition"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON ce.fk_commande = c.rowid"; if ($conf->livraison->enabled) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."livraison as l ON e.rowid = l.fk_expedition"; $sql.= " WHERE e.rowid = ".$id; - $sql.= " AND e.fk_commande = c.rowid"; - + $result = $this->db->query($sql) ; if ($result) @@ -208,17 +223,17 @@ class Expedition extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->ref; + $this->socid = $obj->socid; $this->statut = $obj->fk_statut; - $this->commande_id = $obj->fk_commande; - if ($conf->livraison->enabled) - { - $this->livraison_id = $obj->livraison_id; - } + $this->origin_id = $obj->origin_id; + $this->livraison_id = $obj->livraison_id; $this->user_author_id = $obj->fk_user_author; $this->date = $obj->date_expedition; - $this->entrepot_id = $obj->fk_entrepot; $this->adresse_livraison_id = $obj->fk_adresse_livraison; $this->modelpdf = $obj->model_pdf; + + if ($conf->commande->enabled) $this->origin = "commande"; + $this->db->free($result); if ($this->statut == 0) $this->brouillon = 1; @@ -416,95 +431,94 @@ class Expedition extends CommonObject * Ajoute une ligne * */ - function addline( $id, $qty ) - { - $num = sizeof($this->lignes); - $ligne = new ExpeditionLigne($this->db); + function addline( $entrepot_id, $id, $qty ) + { + $num = sizeof($this->lignes); + $ligne = new ExpeditionLigne($this->db); - $ligne->commande_ligne_id = $id; - $ligne->qty = $qty; + $ligne->entrepot_id = $entrepot_id; + $ligne->origin_line_id = $id; + $ligne->qty = $qty; - $this->lignes[$num] = $ligne; - } + $this->lignes[$num] = $ligne; + } /** * * */ function delete_line($idligne) - { - if ($this->statut == 0) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet WHERE rowid = $idligne"; - - if ($this->db->query($sql) ) + { + if ($this->statut == 0) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."commandedet WHERE rowid = $idligne"; + + if ($this->db->query($sql) ) { - $this->update_price(); - + $this->update_price(); return 1; } - else + else { return 0; } + } } - } + /** * Supprime la fiche * */ function delete() { - $this->db->begin(); + $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition = $this->id ;"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."expeditiondet WHERE fk_expedition = ".$this->id; if ( $this->db->query($sql) ) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition WHERE rowid = $this->id;"; - if ( $this->db->query($sql) ) - { - $this->db->commit(); - - // On efface le répertoire de pdf provisoire - $expref = sanitize_string($this->ref); - if ($conf->expedition->dir_output) - { - $dir = $conf->expedition->dir_output . "/" . $expref ; - $file = $conf->expedition->dir_output . "/" . $expref . "/" . $expref . ".pdf"; - if (file_exists($file)) - { - if (!dol_delete_file($file)) - { - $this->error=$langs->trans("ErrorCanNotDeleteFile",$file); - return 0; - } - } - if (file_exists($dir)) - { - if (!dol_delete_dir($dir)) - { - $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); - return 0; - } - } - } - - return 1; - } - else - { - $this->db->rollback(); - return -2; - } - } + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."expedition WHERE rowid = ".$this->id; + if ( $this->db->query($sql) ) + { + $this->db->commit(); + + // On efface le répertoire de pdf provisoire + $expref = sanitize_string($this->ref); + if ($conf->expedition->dir_output) + { + $dir = $conf->expedition->dir_output . "/" . $expref ; + $file = $conf->expedition->dir_output . "/" . $expref . "/" . $expref . ".pdf"; + if (file_exists($file)) + { + if (!dol_delete_file($file)) + { + $this->error=$langs->trans("ErrorCanNotDeleteFile",$file); + return 0; + } + } + if (file_exists($dir)) + { + if (!dol_delete_dir($dir)) + { + $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); + return 0; + } + } + } + return 1; + } + else + { + $this->db->rollback(); + return -2; + } + } else - { - $this->db->rollback(); - return -1; - } + { + $this->db->rollback(); + return -1; + } } - /** * Classe la commande * @@ -553,27 +567,29 @@ class Expedition extends CommonObject /* - * Lit la commande associée + * Lit le document associé * */ - function fetch_commande() + function fetch_object($object) { - $this->commande = & new Commande($this->db); - $this->commande->fetch($this->commande_id); + $class = ucfirst($object); + $this->$object = & new $class($this->db); + $this->$object->fetch($this->origin_id); } function fetch_lines() { - $sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.qty as qty_commande"; - $sql.= ", ed.qty as qty_expedie, ed.fk_commande_ligne"; + //Todo: récupérer les champs du document associé a part + + $sql = "SELECT cd.rowid, cd.fk_product, cd.description, cd.qty as qty_asked"; + $sql.= ", ed.qty as qty_shipped, ed.fk_origin_line, ed.fk_entrepot"; $sql.= ", p.ref, p.label, p.weight, p.weight_units, p.volume, p.volume_units"; $sql.= " FROM (".MAIN_DB_PREFIX."commandedet as cd"; $sql.= ", ".MAIN_DB_PREFIX."expeditiondet as ed)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON (p.rowid = cd.fk_product)"; $sql.= " WHERE ed.fk_expedition = ".$this->id; - $sql.= " AND ed.fk_commande_ligne = cd.rowid"; - + $sql.= " AND ed.fk_origin_line = cd.rowid"; $resql = $this->db->query($sql); if ($resql) @@ -585,13 +601,14 @@ class Expedition extends CommonObject $ligne = new ExpeditionLigne($this->db); $obj = $this->db->fetch_object($resql); - $ligne->order_line_id = $obj->fk_commande_ligne; + $ligne->origin_line_id = $obj->fk_origin_line; + $ligne->entrepot_id = $obj->fk_entrepot; $ligne->fk_product = $obj->fk_product; $ligne->ref = $obj->ref; $ligne->libelle = $obj->label; $ligne->description = $obj->description; - $ligne->qty_commande = $obj->qty_commande; - $ligne->qty_expedie = $obj->qty_expedie; + $ligne->qty_asked = $obj->qty_asked; + $ligne->qty_shipped = $obj->qty_shipped; $ligne->weight = $obj->weight; $ligne->weight_units = $obj->weight_units; $ligne->volume = $obj->volume; @@ -734,8 +751,8 @@ class ExpeditionLigne var $qty_expedition; var $fk_product; - // From llx_commandedet - var $qty_commande; + // From llx_commandedet or llx_propaldet + var $qty_asking; var $libelle; // Label produit var $product_desc; // Description produit var $ref; diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index d52a8f4376f..c4c3550c444 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2005 Rodolphe Quiedeville * Copyright (C) 2005-2006 Laurent Destailleur * Copyright (C) 2005 Simon TOSSER - * Copyright (C) 2005-2007 Régis Houssin + * Copyright (C) 2005-2008 Régis 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 @@ -34,6 +34,7 @@ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT ."/expedition/mods/pdf/ModelePdfExpedition.class.php"); if ($conf->produit->enabled) require_once(DOL_DOCUMENT_ROOT."/product.class.php"); if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); +if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php"); if ($conf->stock->enabled) require_once(DOL_DOCUMENT_ROOT."/product/stock/entrepot.class.php"); $langs->load("companies"); @@ -55,6 +56,8 @@ if ($user->societe_id > 0) $socid = $user->societe_id; } +$origin = $_GET["origin"]?$_GET["origin"]:$_POST["origin"]; +$origin_id = $_GET["origin_id"]?$_GET["origin_id"]:$_POST["origin_id"]; /* * Actions @@ -62,47 +65,51 @@ if ($user->societe_id > 0) if ($_POST["action"] == 'add') { - // \todo Mettre id entrepot sur ligne detail expedition et non sur fiche expedition + $db->begin(); - $db->begin(); + // Creation de l'objet expedition + $expedition = new Expedition($db); - // Creation de l'objet expedition - $expedition = new Expedition($db); + $expedition->date_expedition = time(); + $expedition->note = $_POST["note"]; + $expedition->origin = $origin; + $expedition->origin_id = $origin_id; - $expedition->date_expedition = time(); - $expedition->note = $_POST["note"]; - $expedition->commande_id = $_POST["commande_id"]; - $expedition->entrepot_id = $_POST["entrepot_id"]; - - // On boucle sur chaque ligne de commande pour compléter objet expedition - // avec qté à livrer - $commande = new Commande($db); - $commande->fetch($expedition->commande_id); - $commande->fetch_lines(); - for ($i = 0 ; $i < sizeof($commande->lignes) ; $i++) + // On boucle sur chaque ligne du document d'origine pour compléter objet expedition + // avec qté à livrer + $class = ucfirst($expedition->origin); + $object = new $class($db); + $object->fetch($expedition->origin_id); + //$object->fetch_lines(); + + $expedition->socid = $object->socid; + + for ($i = 0 ; $i < sizeof($object->lignes) ; $i++) + { + $ent = "entl".$i; + $idl = "idl".$i; + $qty = "qtyl".$i; + $entrepot_id = $_POST[$ent]?$_POST[$ent]:$_POST["entrepot_id"]; + if ($_POST[$qty] > 0) { - $qty = "qtyl".$i; - $idl = "idl".$i; - if ($_POST[$qty] > 0) - { - $expedition->addline($_POST[$idl],$_POST[$qty]); - } - } - - $ret=$expedition->create($user); - if ($ret > 0) - { - $db->commit(); - Header("Location: fiche.php?id=".$expedition->id); - exit; - } - else - { - $db->rollback(); - $mesg='
'.$expedition->error.'
'; - $_GET["commande_id"]=$_POST["commande_id"]; - $_GET["action"]='create'; + $expedition->addline($entrepot_id,$_POST[$idl],$_POST[$qty]); } + } + + $ret=$expedition->create($user); + if ($ret > 0) + { + $db->commit(); + Header("Location: fiche.php?id=".$expedition->id); + exit; + } + else + { + $db->rollback(); + $mesg='
'.$expedition->error.'
'; + $_GET["commande_id"]=$_POST["commande_id"]; + $_GET["action"]='create'; + } } /* @@ -186,26 +193,29 @@ if ($_GET["action"] == 'create') print $mesg.'
'; } - $commande = new Commande($db); - $commande->loadExpeditions(); + $class = ucfirst($origin); - if ( $commande->fetch($_GET["commande_id"])) + $object = new $class($db); + $object->loadExpeditions(); + + if ( $object->fetch($origin_id)) { $soc = new Societe($db); - $soc->fetch($commande->socid); + $soc->fetch($object->socid); $author = new User($db); - $author->id = $commande->user_author_id; + $author->id = $object->user_author_id; $author->fetch(); $entrepot = new Entrepot($db); /* - * Commande + * Document source */ print '
'; print ''; - print ''; + print ''; + print ''; if ($_GET["entrepot_id"]) { print ''; @@ -213,41 +223,34 @@ if ($_GET["action"] == 'create') print ''; - // Ref commande - print ''; - print "\n"; - - // Ref commande client + // Ref print ''; + print "\n"; + + // Ref client + print ''; print ''; - // Sociét + // Tiers print ''; print ''; print ''; // Date print ""; - print '\n"; + print '\n"; // Entrepot (si forcé) if ($conf->stock->enabled && $_GET["entrepot_id"]) @@ -259,9 +262,9 @@ if ($_GET["action"] == 'create') print ''; } - if ($commande->note && ! $user->societe_id) + if ($object->note && ! $user->societe_id) { - print '"; + print '"; } print "
'.$langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref.'
'; - print ''; - if ($_GET['action'] != 'RefCustomerOrder' && $commande->brouillon) print ''; - print '
'; - print $langs->trans('RefCustomerOrderShort').''; - print ''.img_edit($langs->trans('Modify')).'
'; - print '
'; - if ($user->rights->commande->creer && $_GET['action'] == 'RefCustomerOrder') + if ($conf->commande->enabled) { - print ''; - print ''; - print ''; - print ' '; - print ''; + print $langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"),'order').' '.$object->ref; } else { - print $commande->ref_client; + print $langs->trans("RefProposal").''.img_object($langs->trans("ShowProposal"),'propal').' '.$object->ref; } + print '
'; + print $langs->trans('RefCustomer').''; + print $object->ref_client; print '
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
".$langs->trans("Date")."'.dolibarr_print_date($commande->date,"dayhour")."
'.dolibarr_print_date($object->date,"day")."
'.$langs->trans("NotePrivate").': '.nl2br($commande->note)."
'.$langs->trans("NotePrivate").': '.nl2br($object->note)."
"; @@ -270,15 +273,15 @@ if ($_GET["action"] == 'create') * Lignes de commandes * */ - echo '
'; + print '
'; - $lignes = $commande->fetch_lines(1); - $numcommandes = sizeof($commande->lignes); + //$lignes = $object->fetch_lines(1); + $numAsked = sizeof($object->lignes); /* Lecture des expeditions déjà effectuées */ - $commande->loadExpeditions(); + $object->loadExpeditions(); - if ($numcommandes) + if ($numAsked) { print ''; print ''; @@ -300,10 +303,10 @@ if ($_GET["action"] == 'create') } $var=true; - $indicecommande = 0; - while ($indicecommande < $numcommandes) + $indiceAsked = 0; + while ($indiceAsked < $numAsked) { - $ligne = $commande->lignes[$indicecommande]; + $ligne = $object->lignes[$indiceAsked]; $var=!$var; print "\n"; if ($ligne->fk_product > 0) @@ -324,12 +327,12 @@ if ($_GET["action"] == 'create') print ''; print ''; - $quantite_commandee = $ligne->qty; - $quantite_a_livrer = $quantite_commandee - $quantite_livree; + $quantityAsked = $ligne->qty; + $quantityToBeDelivered = $quantityAsked - $quantityDelivered; if ($conf->stock->enabled) { @@ -338,20 +341,20 @@ if ($_GET["action"] == 'create') { $stock = $product->stock_entrepot[$_GET["entrepot_id"]]; $stock+=0; // Convertit en numérique - $defaultqty=min($quantite_a_livrer, $stock); + $defaultqty=min($quantityToBeDelivered, $stock); } // Quantité à livrer print ''; // Stock if ($_GET["entrepot_id"]) { print ''; } } @@ -395,14 +398,14 @@ if ($_GET["action"] == 'create') { // Quantité à livrer print ''; } print "\n"; - $indicecommande++; + $indiceAsked++; $var=!$var; } @@ -426,36 +429,35 @@ else /* */ /* *************************************************************************** */ { - if ($_GET["id"] > 0) + if ($_GET["id"] > 0) + { + $expedition = New Expedition($db); + $result = $expedition->fetch($_GET["id"]); + $lignes = $expedition->lignes; + $num_prod = sizeof($lignes); + + if ($expedition->id > 0) { - $expedition = New Expedition($db); - $result = $expedition->fetch($_GET["id"]); - $lignes = $expedition->lignes; - $num_prod = sizeof($lignes); + $object = New Commande($db); + $object->fetch($expedition->origin_id); - if ($expedition->id > 0) - { + $soc = new Societe($db); + $soc->fetch($expedition->socid); - $commande = New Commande($db); - $commande->fetch($expedition->commande_id); + $h=0; + $head[$h][0] = DOL_URL_ROOT."/expedition/fiche.php?id=".$expedition->id; + $head[$h][1] = $langs->trans("SendingCard"); + $hselected = $h; + $h++; - $soc = new Societe($db); - $soc->fetch($commande->socid); + if ($conf->livraison->enabled && $expedition->livraison_id) + { + $head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$expedition->livraison_id; + $head[$h][1] = $langs->trans("DeliveryCard"); + $h++; + } - $h=0; - $head[$h][0] = DOL_URL_ROOT."/expedition/fiche.php?id=".$expedition->id; - $head[$h][1] = $langs->trans("SendingCard"); - $hselected = $h; - $h++; - - if ($conf->livraison->enabled && $expedition->livraison_id) - { - $head[$h][0] = DOL_URL_ROOT."/livraison/fiche.php?id=".$expedition->livraison_id; - $head[$h][1] = $langs->trans("DeliveryCard"); - $h++; - } - - dolibarr_fiche_head($head, $hselected, $langs->trans("Sending")); + dolibarr_fiche_head($head, $hselected, $langs->trans("Sending")); /* * Confirmation de la suppression @@ -492,9 +494,9 @@ else $totalVolume = ''; for ($i = 0 ; $i < $num_prod ; $i++) { - $totalWeight += $lignes[$i]->weight*$lignes[$i]->qty_expedie; + $totalWeight += $lignes[$i]->weight*$lignes[$i]->qty_shipped; $weightUnit = $lignes[$i]->weight_units; - $totalVolume += $lignes[$i]->volume*$lignes[$i]->qty_expedie; + $totalVolume += $lignes[$i]->volume*$lignes[$i]->qty_shipped; $volumeUnit = $lignes[$i]->volume_units; } @@ -509,19 +511,29 @@ else print ''; print ""; - // Commande liée - print ''; - print '\n"; + // Document liée + print ''; + print ''; + print '\n"; print ''; - // Commande liée - print ''; - print '\n"; + // Ref client + print ''; + print '\n"; print ''; // Date print ''; - print '\n"; + print '\n"; print ''; // Poids Total @@ -570,7 +582,6 @@ else for ($i = 0 ; $i < $num_prod ; $i++) { - $var=!$var; print ""; if ($lignes[$i]->fk_product > 0) { @@ -585,22 +596,22 @@ else } // Qte commandé - print ''; + print ''; // Qte a expedier ou expedier - print ''; + print ''; // Poids - print ''; + print ''; // Volume - print ''; + print ''; // Entrepot source if ($conf->stock->enabled) { $entrepot = new Entrepot($db); - $entrepot->fetch($expedition->entrepot_id); + $entrepot->fetch($lignes[$i]->entrepot_id); print ''; } @@ -664,20 +675,20 @@ else $somethingshown=$html->show_documents('expedition',$expeditionref,$filedir,$urlsource,$genallowed,$delallowed,$expedition->modelpdf); if ($genallowed && ! $somethingshown) $somethingshown=1; - + /* * Autres expeditions */ - $sql = "SELECT cd.fk_product, cd.description, cd.rowid, cd.qty as qty_commande"; - $sql .= " , ed.qty as qty_livre, e.ref, ed.fk_expedition as expedition_id"; - $sql .= ",".$db->pdate("e.date_expedition")." as date_expedition"; - $sql .= " FROM ".MAIN_DB_PREFIX."commandedet as cd"; - $sql .= " , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e"; - $sql .= " WHERE cd.fk_commande = ".$expedition->commande_id; - $sql .= " AND e.rowid <> ".$expedition->id; - $sql .= " AND cd.rowid = ed.fk_commande_ligne"; - $sql .= " AND ed.fk_expedition = e.rowid"; - $sql .= " ORDER BY cd.fk_product"; + $sql = "SELECT obj.fk_product, obj.description, obj.rowid, obj.qty as qty_asking"; + $sql.= ", ed.qty as qty_shipped, ed.fk_expedition as expedition_id"; + $sql.= ", e.ref, ".$db->pdate("e.date_expedition")." as date_expedition"; + $sql.= " FROM ".MAIN_DB_PREFIX.$expedition->origin."det as obj"; + $sql.= " , ".MAIN_DB_PREFIX."expeditiondet as ed, ".MAIN_DB_PREFIX."expedition as e"; + $sql.= " WHERE obj.fk_".$expedition->origin." = ".$expedition->origin_id; + $sql.= " AND e.rowid <> ".$expedition->id; + $sql.= " AND obj.rowid = ed.fk_origin_line"; + $sql.= " AND ed.fk_expedition = e.rowid"; + $sql.= " ORDER BY obj.fk_product"; $resql = $db->query($sql); if ($resql) @@ -719,7 +730,7 @@ else { print "\n"; } - print ''; + print ''; print ''; print ''; $i++; diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index 3997bc884bb..b1a6875d1d8 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2006 Laurent Destailleur - * Copyright (C) 2005-2006 Regis Houssin + * Copyright (C) 2005-2008 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 @@ -50,19 +50,26 @@ print "
'.$langs->trans("Description").'
'.$ligne->qty.''; - $quantite_livree = $commande->expeditions[$ligne->fk_product]; - print $quantite_livree;; + $quantityDelivered = $object->expeditions[$ligne->fk_product]; + print $quantityDelivered; print ''; - print ''; - print ''; + print ''; + print ''; print ''.$stock; - if ($stock < $quantite_a_livrer) + if ($stock < $quantityToBeDelivered) { print ' '.img_warning($langs->trans("StockTooLow")); } @@ -387,7 +390,7 @@ if ($_GET["action"] == 'create') } print ''; - $html->select_array('warehouse'.$i,$array,'',1,0,0); + $html->select_array('entl'.$i,$array,'',1,0,0); print ''; - print ''; - print ''; + print ''; + print ''; print '
'.$soc->getNomUrl(1).'
'.$langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"),'order').' '.$commande->ref."
'; + if ($conf->commande->enabled) + { + print $langs->trans("RefOrder").''.img_object($langs->trans("ShowOrder"),'order').' '.$object->ref; + } + else + { + print $langs->trans("RefProposal").''.img_object($langs->trans("ShowProposal"),'propal').' '.$object->ref; + } + print "
'.$langs->trans("RefCustomerOrderShort").''.$commande->ref_client."
'.$langs->trans("RefCustomer").''.$object->ref_client."
'.$langs->trans("Date").''.dolibarr_print_date($expedition->date,"dayhour")."'.dolibarr_print_date($expedition->date,"day")."
'.$lignes[$i]->qty_commande.''.$lignes[$i]->qty_asked.''.$lignes[$i]->qty_expedie.''.$lignes[$i]->qty_shipped.''.$lignes[$i]->weight*$lignes[$i]->qty_expedie.' '.measuring_units_string($lignes[$i]->weight_units,"weight").''.$lignes[$i]->weight*$lignes[$i]->qty_shipped.' '.measuring_units_string($lignes[$i]->weight_units,"weight").''.$lignes[$i]->volume*$lignes[$i]->qty_expedie.' '.measuring_units_string($lignes[$i]->volume_units,"volume").''.$lignes[$i]->volume*$lignes[$i]->qty_shipped.' '.measuring_units_string($lignes[$i]->volume_units,"volume").''.$entrepot->getNomUrl(1).'".nl2br(dolibarr_trunc($objp->description,24))."'.$objp->qty_livre.''.$objp->qty_shipped.''.dolibarr_print_date($objp->date_expedition).'

\n"; /* * Expeditions à valider */ -$sql = "SELECT e.rowid, e.ref, s.nom, s.rowid as socid, c.ref as commande_ref, c.rowid as commande_id"; -if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; -$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; -if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE e.fk_commande = c.rowid AND c.fk_soc = s.rowid AND e.fk_statut = 0"; +$clause = " WHERE "; +$sql = "SELECT e.rowid, e.ref"; +$sql.= ", s.nom, s.rowid as socid"; +$sql.= ", c.ref as commande_ref, c.rowid as commande_id"; +$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."co_exp as ce ON e.rowid = ce.fk_expedition"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON ce.fk_commande = c.rowid"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; +if (!$user->rights->commercial->client->voir && !$socid) +{ + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; + $sql.= $clause." sc.fk_user = " .$user->id; + $clause = " AND "; +} +$sql.= $clause." e.fk_statut = 0"; if ($socid) { $sql .= " AND c.fk_soc = ".$socid; } -if (!$user->rights->commercial->client->voir && !$socid) //restriction -{ - $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -} + $resql=$db->query($sql); if ($resql) { @@ -173,39 +180,48 @@ if ( $resql ) /* * Expeditions à valider */ -$sql = "SELECT e.rowid, e.ref, s.nom, s.rowid as socid, c.ref as commande_ref, c.rowid as commande_id"; -if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; -$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e, ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."commande as c"; -if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql .= " WHERE e.fk_commande = c.rowid AND c.fk_soc = s.rowid AND e.fk_statut = 1"; +$clause = " WHERE "; +$sql = "SELECT e.rowid, e.ref"; +$sql.= ", s.nom, s.rowid as socid"; +$sql.= ", c.ref as commande_ref, c.rowid as commande_id"; +$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."co_exp as ce ON e.rowid = ce.fk_expedition"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON ce.fk_commande = c.rowid"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; +if (!$user->rights->commercial->client->voir && !$socid) +{ + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; + $sql.= $clause." sc.fk_user = " .$user->id; + $clause = " AND "; +} +$sql.= $clause." e.fk_statut = 1"; if ($socid) $sql .= " AND c.fk_soc = ".$socid; -if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; -$sql .= " ORDER BY e.date_expedition DESC"; -$sql .= $db->plimit(5, 0); +$sql.= " ORDER BY e.date_expedition DESC"; +$sql.= $db->plimit(5, 0); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num) + { + $i = 0; + print ''; + print ''; + print ''; + $var = True; + while ($i < $num) { - $i = 0; - print '
'.$langs->trans("LastSendings",$num).'
'; - print ''; - print ''; - $var = True; - while ($i < $num) - { - $var=!$var; - $obj = $db->fetch_object($resql); - print "'; - print ''; - print ''; - $i++; - } - print "
'.$langs->trans("LastSendings",$max).'
rowid\">".img_object($langs->trans("ShowSending"),"sending").' '; - print $obj->ref.''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.''.img_object($langs->trans("ShowOrder"),"order").' '.$obj->commande_ref.'

"; + $var=!$var; + $obj = $db->fetch_object($resql); + print "rowid\">".img_object($langs->trans("ShowSending"),"sending").' '; + print $obj->ref.''; + print ''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.''; + print ''.img_object($langs->trans("ShowOrder"),"order").' '.$obj->commande_ref.''; + $i++; } + print "
"; + } $db->free($resql); } diff --git a/htdocs/expedition/liste.php b/htdocs/expedition/liste.php index bf2d5522ed3..29c2f46e324 100644 --- a/htdocs/expedition/liste.php +++ b/htdocs/expedition/liste.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2006 Laurent Destailleur - * Copyright (C) 2005-2006 Regis Houssin + * Copyright (C) 2005-2008 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 @@ -31,6 +31,8 @@ require("./pre.inc.php"); if (!$user->rights->expedition->lire) accessforbidden(); +$langs->load('companies'); + // Sécurité accés client if ($user->societe_id > 0) { @@ -55,42 +57,51 @@ $offset = $limit * $_GET["page"] ; /******************************************************************************/ -llxHeader('',$langs->trans('ListOfSendings'),'ch-expedition.html'); +llxHeader('',$langs->trans('ListOfSendings')); -$sql = "SELECT e.rowid, e.ref,".$db->pdate("e.date_expedition")." as date_expedition, e.fk_statut, s.nom as socname, s.rowid as socid, c.ref as comref, c.rowid as comid"; -if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user"; -$sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; -if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."commande as c"; -if ($socid) $sql.=", ".MAIN_DB_PREFIX."commande as c"; -if ($user->rights->commercial->client->voir && !$socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as c ON c.rowid = e.fk_commande"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc"; - -$sql_add = " WHERE "; +$clause = " WHERE "; +$sql = "SELECT e.rowid, e.ref,".$db->pdate("e.date_expedition")." as date_expedition, e.fk_statut"; +$sql.= ", s.nom as socname, s.rowid as socid"; +$sql.= ", ori.ref as oriref, ori.rowid as oriid"; +$sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; +if ($conf->commande->enabled) +{ + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."co_exp as ce ON e.rowid = ce.fk_expedition"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."commande as ori ON ce.fk_commande = ori.rowid"; +} +else +{ + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."pr_exp as pe ON e.rowid = pe.fk_expedition"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."propal as ori ON pe.fk_commande = ori.rowid"; +} +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc"; +if (!$user->rights->commercial->client->voir && !$socid) +{ + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc"; + $sql.= $clause." sc.fk_user = " .$user->id; + $clause = " AND "; +} if ($socid) { - $sql.= $sql_add . " e.fk_commande = c.rowid AND c.fk_soc = ".$socid; - $sql_add = " AND "; + $sql.= $clause." e.fk_soc = ".$socid; + $clause = " AND "; } if ($_POST["sf_ref"]) { - $sql.= $sql_add . " e.ref like '%".addslashes($_POST["sf_ref"])."%'"; - $sql_add = " AND "; -} -if (!$user->rights->commercial->client->voir && !$socid) //restriction -{ - $sql .= $sql_add . " e.fk_commande = c.rowid AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql.= $clause." e.ref like '%".addslashes($_POST["sf_ref"])."%'"; + $clause = " AND "; } -$expedition = new Expedition($db); - -$sql .= " ORDER BY $sortfield $sortorder"; -$sql .= $db->plimit($limit + 1,$offset); +$sql.= " ORDER BY $sortfield $sortorder"; +$sql.= $db->plimit($limit + 1,$offset); $resql=$db->query($sql); if ($resql) { $num = $db->num_rows($resql); + $expedition = new Expedition($db); + print_barre_liste($langs->trans('ListOfSendings'), $_GET["page"], "liste.php","&socid=$socid",$sortfield,$sortorder,'',$num); $i = 0; @@ -99,50 +110,64 @@ if ($resql) print ''; print_liste_field_titre($langs->trans("Ref"),"liste.php","e.ref","","&socid=$socid",'width="15%"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Company"),"liste.php","s.nom", "", "&socid=$socid",'width="25%" align="left"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Order"),"liste.php","c.ref", "", "&socid=$socid",'width="25%" align="left"',$sortfield,$sortorder); + if ($conf->commande->enabled) + { + print_liste_field_titre($langs->trans("Order"),"liste.php","ori.ref", "", "&socid=$socid",'width="25%" align="left"',$sortfield,$sortorder); + } + else + { + print_liste_field_titre($langs->trans("Proposal"),"liste.php","ori.ref", "", "&socid=$socid",'width="25%" align="left"',$sortfield,$sortorder); + } print_liste_field_titre($langs->trans("Date"),"liste.php","e.date_expedition","","&socid=$socid", 'width="25%" align="right" colspan="2"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Status"),"liste.php","e.fk_statut","","&socid=$socid",'width="10%" align="center"',$sortfield,$sortorder); print "\n"; $var=True; while ($i < min($num,$limit)) + { + $objp = $db->fetch_object($resql); + + $var=!$var; + print ""; + print "rowid."\">".img_object($langs->trans("ShowSending"),"sending").' '; + print "rowid."\">".$objp->ref."\n"; + print ''.$objp->socname.''; + if ($conf->commande->enabled) { - $objp = $db->fetch_object($resql); - - $var=!$var; - print ""; - print "rowid."\">".img_object($langs->trans("ShowSending"),"sending").' '; - print "rowid."\">".$objp->ref."\n"; - print ''.$objp->socname.''; - print ''.$objp->comref.''; - - $now = time(); - $lim = 3600 * 24 * 15 ; - - if ( ($now - $objp->date_expedition) > $lim && $objp->statutid == 1 ) - { - print " > 15 jours"; - } - else - { - print " "; - } - - print ""; - $y = strftime("%Y",$objp->date_expedition); - $m = strftime("%m",$objp->date_expedition); - - print strftime("%d",$objp->date_expedition)."\n"; - print " "; - print strftime("%B",$objp->date_expedition)."\n"; - print " "; - print strftime("%Y",$objp->date_expedition)."\n"; - - print ''.$expedition->statuts[$objp->fk_statut].''; - print "\n"; - - $i++; + print ''.$objp->oriref.''; } + else + { + print ''.$objp->oriref.''; + } + + $now = time(); + $lim = 3600 * 24 * 15 ; + + if ( ($now - $objp->date_expedition) > $lim && $objp->statutid == 1 ) + { + print " > 15 jours"; + } + else + { + print " "; + } + + print ""; + $y = strftime("%Y",$objp->date_expedition); + $m = strftime("%m",$objp->date_expedition); + + print strftime("%d",$objp->date_expedition)."\n"; + print " "; + print strftime("%B",$objp->date_expedition)."\n"; + print " "; + print strftime("%Y",$objp->date_expedition)."\n"; + + print ''.$expedition->statuts[$objp->fk_statut].''; + print "\n"; + + $i++; + } print ""; $db->free($resql); diff --git a/htdocs/includes/modules/modExpedition.class.php b/htdocs/includes/modules/modExpedition.class.php index bb2fcdd064f..ad59c5f2dce 100644 --- a/htdocs/includes/modules/modExpedition.class.php +++ b/htdocs/includes/modules/modExpedition.class.php @@ -21,7 +21,7 @@ /** \defgroup expedition Module expedition - \brief Module pour g�rer les expeditions de produits + \brief Module pour gerer les expeditions de produits */ /** @@ -42,7 +42,7 @@ class modExpedition extends DolibarrModules /** * \brief Constructeur. Definit les noms, constantes et boites - * \param DB handler d'acc�s base + * \param DB handler d'acces base */ function modExpedition($DB) { @@ -51,7 +51,7 @@ class modExpedition extends DolibarrModules $this->family = "crm"; $this->name = "Expedition"; - $this->description = "Gestion des exp�ditions"; + $this->description = "Gestion des expeditions"; $this->revision = explode(' ','$Revision$'); $this->version = $this->revision[1]; $this->const_name = 'MAIN_MODULE_EXPEDITION'; @@ -64,8 +64,8 @@ class modExpedition extends DolibarrModules // Config pages $this->config_page_url = array("confexped.php"); - // D�pendances - $this->depends = array(); + // Dependances + $this->depends = array("modPropale"); $this->requiredby = array(); // Constantes @@ -73,13 +73,13 @@ class modExpedition extends DolibarrModules $this->const[0][0] = "LIVRAISON_ADDON_PDF"; $this->const[0][1] = "chaine"; $this->const[0][2] = "typhon"; - $this->const[0][3] = 'Nom du gestionnaire de g�n�ration des commandes en PDF'; + $this->const[0][3] = 'Nom du gestionnaire de generation des commandes en PDF'; $this->const[0][4] = 0; $this->const[1][0] = "LIVRAISON_ADDON"; $this->const[1][1] = "chaine"; $this->const[1][2] = "mod_livraison_jade"; - $this->const[1][3] = 'Nom du gestionnaire de num�rotation des bons de livraison'; + $this->const[1][3] = 'Nom du gestionnaire de numerotation des bons de livraison'; $this->const[1][4] = 0; // Boxes @@ -99,7 +99,7 @@ class modExpedition extends DolibarrModules $r++; $this->rights[$r][0] = 102; - $this->rights[$r][1] = 'Cr�er modifier les expeditions'; + $this->rights[$r][1] = 'Creer modifier les expeditions'; $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'creer'; @@ -128,7 +128,7 @@ class modExpedition extends DolibarrModules $r++; $this->rights[$r][0] = 1102; - $this->rights[$r][1] = 'Cr�er modifier les bons de livraison'; + $this->rights[$r][1] = 'Creer modifier les bons de livraison'; $this->rights[$r][2] = 'w'; $this->rights[$r][3] = 0; $this->rights[$r][4] = 'livraison'; @@ -154,8 +154,8 @@ class modExpedition extends DolibarrModules /** - * \brief Fonction appel�e lors de l'activation du module. Ins�re en base les constantes, boites, permissions du module. - * D�finit �galement les r�pertoires de donn�es � cr�er pour ce module. + * \brief Fonction appelee lors de l'activation du module. Insere en base les constantes, boites, permissions du module. + * Definit egalement les repertoires de donnees a creer pour ce module. */ function init() { @@ -171,7 +171,7 @@ class modExpedition extends DolibarrModules } /** - * \brief Fonction appel�e lors de la d�sactivation d'un module. + * \brief Fonction appelee lors de la desactivation d'un module. * Supprime de la base les constantes, boites et permissions du module. */ function remove() diff --git a/htdocs/includes/modules/modPropale.class.php b/htdocs/includes/modules/modPropale.class.php index e04e6be904b..04c2e8e8c0d 100644 --- a/htdocs/includes/modules/modPropale.class.php +++ b/htdocs/includes/modules/modPropale.class.php @@ -22,7 +22,7 @@ */ /** \defgroup propale Module propale - \brief Module pour g�rer la tenue de propositions commerciales + \brief Module pour gerer la tenue de propositions commerciales */ /** @@ -43,7 +43,7 @@ class modPropale extends DolibarrModules /** * \brief Constructeur. Definit les noms, constantes et boites - * \param DB handler d'acc�s base + * \param DB handler d'acces base */ function modPropale($DB) { @@ -64,7 +64,7 @@ class modPropale extends DolibarrModules // Dir $this->dirs = array(); - // D�pendances + // Dependances $this->depends = array("modSociete","modCommercial"); $this->config_page_url = array("propale.php"); @@ -74,13 +74,13 @@ class modPropale extends DolibarrModules $this->const[0][0] = "PROPALE_ADDON_PDF"; $this->const[0][1] = "chaine"; $this->const[0][2] = "azur"; - $this->const[0][3] = 'Nom du gestionnaire de g�n�ration des propales en PDF'; + $this->const[0][3] = 'Nom du gestionnaire de generation des propales en PDF'; $this->const[0][4] = 0; $this->const[1][0] = "PROPALE_ADDON"; $this->const[1][1] = "chaine"; $this->const[1][2] = "mod_propale_marbre"; - $this->const[1][3] = 'Nom du gestionnaire de num�rotation des propales'; + $this->const[1][3] = 'Nom du gestionnaire de numerotation des propales'; $this->const[1][4] = 0; // Boxes @@ -93,54 +93,54 @@ class modPropale extends DolibarrModules $this->rights[1][0] = 21; // id de la permission $this->rights[1][1] = 'Lire les propositions commerciales'; // libelle de la permission - $this->rights[1][2] = 'r'; // type de la permission (d�pr�ci� � ce jour) - $this->rights[1][3] = 1; // La permission est-elle une permission par d�faut + $this->rights[1][2] = 'r'; // type de la permission (deprecie a ce jour) + $this->rights[1][3] = 1; // La permission est-elle une permission par defaut $this->rights[1][4] = 'lire'; $this->rights[2][0] = 22; // id de la permission - $this->rights[2][1] = 'Cr�er/modifier les propositions commerciales'; // libelle de la permission - $this->rights[2][2] = 'w'; // type de la permission (d�pr�ci� � ce jour) - $this->rights[2][3] = 0; // La permission est-elle une permission par d�faut + $this->rights[2][1] = 'Creer/modifier les propositions commerciales'; // libelle de la permission + $this->rights[2][2] = 'w'; // type de la permission (deprecie a ce jour) + $this->rights[2][3] = 0; // La permission est-elle une permission par defaut $this->rights[2][4] = 'creer'; $this->rights[3][0] = 24; // id de la permission $this->rights[3][1] = 'Valider les propositions commerciales'; // libelle de la permission - $this->rights[3][2] = 'd'; // type de la permission (d�pr�ci� � ce jour) - $this->rights[3][3] = 0; // La permission est-elle une permission par d�faut + $this->rights[3][2] = 'd'; // type de la permission (deprecie a ce jour) + $this->rights[3][3] = 0; // La permission est-elle une permission par defaut $this->rights[3][4] = 'valider'; $this->rights[4][0] = 25; // id de la permission $this->rights[4][1] = 'Envoyer les propositions commerciales aux clients'; // libelle de la permission - $this->rights[4][2] = 'd'; // type de la permission (d�pr�ci� � ce jour) - $this->rights[4][3] = 0; // La permission est-elle une permission par d�faut + $this->rights[4][2] = 'd'; // type de la permission (deprecie a ce jour) + $this->rights[4][3] = 0; // La permission est-elle une permission par defaut $this->rights[4][4] = 'envoyer'; $this->rights[5][0] = 26; // id de la permission - $this->rights[5][1] = 'Cl�turer les propositions commerciales'; // libelle de la permission - $this->rights[5][2] = 'd'; // type de la permission (d�pr�ci� � ce jour) - $this->rights[5][3] = 0; // La permission est-elle une permission par d�faut + $this->rights[5][1] = 'Cloturer les propositions commerciales'; // libelle de la permission + $this->rights[5][2] = 'd'; // type de la permission (deprecie a ce jour) + $this->rights[5][3] = 0; // La permission est-elle une permission par defaut $this->rights[5][4] = 'cloturer'; $this->rights[6][0] = 27; // id de la permission $this->rights[6][1] = 'Supprimer les propositions commerciales'; // libelle de la permission - $this->rights[6][2] = 'd'; // type de la permission (d�pr�ci� � ce jour) - $this->rights[6][3] = 0; // La permission est-elle une permission par d�faut + $this->rights[6][2] = 'd'; // type de la permission (deprecie a ce jour) + $this->rights[6][3] = 0; // La permission est-elle une permission par defaut $this->rights[6][4] = 'supprimer'; } /** - * \brief Fonction appel�e lors de l'activation du module. Ins�re en base les constantes, boites, permissions du module. - * D�finit �galement les r�pertoires de donn�es � cr�er pour ce module. + * \brief Fonction appelee lors de l'activation du module. Insere en base les constantes, boites, permissions du module. + * Definit egalement les repertoires de donnees a creer pour ce module. */ function init() { global $conf; - // Permissions et valeurs par d�faut + // Permissions et valeurs par defaut $this->remove(); - // R�pertoires + // Repertoires $this->dirs[0] = $conf->propal->dir_output; $this->dirs[1] = $conf->propal->dir_temp; @@ -154,7 +154,7 @@ class modPropale extends DolibarrModules } /** - * \brief Fonction appel�e lors de la d�sactivation d'un module. + * \brief Fonction appelee lors de la desactivation d'un module. * Supprime de la base les constantes, boites et permissions du module. */ function remove() diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 50a6f70a0bb..99398555a82 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -1,6 +1,7 @@ * Copyright (C) 2005-2007 Laurent Destailleur + * Copyright (C) 2005-2008 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 @@ -133,27 +134,27 @@ if (isset($_POST['action']) && $_POST['action'] == 'upgrade') ***************************************************************************************/ if (! $error) { - + $db->begin(); - // Chaque action de migration doit renvoyer une ligne sur 4 colonnes avec - // dans la 1ere colonne, la description de l'action a faire - // dans la 4eme colonne, le texte 'OK' si fait ou 'AlreadyDone' si rien n'est fait ou 'Error' + // Chaque action de migration doit renvoyer une ligne sur 4 colonnes avec + // dans la 1ere colonne, la description de l'action a faire + // dans la 4eme colonne, le texte 'OK' si fait ou 'AlreadyDone' si rien n'est fait ou 'Error' // Script pour V2 -> V2.1 - migrate_paiements($db,$langs,$conf); + migrate_paiements($db,$langs,$conf); - migrate_contracts_det($db,$langs,$conf); + migrate_contracts_det($db,$langs,$conf); - migrate_contracts_date1($db,$langs,$conf); + migrate_contracts_date1($db,$langs,$conf); - migrate_contracts_date2($db,$langs,$conf); + migrate_contracts_date2($db,$langs,$conf); - migrate_contracts_date3($db,$langs,$conf); + migrate_contracts_date3($db,$langs,$conf); - migrate_contracts_open($db,$langs,$conf); + migrate_contracts_open($db,$langs,$conf); - migrate_modeles($db,$langs,$conf); + migrate_modeles($db,$langs,$conf); migrate_price_propal($db,$langs,$conf); @@ -163,7 +164,7 @@ if (isset($_POST['action']) && $_POST['action'] == 'upgrade') migrate_price_contrat($db,$langs,$conf); - migrate_paiementfourn_facturefourn($db,$langs,$conf); + migrate_paiementfourn_facturefourn($db,$langs,$conf); // Script pour V2.1 -> V2.2 migrate_paiements_orphelins_1($db,$langs,$conf); @@ -173,11 +174,14 @@ if (isset($_POST['action']) && $_POST['action'] == 'upgrade') migrate_links_transfert($db,$langs,$conf); migrate_delete_old_files($db,$langs,$conf); + + // Script pour V2.2 -> V2.4 + migrate_commande_expedition($db,$langs,$conf); - // On commit dans tous les cas. - // La procedure etant concue pour pouvoir passer plusieurs fois quelquesoit la situation. - $db->commit(); - $db->close(); + // On commit dans tous les cas. + // La procedure etant concue pour pouvoir passer plusieurs fois quelquesoit la situation. + $db->commit(); + $db->close(); } @@ -1454,6 +1458,75 @@ function migrate_module_menus($db,$langs,$conf) } } +/* + * Correspondance des expeditions et des commandes clients dans la table llx_co_exp + */ +function migrate_commande_expedition($db,$langs,$conf) +{ + if ($conf->expedition->enabled) + { + print ''; + + print '
'; + print ''.$langs->trans('MigrationShipmentOrderMatching')."
\n"; + + $result = $db->DDLDescTable(MAIN_DB_PREFIX."expedition","fk_commande"); + $obj = $db->fetch_object($result); + if ($obj) + { + $sql = "SELECT e.rowid, e.fk_commande FROM ".MAIN_DB_PREFIX."expedition as e"; + $resql = $db->query($sql); + if ($resql) + { + $i = 0; + $error = 0; + $num = $db->num_rows($resql); + + if ($num) + { + $db->begin(); + + while ($i < $num) + { + $obj = $db->fetch_object($resql); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."co_exp (fk_expedition,fk_commande)"; + $sql.= " VALUES (".$obj->rowid.",".$obj->fk_commande.")"; + $resql2=$db->query($sql); + + if (!$resql2) + { + $error++; + dolibarr_print_error($db); + } + print ". "; + $i++; + } + if ($error == 0) + { + $db->commit(); + $sql = "ALTER TABLE ".MAIN_DB_PREFIX."expedition DROP COLUMN fk_commande"; + $db->query($sql); + } + else + { + $db->rollback(); + } + } + } + else + { + dolibarr_print_error($db); + } + } + else + { + print $langs->trans('AlreadyDone')."
\n"; + } + print ''; + } +} + /* A faire egalement: Modif statut paye et fk_facture des factures payés completement On recherche facture incorrecte: diff --git a/htdocs/lib/propal.lib.php b/htdocs/lib/propal.lib.php index 86e343a6204..be586febf71 100644 --- a/htdocs/lib/propal.lib.php +++ b/htdocs/lib/propal.lib.php @@ -43,11 +43,11 @@ function propal_prepare_head($propal) $head[$h][2] = 'comm'; $h++; - if (!$conf->commande->enabled && (($conf->expedition->enabled && $user->rights->expedition->lire) - || ($conf->livraison->enabled && $user->rights->expedition->livraison->lire))) + if ((!$conf->commande->enabled && (($conf->expedition->enabled && $user->rights->expedition->lire) + || ($conf->livraison->enabled && $user->rights->expedition->livraison->lire)))) { $langs->load("sendings"); - $head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?id='.$propal->id; + $head[$h][0] = DOL_URL_ROOT.'/expedition/propal.php?propalid='.$propal->id; if ($conf->expedition->enabled) $text=$langs->trans("Sendings"); if ($conf->livraison->enabled) $text.='/'.$langs->trans("Receivings"); $head[$h][1] = $text; diff --git a/htdocs/product/stock/entrepot.class.php b/htdocs/product/stock/entrepot.class.php index 2adfd9f715e..77d50dfbb00 100644 --- a/htdocs/product/stock/entrepot.class.php +++ b/htdocs/product/stock/entrepot.class.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2005-2008 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 @@ -264,25 +265,27 @@ class Entrepot */ function list_array() { - $liste = array(); + $liste = array(); - $sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."entrepot WHERE statut = 1"; + $sql = "SELECT rowid, label"; + $sql.= " FROM ".MAIN_DB_PREFIX."entrepot"; + $sql.= " WHERE statut = 1"; - $result = $this->db->query($sql) ; - $i = 0; - $num = $this->db->num_rows(); - - if ( $result ) - { - while ($i < $num) + $result = $this->db->query($sql) ; + $i = 0; + $num = $this->db->num_rows(); + + if ( $result ) + { + while ($i < $num) { $row = $this->db->fetch_row($i); $liste[$row[0]] = $row[1]; $i++; } - $this->db->free(); - } - return $liste; + $this->db->free(); + } + return $liste; } /** @@ -295,31 +298,30 @@ class Entrepot $sql = "SELECT sum(ps.reel)"; $sql .= " FROM llx_product_stock as ps"; if ($conf->categorie->enabled && !$user->rights->categorie->voir) - { - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid"; - } + { + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid"; + } $sql .= " WHERE ps.fk_entrepot = ".$this->id; if ($conf->categorie->enabled && !$user->rights->categorie->voir) - { - $sql.= ' AND IFNULL(c.visible,1)=1'; - } - + { + $sql.= ' AND IFNULL(c.visible,1)=1'; + } + $result = $this->db->query($sql) ; if ( $result ) - { - $row = $this->db->fetch_row(0); - return $row[0]; - - $this->db->free(); - } + { + $row = $this->db->fetch_row(0); + return $row[0]; + + $this->db->free(); + } else - { - return 0; - } + { + return 0; + } } - /** * \brief Retourne le libellé du statut d'un entrepot (ouvert, ferme) diff --git a/mysql/migration/2.2.0-2.4.0.sql b/mysql/migration/2.2.0-2.4.0.sql index 45b18c80d29..5db5ca9183f 100644 --- a/mysql/migration/2.2.0-2.4.0.sql +++ b/mysql/migration/2.2.0-2.4.0.sql @@ -41,3 +41,48 @@ alter table llx_menu add column tms timestamp; update llx_menu set url='/comm/prospect/prospects.php?leftmenu=prospects' where rowid=702 and url='/contact/index.php?leftmenu=prospects&type=p'; ALTER TABLE llx_menu ADD UNIQUE INDEX idx_menu_uk_menu (menu_handler, fk_menu, url); +-- Drop unused table +drop table if exists llx_so_gr; + +-- Modification expedition +create table llx_co_exp +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_commande integer NOT NULL, + fk_expedition integer NOT NULL, + + key(fk_commande), + key(fk_expedition) +)type=innodb; + +-- V4 ALTER TABLE llx_expedition DROP INDEX fk_expedition_methode; +-- V4 ALTER TABLE llx_expedition DROP INDEX fk_commande; +-- V4 ALTER TABLE llx_expedition DROP INDEX ref; +-- V4 ALTER TABLE llx_expeditiondet DROP INDEX fk_expedition; +-- V4 ALTER TABLE llx_expeditiondet DROP INDEX fk_commande_ligne; + +alter table llx_expedition add column fk_soc integer NOT NULL after ref; +alter table llx_expedition add column fk_adresse_livraison integer after date_expedition; +-- V4.1 UPDATE llx_expedition as e SET e.fk_soc = (SELECT c.fk_soc FROM llx_commande AS c WHERE e.fk_commande = c.rowid); +-- V4.1 UPDATE llx_expedition as e SET e.fk_adresse_livraison = (SELECT c.fk_adresse_livraison FROM llx_commande AS c WHERE e.fk_commande = c.rowid); + +ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_soc (fk_soc); +ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_user_author (fk_user_author); +ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_user_valid (fk_user_valid); +ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_expedition_methode (fk_expedition_methode); +-- V4 ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid); +-- V4 ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); +-- V4 ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid); +-- V4 ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_expedition_methode FOREIGN KEY (fk_expedition_methode) REFERENCES llx_expedition_methode (rowid); +ALTER TABLE llx_expedition ADD UNIQUE INDEX idx_expedition_uk_ref (ref); + +ALTER TABLE llx_expeditiondet CHANGE fk_commande_ligne fk_origin_line integer; +ALTER TABLE llx_expeditiondet ADD COLUMN fk_entrepot integer after fk_origin_line; +ALTER TABLE llx_expeditiondet ADD COLUMN rang integer DEFAULT 0 after qty; +-- V4.1 UPDATE llx_expeditiondet as ed SET ed.fk_entrepot = (SELECT e.fk_entrepot FROM llx_expedition AS e WHERE ed.fk_expedition = e.rowid); +ALTER TABLE llx_expedition DROP COLUMN fk_entrepot; + +ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_expedition (fk_expedition); +ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_entrepot (fk_entrepot); +-- V4 ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_expedition FOREIGN KEY (fk_expedition) REFERENCES llx_expedition (rowid); +-- V4 ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_entrepot FOREIGN KEY (fk_entrepot) REFERENCES llx_entrepot (rowid); diff --git a/mysql/tables/llx_co_exp.sql b/mysql/tables/llx_co_exp.sql new file mode 100644 index 00000000000..2409f14889e --- /dev/null +++ b/mysql/tables/llx_co_exp.sql @@ -0,0 +1,30 @@ +-- =================================================================== +-- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2008 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 +-- 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. +-- +-- $Id$ +-- =================================================================== + +create table llx_co_exp +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_commande integer NOT NULL, + fk_expedition integer NOT NULL, + + key(fk_commande), + key(fk_expedition) +)type=innodb; diff --git a/mysql/tables/llx_expedition.key.sql b/mysql/tables/llx_expedition.key.sql new file mode 100644 index 00000000000..cee509be72e --- /dev/null +++ b/mysql/tables/llx_expedition.key.sql @@ -0,0 +1,33 @@ +-- =================================================================== +-- Copyright (C) 2005 Laurent Destailleur +-- Copyright (C) 2008 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 +-- 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. +-- +-- $Id$ +-- =================================================================== + + +ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_soc (fk_soc); +ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_user_author (fk_user_author); +ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_user_valid (fk_user_valid); +ALTER TABLE llx_expedition ADD INDEX idx_expedition_fk_expedition_methode (fk_expedition_methode); + +ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid); +ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_user_author FOREIGN KEY (fk_user_author) REFERENCES llx_user (rowid); +ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_user_valid FOREIGN KEY (fk_user_valid) REFERENCES llx_user (rowid); +ALTER TABLE llx_expedition ADD CONSTRAINT fk_expedition_fk_expedition_methode FOREIGN KEY (fk_expedition_methode) REFERENCES llx_expedition_methode (rowid); + +ALTER TABLE llx_expedition ADD UNIQUE INDEX idx_expedition_uk_ref (ref); \ No newline at end of file diff --git a/mysql/tables/llx_expedition.sql b/mysql/tables/llx_expedition.sql index 818cd69c556..fd92a82cc0d 100644 --- a/mysql/tables/llx_expedition.sql +++ b/mysql/tables/llx_expedition.sql @@ -1,5 +1,6 @@ -- =================================================================== -- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2008 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 @@ -23,19 +24,15 @@ create table llx_expedition rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, ref varchar(30) NOT NULL, - fk_commande integer, - date_creation datetime, -- date de creation - date_valid datetime, -- date de validation - date_expedition date, -- date de l'expedition + fk_soc integer NOT NULL, + date_creation datetime, -- date de creation fk_user_author integer, -- createur + date_valid datetime, -- date de validation fk_user_valid integer, -- valideur - fk_entrepot integer, + date_expedition date, -- date de l'expedition + fk_adresse_livraison integer, -- adresse de livraison fk_expedition_methode integer, fk_statut smallint DEFAULT 0, note text, - model_pdf varchar(50), - - UNIQUE INDEX (ref), - key(fk_expedition_methode), - key(fk_commande) + model_pdf varchar(50) )type=innodb; diff --git a/mysql/tables/llx_expeditiondet.key.sql b/mysql/tables/llx_expeditiondet.key.sql new file mode 100644 index 00000000000..a2e54d34770 --- /dev/null +++ b/mysql/tables/llx_expeditiondet.key.sql @@ -0,0 +1,24 @@ +-- =================================================================== +-- Copyright (C) 2005 Laurent Destailleur +-- Copyright (C) 2008 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 +-- 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. +-- +-- $Id$ +-- =================================================================== + + +ALTER TABLE llx_expeditiondet ADD INDEX idx_expeditiondet_fk_expedition (fk_expedition); +ALTER TABLE llx_expeditiondet ADD CONSTRAINT fk_expeditiondet_fk_expedition FOREIGN KEY (fk_expedition) REFERENCES llx_expedition (rowid); diff --git a/mysql/tables/llx_expeditiondet.sql b/mysql/tables/llx_expeditiondet.sql index 8d662dbee1f..6bd6e54a437 100644 --- a/mysql/tables/llx_expeditiondet.sql +++ b/mysql/tables/llx_expeditiondet.sql @@ -1,5 +1,6 @@ -- =================================================================== -- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2008 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 @@ -22,9 +23,8 @@ create table llx_expeditiondet ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_expedition integer NOT NULL, - fk_commande_ligne integer NOT NULL, - qty real, -- quantité - - key(fk_expedition), - key(fk_commande_ligne) + fk_origin_line integer, -- Correspondance de la ligne avec le document d'origine (propal, commande) + fk_entrepot integer, -- Entrepot de depart du produit + qty real, -- Quantity + rang integer DEFAULT 0 )type=innodb; diff --git a/mysql/tables/llx_livraison.sql b/mysql/tables/llx_livraison.sql index ffbc22c5cae..60a04cf43e2 100644 --- a/mysql/tables/llx_livraison.sql +++ b/mysql/tables/llx_livraison.sql @@ -1,5 +1,6 @@ -- =================================================================== -- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2008 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 @@ -25,18 +26,18 @@ create table llx_livraison fk_commande integer DEFAULT 0, -- commande auquel est rattache le bon de livraison fk_expedition integer, -- expedition auquel est rattache le bon de livraison ref varchar(30) NOT NULL, -- delivery number - date_creation datetime, -- date de creation - date_valid datetime, -- date de validation + date_creation datetime, -- date de creation fk_user_author integer, -- createur du bon de livraison + date_valid datetime, -- date de validation fk_user_valid integer, -- valideur du bon de livraison + date_livraison date default NULL, -- date de livraison + fk_adresse_livraison integer, -- adresse de livraison fk_statut smallint default 0, total_ht real default 0, total_ttc real default 0, note text, note_public text, model_pdf varchar(50), - date_livraison date default NULL, - fk_adresse_livraison integer, -- adresse de livraison UNIQUE INDEX (ref), key(fk_commande) diff --git a/mysql/tables/llx_livraisondet.sql b/mysql/tables/llx_livraisondet.sql index 17be39b8c3f..1e537d1e4c3 100644 --- a/mysql/tables/llx_livraisondet.sql +++ b/mysql/tables/llx_livraisondet.sql @@ -1,5 +1,6 @@ -- =================================================================== -- Copyright (C) 2003 Rodolphe Quiedeville +-- Copyright (C) 2008 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