[ task #731 ] Uniformize ref generation. Propals
This commit is contained in:
parent
f172c900c7
commit
7d9d575e40
@ -1180,37 +1180,6 @@ if ($action == 'create')
|
||||
|
||||
$object = new Propal($db);
|
||||
|
||||
$numpr='';
|
||||
$obj = $conf->global->PROPALE_ADDON;
|
||||
if ($obj)
|
||||
{
|
||||
if (! empty($conf->global->PROPALE_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.'.php';
|
||||
$modPropale = new $obj;
|
||||
$numpr = $modPropale->getNextValue($soc,$object);
|
||||
}
|
||||
}
|
||||
|
||||
// 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 '<form name="addprop" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
@ -1222,12 +1191,9 @@ if ($action == 'create')
|
||||
}
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Ref").'</td>';
|
||||
print '<td colspan="2">'.$numpr.'</td>';
|
||||
print '<input type="hidden" name="ref" value="'.$numpr.'">';
|
||||
print '</tr>';
|
||||
|
||||
// Reference
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans("Draft").'</td></tr>';
|
||||
|
||||
// Ref customer
|
||||
print '<tr><td>'.$langs->trans('RefCustomer').'</td><td colspan="2">';
|
||||
@ -1990,10 +1956,10 @@ else
|
||||
if ($action != 'statut' && $action <> 'editline')
|
||||
{
|
||||
// Validate
|
||||
if ($object->statut == 0 && $user->rights->propal->valider)
|
||||
if ($object->statut == 0 && $object->total_ttc >= 0 && count($object->lines) > 0 && $user->rights->propal->valider)
|
||||
{
|
||||
if (count($object->lines) > 0) print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=validate">'.$langs->trans('Validate').'</a>';
|
||||
else print '<a class="butActionRefused" href="#">'.$langs->trans('Validate').'</a>';
|
||||
//else print '<a class="butActionRefused" href="#">'.$langs->trans('Validate').'</a>';
|
||||
}
|
||||
|
||||
// Edit
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Copyright (C) 2005-2013 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
|
||||
* Copyright (C) 2010-2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2010-2011 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2012 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
*
|
||||
@ -720,7 +720,7 @@ class Propal extends CommonObject
|
||||
|
||||
if ($this->id)
|
||||
{
|
||||
if (empty($this->ref)) $this->ref='(PROV'.$this->id.')';
|
||||
$this->ref='(PROV'.$this->id.')';
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."propal SET ref='".$this->ref."' WHERE rowid=".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::create sql=".$sql);
|
||||
@ -1178,11 +1178,29 @@ class Propal extends CommonObject
|
||||
$now=dol_now();
|
||||
|
||||
if ($user->rights->propale->valider)
|
||||
{
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
// Numbering module definition
|
||||
$soc = new Societe($this->db);
|
||||
$soc->fetch($this->socid);
|
||||
|
||||
// Class of company linked to propal
|
||||
$result=$soc->set_as_client();
|
||||
|
||||
// Define new ref
|
||||
if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref)))
|
||||
{
|
||||
$num = $this->getNextNumRef($soc);
|
||||
}
|
||||
else
|
||||
{
|
||||
$num = $this->ref;
|
||||
}
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
|
||||
$sql.= " SET fk_statut = 1, date_valid='".$this->db->idate($now)."', fk_user_valid=".$user->id;
|
||||
$sql.= " SET ref = '".$num."',";
|
||||
$sql.= " fk_statut = 1, date_valid='".$this->db->idate($now)."', fk_user_valid=".$user->id;
|
||||
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
|
||||
|
||||
dol_syslog(get_class($this).'::valid sql='.$sql);
|
||||
|
||||
@ -19,7 +19,7 @@ DeleteProp=Eliminar pressupost
|
||||
ValidateProp=Validar pressupost
|
||||
AddProp=Crear pressupost
|
||||
ConfirmDeleteProp=Esteu segur de voler eliminar aquest pressupost?
|
||||
ConfirmValidateProp=Esteu segur de voler validar aquest pressupost?
|
||||
ConfirmValidateProp=Esteu segur de voler validar aquest pressupost sota la referència <b>%s</b>?
|
||||
LastPropals=Els %s darrers pressupostos
|
||||
LastClosedProposals=Els %s darrers pressupostos tancats
|
||||
LastModifiedProposals=Els %s darrers pressupostos modificats
|
||||
|
||||
@ -19,7 +19,7 @@ DeleteProp=Delete commercial proposal
|
||||
ValidateProp=Validate commercial proposal
|
||||
AddProp=Add proposal
|
||||
ConfirmDeleteProp=Are you sure you want to delete this commercial proposal ?
|
||||
ConfirmValidateProp=Are you sure you want to validate this commercial proposal ?
|
||||
ConfirmValidateProp=Are you sure you want to validate this commercial proposal under name <b>%s</b> ?
|
||||
LastPropals=Last %s proposals
|
||||
LastClosedProposals=Last %s closed proposals
|
||||
LastModifiedProposals=Last %s modified proposals
|
||||
|
||||
@ -20,7 +20,7 @@ DeleteProp=Eliminar presupuesto
|
||||
ValidateProp=Validar presupuesto
|
||||
AddProp=Crear presupuesto
|
||||
ConfirmDeleteProp=¿Está seguro de querer eliminar este presupuesto?
|
||||
ConfirmValidateProp=¿Está seguro de querer validar este presupuesto?
|
||||
ConfirmValidateProp=¿Está seguro de querer validar este presupuesto bajo la referencia <b>%s</b> ?
|
||||
LastPropals=Los %s últimos presupuestos
|
||||
LastClosedProposals=Los %s últimos presupuestos cerrados
|
||||
LastModifiedProposals=Los %s últimos presupuestos modificados
|
||||
|
||||
@ -19,7 +19,7 @@ DeleteProp=Supprimer proposition
|
||||
ValidateProp=Valider proposition
|
||||
AddProp=Créer proposition
|
||||
ConfirmDeleteProp=Êtes-vous sûr de vouloir effacer cette proposition commerciale ?
|
||||
ConfirmValidateProp=Êtes-vous sûr de vouloir valider cette proposition commerciale ?
|
||||
ConfirmValidateProp=Êtes-vous sûr de vouloir valider cette proposition commerciale sous la référence <b>%s</b> ?
|
||||
LastPropals=Les %s dernières propales
|
||||
LastClosedProposals=Les %s dernières propositions commerciales fermées
|
||||
LastModifiedProposals=Les %s dernières propositions commerciales modifiées
|
||||
|
||||
Loading…
Reference in New Issue
Block a user