* Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2010 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. */ /** * \file htdocs/comm/addpropal.php * \ingroup propal * \brief Page to add a new commercial proposal * \version $Id$ */ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'); require_once(DOL_DOCUMENT_ROOT.'/includes/modules/propale/modules_propale.php'); if ($conf->projet->enabled) { require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); require_once(DOL_DOCUMENT_ROOT.'/lib/project.lib.php'); } $langs->load("propal"); if ($conf->projet->enabled) $langs->load("projects"); $langs->load("companies"); $langs->load("bills"); $langs->load("orders"); $langs->load("deliveries"); /* * View */ llxHeader(); print_fiche_titre($langs->trans("NewProp")); $html=new Form($db); /* * Creation d'une nouvelle propale */ if ($_GET["action"] == 'create') { $soc = new Societe($db); $result=$soc->fetch($_GET["socid"]); if ($result < 0) { dol_print_error($db,$soc->error); exit; } $propal = new Propal($db); $numpr=''; $obj = $conf->global->PROPALE_ADDON; if ($obj) { if (! empty($conf->global->PROPALE_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/includes/modules/propale/".$conf->global->PROPALE_ADDON.".php")) { require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/".$conf->global->PROPALE_ADDON.".php"); $modPropale = new $obj; $numpr = $modPropale->getNextValue($soc,$propal); } } // Fix pour modele numerotation qui deconne // Si numero deja pris (ne devrait pas arriver), on incremente par .num+1 $sql = "SELECT count(*) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."propal"; $sql.= " WHERE ref LIKE '".$numpr."%'"; $sql.= " AND entity = ".$conf->entity; $resql=$db->query($sql); if ($resql) { $obj=$db->fetch_object($resql); $num = $obj->nb; $db->free($resql); if ($num > 0) { $numpr .= "." . ($num + 1); } } print '
'; print ''; print ''; if (isset($_GET["origin"]) && $_GET["origin"] != 'project' && isset($_GET["originid"])) { print ''; print ''; } print ''; // Ref print ''; // Reference client print ''; print ''; // Societe print ''; print ''; /* * Contact de la propale */ print "'; // Ligne info remises tiers print ''; // Date print ''; print ''; // Terms of payment print ''; // Mode of payment print ''; // Delivery date (or manufacturing) print ''; print ''; // Delivery address if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS) { print ''; print ''; } // Model print ''; print ''; print '"; // Project if ($conf->projet->enabled) { $projectid = 0; if (isset($_GET["origin"]) && $_GET["origin"] == 'project') $projectid = ($_GET["originid"]?$_GET["originid"]:0); 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->getAvailableDiscounts(); print '. '; if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($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("DeliveryDate").''; 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 { $datepropal=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; $html->select_date($datepropal,'liv_','','','',"addprop"); } print '
'.$langs->trans('DeliveryAddress').''; $numaddress = $html->select_address($soc->fk_delivery_address, $_GET['socid'],'fk_address',1); if ($numaddress==0) { print '   id.'&action=create>'.$langs->trans("AddAddress").''; } print '
'.$langs->trans("DefaultModel").''; $model=new ModelePDFPropales(); $liste=$model->liste_modeles($db); print $html->selectarray('model',$liste,$conf->global->PROPALE_ADDON_PDF); print "
'.$langs->trans("Project").''; $numprojet=select_projects($soc->id,$projectid); if ($numprojet==0) { print '   '.$langs->trans("AddProject").''; } print '
"; print '
'; /* * Combobox pour la fonction de copie */ print ''; if (empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) { print ''; } else { // For backward compatibility 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, p.ref, s.nom"; $sql.=" FROM ".MAIN_DB_PREFIX."propal p"; $sql.= ", ".MAIN_DB_PREFIX."societe s"; $sql.= " WHERE s.rowid = p.fk_soc"; $sql.= " AND p.entity = ".$conf->entity; $sql.= " AND p.fk_statut <> 0"; $sql.= " ORDER BY Id"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; while ($i < $num) { $row = $db->fetch_row($resql); $propalRefAndSocName = $row[1]." - ".$row[2]; $liste_propal[$row[0]]=$propalRefAndSocName; $i++; } print $html->selectarray("copie_propal",$liste_propal, 0); } else { dol_print_error($db); } print '
 
'.$langs->trans("CreateEmptyPropal").'
'; if ($conf->product->enabled || $conf->service->enabled) { $lib=$langs->trans("ProductsAndServices"); print ''; print ''; print ''; print ''; print ''; print ''; for ($i = 1 ; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i++) { print ''; print ''; print ''; print ''; } print "
'.$lib.''.$langs->trans("Qty").''.$langs->trans("ReductionShort").'
'; // multiprix if($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) $html->select_produits('',"idprod".$i,'',$conf->product->limit_size,$soc->price_level); else $html->select_produits('',"idprod".$i,'',$conf->product->limit_size); print '%
"; } else { print ' '; } print '
'; print '
'; $langs->load("bills"); print '
'; print ''; print '
'; print "
"; } $db->close(); llxFooter('$Date$ - $Revision$'); ?>