New: Add option MAIN_AUTOFILL_DATE

This commit is contained in:
Laurent Destailleur 2008-07-17 22:11:45 +00:00
parent 11920dd1fd
commit 6395d1e4fb
6 changed files with 173 additions and 169 deletions

View File

@ -20,18 +20,18 @@
*/ */
/** /**
\file htdocs/comm/addpropal.php \file htdocs/comm/addpropal.php
\ingroup propal \ingroup propal
\brief Page d'ajout d'une proposition commmercial \brief Page d'ajout d'une proposition commmercial
\version $Id$ \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT.'/propal.class.php'); require_once(DOL_DOCUMENT_ROOT.'/propal.class.php');
require_once(DOL_DOCUMENT_ROOT.'/includes/modules/propale/modules_propale.php'); require_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")) 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"); require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/".PROPALE_ADDON.".php");
} }
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/lib/project.lib.php'); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/lib/project.lib.php');
@ -67,45 +67,45 @@ if ($_GET["projetid"])
*/ */
if ($_GET["action"] == 'create') if ($_GET["action"] == 'create')
{ {
$soc = new Societe($db); $soc = new Societe($db);
$result=$soc->fetch($_GET["socid"]); $result=$soc->fetch($_GET["socid"]);
if ($result < 0) if ($result < 0)
{ {
dolibarr_print_error($db,$soc->error); dolibarr_print_error($db,$soc->error);
exit; exit;
} }
$propal = new Propal($db); $propal = new Propal($db);
$propal->date=time(); $propal->date=time();
$obj = $conf->global->PROPALE_ADDON; $obj = $conf->global->PROPALE_ADDON;
$modPropale = new $obj; $modPropale = new $obj;
$numpr = $modPropale->getNextValue($soc,$propal); $numpr = $modPropale->getNextValue($soc,$propal);
// Fix pour modele numerotation qui deconne // Fix pour modele numerotation qui deconne
// Si numero deja pris (ne devrait pas arriver), on incremente par .num+1 // 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%'"; $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."propal WHERE ref like '$numpr%'";
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
{ {
$obj=$db->fetch_object($resql); $obj=$db->fetch_object($resql);
$num = $obj->nb; $num = $obj->nb;
$db->free($resql); $db->free($resql);
if ($num > 0) if ($num > 0)
{ {
$numpr .= "." . ($num + 1); $numpr .= "." . ($num + 1);
} }
} }
print "<form name='addprop' action=\"propal.php?socid=".$soc->id."\" method=\"post\">"; print "<form name='addprop' action=\"propal.php?socid=".$soc->id."\" method=\"post\">";
print "<input type=\"hidden\" name=\"action\" value=\"add\">"; print "<input type=\"hidden\" name=\"action\" value=\"add\">";
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref // Ref
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="2"><input name="ref" value="'.$numpr.'"></td></tr>'; print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="2"><input name="ref" value="'.$numpr.'"></td></tr>';
// Reference client // Reference client
print '<tr><td>'.$langs->trans('RefCustomer').'</td><td>'; print '<tr><td>'.$langs->trans('RefCustomer').'</td><td>';
print '<input type="text" name="ref_client" value=""></td>'; print '<input type="text" name="ref_client" value=""></td>';
print '</tr>'; print '</tr>';
@ -117,14 +117,14 @@ if ($_GET["action"] == 'create')
print '</tr>'; print '</tr>';
/* /*
* Contact de la propale * Contact de la propale
*/ */
print "<tr><td>".$langs->trans("DefaultContact")."</td><td colspan=\"2\">\n"; print "<tr><td>".$langs->trans("DefaultContact")."</td><td colspan=\"2\">\n";
$html->select_contacts($soc->id,$setcontact,'contactidp',1); $html->select_contacts($soc->id,$setcontact,'contactidp',1);
print '</td></tr>'; print '</td></tr>';
// Ligne info remises tiers // Ligne info remises tiers
print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="2">'; print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="2">';
if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
else print $langs->trans("CompanyHasNoRelativeDiscount"); else print $langs->trans("CompanyHasNoRelativeDiscount");
$absolute_discount=$soc->getAvailableDiscounts(); $absolute_discount=$soc->getAvailableDiscounts();
@ -152,151 +152,152 @@ if ($_GET["action"] == 'create')
print '</td></tr>'; print '</td></tr>';
// Date de livraison (ou de fabrication) // Date de livraison (ou de fabrication)
if ($conf->expedition->enabled) if ($conf->expedition->enabled)
{
if ($conf->global->PROPALE_ADD_SHIPPING_DATE)
{ {
print '<tr><td>'.$langs->trans("DeliveryDate").'</td>'; if ($conf->global->PROPALE_ADD_SHIPPING_DATE)
print '<td colspan="2">';
if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "")
{ {
$tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); print '<tr><td>'.$langs->trans("DeliveryDate").'</td>';
$syear = date("Y", $tmpdte); print '<td colspan="2">';
$smonth = date("m", $tmpdte); if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "")
$sday = date("d", $tmpdte); {
$html->select_date($syear."-".$smonth."-".$sday,'liv_','','','',"addprop"); $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 '</td></tr>';
} }
else
// Adresse de livraison
if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS)
{ {
$html->select_date(-1,'liv_','','','',"addprop"); print '<tr><td>'.$langs->trans('DeliveryAddress').'</td>';
print '<td colspan="3">';
$numaddress = $html->select_adresse_livraison($soc->adresse_livraison_id, $_GET['socid'],'adresse_livraison_id',1);
if ($numaddress==0)
{
print ' &nbsp; <a href=../comm/adresse_livraison.php?socid='.$soc->id.'&action=create>'.$langs->trans("AddAddress").'</a>';
}
print '</td></tr>';
} }
print '</td></tr>';
} }
// Adresse de livraison // Model
if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS) print '<tr>';
{ print '<td>'.$langs->trans("DefaultModel").'</td>';
print '<tr><td>'.$langs->trans('DeliveryAddress').'</td>'; print '<td colspan="2">';
print '<td colspan="3">'; $model=new ModelePDFPropales();
$numaddress = $html->select_adresse_livraison($soc->adresse_livraison_id, $_GET['socid'],'adresse_livraison_id',1); $liste=$model->liste_modeles($db);
if ($numaddress==0) $html->select_array('model',$liste,$conf->global->PROPALE_ADDON_PDF);
{ print "</td></tr>";
print ' &nbsp; <a href=../comm/adresse_livraison.php?socid='.$soc->id.'&action=create>'.$langs->trans("AddAddress").'</a>';
}
print '</td></tr>';
}
}
// Model
print '<tr>';
print '<td>'.$langs->trans("DefaultModel").'</td>';
print '<td colspan="2">';
$model=new ModelePDFPropales();
$liste=$model->liste_modeles($db);
$html->select_array('model',$liste,$conf->global->PROPALE_ADDON_PDF);
print "</td></tr>";
// Projet // Projet
if ($conf->projet->enabled) if ($conf->projet->enabled)
{ {
print '<tr>'; print '<tr>';
print '<td valign="top">'.$langs->trans("Project").'</td><td colspan="2">'; print '<td valign="top">'.$langs->trans("Project").'</td><td colspan="2">';
$numprojet=select_projects($soc->id,$projetid,'projetidp'); $numprojet=select_projects($soc->id,$projetid,'projetidp');
if ($numprojet==0) if ($numprojet==0)
{ {
print ' &nbsp; <a href="../projet/fiche.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddProject").'</a>'; print ' &nbsp; <a href="../projet/fiche.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddProject").'</a>';
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
print "</table>"; print "</table>";
print '<br>'; print '<br>';
/* /*
* Combobox pour la fonction de copie * Combobox pour la fonction de copie
*/ */
print '<table>'; print '<table>';
print '<tr>'; print '<tr>';
print '<td><input type="radio" name="createmode" value="copy"></td>'; print '<td><input type="radio" name="createmode" value="copy"></td>';
print '<td>'.$langs->trans("CopyPropalFrom").' </td>'; print '<td>'.$langs->trans("CopyPropalFrom").' </td>';
print '<td>'; print '<td>';
$liste_propal = array(); $liste_propal = array();
$liste_propal[0] = ''; $liste_propal[0] = '';
$sql ="SELECT p.rowid as id, p.ref, s.nom"; $sql ="SELECT p.rowid as id, p.ref, s.nom";
$sql.=" FROM ".MAIN_DB_PREFIX."propal p, ".MAIN_DB_PREFIX."societe s"; $sql.=" FROM ".MAIN_DB_PREFIX."propal p, ".MAIN_DB_PREFIX."societe s";
$sql.=" WHERE s.rowid = p.fk_soc AND fk_statut <> 0 ORDER BY Id"; $sql.=" WHERE s.rowid = p.fk_soc AND fk_statut <> 0 ORDER BY Id";
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql) if ($resql)
{ {
$num = $db->num_rows($resql); $num = $db->num_rows($resql);
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$row = $db->fetch_row($resql); $row = $db->fetch_row($resql);
$propalRefAndSocName = $row[1]." - ".$row[2]; $propalRefAndSocName = $row[1]." - ".$row[2];
$liste_propal[$row[0]]=$propalRefAndSocName; $liste_propal[$row[0]]=$propalRefAndSocName;
$i++; $i++;
} }
$html->select_array("copie_propal",$liste_propal, 0); $html->select_array("copie_propal",$liste_propal, 0);
} }
else else
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
print '</td></tr>'; print '</td></tr>';
if ($conf->global->PRODUCT_SHOW_WHEN_CREATE) print '<tr><td colspan="3">&nbsp;</td></tr>'; if ($conf->global->PRODUCT_SHOW_WHEN_CREATE) print '<tr><td colspan="3">&nbsp;</td></tr>';
print '<tr><td valign="top"><input type="radio" name="createmode" value="empty" checked="true"></td>'; print '<tr><td valign="top"><input type="radio" name="createmode" value="empty" checked="true"></td>';
print '<td valign="top" colspan="2">'.$langs->trans("CreateEmptyPropal").'</td></tr>'; print '<td valign="top" colspan="2">'.$langs->trans("CreateEmptyPropal").'</td></tr>';
if ($conf->global->PRODUCT_SHOW_WHEN_CREATE) if ($conf->global->PRODUCT_SHOW_WHEN_CREATE)
{ {
print '<tr><td colspan="3">'; print '<tr><td colspan="3">';
if ($conf->produit->enabled || $conf->service->enabled) if ($conf->produit->enabled || $conf->service->enabled)
{ {
$lib=$langs->trans("ProductsAndServices"); $lib=$langs->trans("ProductsAndServices");
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr>'; print '<tr>';
print '<td>'.$lib.'</td>'; print '<td>'.$lib.'</td>';
print '<td>'.$langs->trans("Qty").'</td>'; print '<td>'.$langs->trans("Qty").'</td>';
print '<td>'.$langs->trans("ReductionShort").'</td>'; print '<td>'.$langs->trans("ReductionShort").'</td>';
print '</tr>'; print '</tr>';
for ($i = 1 ; $i <= $conf->global->PROPALE_NEW_FORM_NB_PRODUCT ; $i++) for ($i = 1 ; $i <= $conf->global->PROPALE_NEW_FORM_NB_PRODUCT ; $i++)
{ {
print '<tr><td>'; print '<tr><td>';
// multiprix // multiprix
if($conf->global->PRODUIT_MULTIPRICES == 1) if($conf->global->PRODUIT_MULTIPRICES == 1)
$html->select_produits('',"idprod".$i,'',$conf->produit->limit_size,$soc->price_level); $html->select_produits('',"idprod".$i,'',$conf->produit->limit_size,$soc->price_level);
else else
$html->select_produits('',"idprod".$i,'',$conf->produit->limit_size); $html->select_produits('',"idprod".$i,'',$conf->produit->limit_size);
print '</td>'; print '</td>';
print '<td><input type="text" size="2" name="qty'.$i.'" value="1"></td>'; print '<td><input type="text" size="2" name="qty'.$i.'" value="1"></td>';
print '<td><input type="text" size="2" name="remise'.$i.'" value="'.$soc->remise_client.'">%</td>'; print '<td><input type="text" size="2" name="remise'.$i.'" value="'.$soc->remise_client.'">%</td>';
print '</tr>'; print '</tr>';
} }
print "</table>"; print "</table>";
} }
else else
{ {
print '&nbsp;'; print '&nbsp;';
} }
print '</td></tr>'; print '</td></tr>';
} }
print '</table>'; print '</table>';
print '<br>'; print '<br>';
$langs->load("bills"); $langs->load("bills");
print '<center>'; print '<center>';
print '<input type="submit" class="button" value="'.$langs->trans("CreateDraft").'">'; print '<input type="submit" class="button" value="'.$langs->trans("CreateDraft").'">';
print '</center>'; print '</center>';
print "</form>"; print "</form>";
} }
$db->close(); $db->close();

View File

@ -867,7 +867,8 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
} }
else else
{ {
$html->select_date(-1,'liv_','','',1,"crea_commande"); $dateorder=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
$html->select_date($dateorder,'liv_','','',1,"crea_commande");
} }
print "</td></tr>"; print "</td></tr>";

View File

@ -1291,7 +1291,7 @@ if ($_GET['action'] == 'create')
$mode_reglement_id = $soc->mode_reglement; $mode_reglement_id = $soc->mode_reglement;
$remise_percent = $soc->remise_client; $remise_percent = $soc->remise_client;
$remise_absolue = 0; $remise_absolue = 0;
$dateinvoice=-1; $dateinvoice=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
} }
$absolute_discount=$soc->getAvailableDiscounts(); $absolute_discount=$soc->getAvailableDiscounts();

View File

@ -279,9 +279,10 @@ if ($_GET['action'] == 'create' || $_POST['action'] == 'confirm_paiement' || $_P
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'.$facture->client->getNomUrl(4)."</td></tr>\n"; print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'.$facture->client->getNomUrl(4)."</td></tr>\n";
// Date payment // Date payment
$datepaye = dolibarr_mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
print '<tr><td>'.$langs->trans('Date').'</td><td>'; print '<tr><td>'.$langs->trans('Date').'</td><td>';
$html->select_date((! empty($datepaye) ? $datepaye : -1),'','','',0,"add_paiement"); $datepayment = dolibarr_mktime(12, 0 , 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']);
$datepayment= ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0) : $datepayment);
$html->select_date($datepayment,'','','',0,"add_paiement");
print '</td>'; print '</td>';
print '<td>'.$langs->trans('Comments').'</td></tr>'; print '<td>'.$langs->trans('Comments').'</td></tr>';

View File

@ -206,7 +206,8 @@ if ($_GET["action"] == 'create')
print "<input type=\"hidden\" name=\"chid\" value=\"$chid\">"; print "<input type=\"hidden\" name=\"chid\" value=\"$chid\">";
print '<tr><td>'.$langs->trans("Date").'</td><td>'; print '<tr><td>'.$langs->trans("Date").'</td><td>';
$html->select_date(-1,'','','','',"add_paiement"); $datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
$html->select_date($datepayment,'','','','',"add_paiement");
print "</td>"; print "</td>";
print '<td>'.$langs->trans("Comments").'</td></tr>'; print '<td>'.$langs->trans("Comments").'</td></tr>';

View File

@ -529,17 +529,17 @@ function dolibarr_getdate($timestamp,$fast=false)
} }
/** /**
\brief Retourne une date fabriqu<EFBFBD>e depuis infos. \brief Retourne une date fabriquee depuis infos.
Remplace la fonction mktime non impl<EFBFBD>ment<EFBFBD>e sous Windows si ann<EFBFBD>e < 1970 Remplace la fonction mktime non implementee sous Windows si annee < 1970
\param hour Heure \param hour Hour
\param minute Minute \param minute Minute
\param second Seconde \param second Second
\param month Mois \param month Month
\param day Jour \param day Day
\param year Ann<EFBFBD>e \param year Year
\param gm Time gm \param gm Time gm
\param check No check on parameters (Can use day 32, etc...) \param check No check on parameters (Can use day 32, etc...)
\return timestamp Date en timestamp, '' if error \return timestamp Date en timestamp, '' if error
\remarks PHP mktime is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows \remarks PHP mktime is restricted to the years 1901-2038 on Unix and 1970-2038 on Windows
*/ */
function dolibarr_mktime($hour,$minute,$second,$month,$day,$year,$gm=0,$check=1) function dolibarr_mktime($hour,$minute,$second,$month,$day,$year,$gm=0,$check=1)