* Copyright (C) 2004-2006 Laurent Destailleur * Copyright (C) 2005-2006 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * * 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$ * $Source$ */ /** \file htdocs/comm/addpropal.php \ingroup propal \brief Page d'ajout d'une proposition commmercial \version $Revision$ */ require("./pre.inc.php"); include_once(DOL_DOCUMENT_ROOT.'/includes/modules/propale/modules_propale.php'); if (defined("PROPALE_ADDON") && is_readable(DOL_DOCUMENT_ROOT ."/includes/modules/propale/".PROPALE_ADDON.".php")) { require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/".PROPALE_ADDON.".php"); } $langs->load("propal"); if ($conf->projet->enabled) $langs->load("projects"); $langs->load("companies"); $langs->load("bills"); $langs->load("orders"); $user->getrights('propale'); $user->getrights('fichinter'); $user->getrights('commande'); $user->getrights('projet'); llxHeader(); print_titre($langs->trans("NewProp")); $html=new Form($db); // Récupération de l'id de projet $projetid = 0; if ($_GET["projetid"]) { $projetid = $_GET["projetid"]; } /* * * Creation d'une nouvelle propale * */ if ($_GET["action"] == 'create') { $soc = new Societe($db); $result=$soc->fetch($_GET["socid"]); if ($result < 0) { dolibarr_print_error($db,$soc->error); exit; } $obj = $conf->global->PROPALE_ADDON; $modPropale = new $obj; $numpr = $modPropale->getNextValue($soc); // Fix pour modele numerotation qui deconne // Si numero deja pris (ne devrait pas arriver), on incremente par .num+1 $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."propal WHERE ref like '$numpr%'"; $resql=$db->query($sql); if ($resql) { $obj=$db->fetch_object($resql); $num = $obj->nb; $db->free($resql); if ($num > 0) { $numpr .= "." . ($num + 1); } } print "
id."\" method=\"post\">"; print ""; print ''; // Ref print ''; // Reference client print ''; print ''; // Societe print ''; print ''; /* * Contact de la propale */ print "'; // Ligne info remises tiers print ''; // Date facture print ''; print ''; // Conditions de réglement print ''; // Mode de réglement print ''; // Réductions relatives (Remises-Ristournes-Rabbais) /* Une réduction doit s'appliquer obligatoirement sur des lignes de factures et non globalement car une tva est obligatoire meme sur une reduc $relative_discount=$soc->remise_client; print ''; print ''; */ // Réductions absolues (Remises-Ristournes-Rabbais) /* Les remises absolues doivent s'appliquer par ajout de lignes spécialisées $absolute_discount=$soc->getCurrentDiscount(); print ''; print ''; */ // Date de livraison // A quoi sert une date de livraison sur une propale ? // Si il y a date de livraison connue alors ne s'agit-il pas d'une commande plutot ? // Régis : c'est plus pour information afin que le client est un délai de fabrication par exemple. if ($conf->expedition->enabled) { if ($conf->global->PROPALE_ADD_SHIPPING_DATE) { print ''; print ''; } // Adresse de livraison if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS) { print ''; print ''; } } // Model print ''; print ''; print '"; // Projet if ($conf->projet->enabled) { print ''; print ''; print ''; } print "
'.$langs->trans("Ref").'
'.$langs->trans('RefCustomer').''; print '
'.$langs->trans('Company').''.$soc->getNomUrl(1); print ''; print '
".$langs->trans("DefaultContact")."\n"; $html->select_contacts($soc->id,$setcontact,'contactidp',1); print '
'.$langs->trans('Discounts').''; if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); else print $langs->trans("CompanyHasNoRelativeDiscount"); $absolute_discount=$soc->getCurrentDiscount(); print '. '; if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie)); else print $langs->trans("CompanyHasNoAbsoluteDiscount"); print '.'; print '
'.$langs->trans('Date').''; $html->select_date('','','','','',"addprop"); print '
'.$langs->trans("ValidityDuration").' '.$langs->trans("days").'
'.$langs->trans('PaymentConditionsShort').''; $html->select_conditions_paiements($soc->cond_reglement,'cond_reglement_id'); print '
'.$langs->trans('PaymentMode').''; $html->select_types_paiements($soc->mode_reglement,'mode_reglement_id'); print '
'.$langs->trans("CustomerRelativeDiscount").''; print ' %'; print ''.img_info().' '; if ($relative_discount) { print $langs->trans("CompanyHasRelativeDiscount",$relative_discount); } else { print $langs->trans("CompanyHasNoRelativeDiscount"); } print '
'.$langs->trans("CustomerAbsoluteDiscount").''; print ' '.$langs->trans("Currency".$conf->monnaie); print ''.img_info().' '; if ($absolute_discount) { print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie)); } else { print $langs->trans("CompanyHasNoAbsoluteDiscount"); } print '
'.$langs->trans("DateDelivery").''; if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") { $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); $syear = date("Y", $tmpdte); $smonth = date("m", $tmpdte); $sday = date("d", $tmpdte); $html->select_date($syear."-".$smonth."-".$sday,'liv_','','','',"addprop"); } else { $html->select_date(-1,'liv_','','','',"addprop"); } print '
'.$langs->trans('DeliveryAddress').''; $numaddress = $html->select_adresse_livraison($soc->adresse_livraison_id, $_GET['socid'],'adresse_livraison_id',1); if ($numaddress==0) { print '   id.'&action=create>'.$langs->trans("AddAddress").''; } print '
'.$langs->trans("DefaultModel").''; $model=new ModelePDFPropales(); $liste=$model->liste_modeles($db); $html->select_array('model',$liste,$conf->global->PROPALE_ADDON_PDF); print "
'.$langs->trans("Project").''; $numprojet=$html->select_projects($soc->id,$projetid,'projetidp'); if ($numprojet==0) { print '   '.$langs->trans("AddProject").''; } print '
"; print '
'; /* * Combobox pour la fonction de copie */ print ''; print ''; print ''; print ''; print ''; if ($conf->global->PRODUCT_SHOW_WHEN_CREATE) print ''; print ''; print ''; if ($conf->global->PRODUCT_SHOW_WHEN_CREATE) { print ''; } print '
'.$langs->trans("CopyPropalFrom").' '; $liste_propal = array(); $liste_propal[0] = ''; $sql ="SELECT p.rowid as id, CONCAT(p.ref, ' - ', s.nom) as lib"; $sql.=" FROM ".MAIN_DB_PREFIX."propal p, ".MAIN_DB_PREFIX."societe s"; $sql.=" WHERE s.idp = p.fk_soc AND fk_statut <> 0 ORDER BY Id"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; while ($i < $num) { $row = $db->fetch_row($resql); $liste_propal[$row[0]]=$row[1]; $i++; } $html->select_array("copie_propal",$liste_propal, 0); } else { dolibarr_print_error($db); } print '
 
'.$langs->trans("CreateEmptyPropal").'
'; if ($conf->produit->enabled || $conf->service->enabled) { $lib=$langs->trans("ProductsAndServices"); print ''; print ''; print ''; print ''; print ''; print ''; for ($i = 1 ; $i <= $conf->global->PROPALE_NEW_FORM_NB_PRODUCT ; $i++) { print ''; print ''; print ''; print ''; } print "
'.$lib.''.$langs->trans("Qty").''.$langs->trans("ReductionShort").'
'; // multiprix if($conf->global->PRODUIT_MULTIPRICES == 1) $html->select_produits('',"idprod".$i,'',$conf->produit->limit_size,$soc->price_level); else $html->select_produits('',"idprod".$i,'',$conf->produit->limit_size); print '%
"; } else { print ' '; } print '
'; print '
'; $langs->load("bills"); print '
'; print ''; print '
'; print "
"; } $db->close(); llxFooter('$Date$ - $Revision$'); ?>