New: Can open back a commercial proposal

This commit is contained in:
Laurent Destailleur 2011-12-16 14:59:09 +01:00
parent 0c32afe40b
commit b54da5a719
5 changed files with 109 additions and 56 deletions

View File

@ -5,6 +5,7 @@ English Dolibarr ChangeLog
***** ChangeLog for 3.2 compared to 3.1 ***** ***** ChangeLog for 3.2 compared to 3.1 *****
For users: For users:
- New: Can open back a closed commercial proposal.
- New: show thirdparty barcode on main tab. - New: show thirdparty barcode on main tab.
- New: Can input note (private and public) during note and expenses creation. - New: Can input note (private and public) during note and expenses creation.
- New: Print ticket show invoice ref into POS module. - New: Print ticket show invoice ref into POS module.

View File

@ -89,6 +89,7 @@ $hookmanager=new HookManager($db);
$hookmanager->callHooks(array('propalcard')); $hookmanager->callHooks(array('propalcard'));
/******************************************************************************/ /******************************************************************************/
/* Actions */ /* Actions */
/******************************************************************************/ /******************************************************************************/
@ -246,9 +247,7 @@ if ($_POST['action'] == 'set_ref_client' && $user->rights->propale->creer)
$object->set_ref_client($user, $_POST['ref_client']); $object->set_ref_client($user, $_POST['ref_client']);
} }
/* // Create proposal
* Creation propale
*/
if ($_POST['action'] == 'add' && $user->rights->propale->creer) if ($_POST['action'] == 'add' && $user->rights->propale->creer)
{ {
$object->socid=$_POST['socid']; $object->socid=$_POST['socid'];
@ -382,31 +381,42 @@ if ($action == 'classifybilled')
$object->cloture($user, 4, ''); $object->cloture($user, 4, '');
} }
/* // Reopen proposal
* Cloture de la propale if ($action == 'confirm_reopen' && $user->rights->propale->cloturer)
*/
if (GETPOST('action') == 'setstatut' && $user->rights->propale->cloturer)
{ {
if (! $_POST['cancel']) if (! $_POST['cancel'])
{ {
if (! GETPOST('statut')) $object->fetch($id);
// prevent browser refresh from reopening proposal several times
if ($object->statut==2 || $object->statut==3)
{ {
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("CloseAs")).'</div>'; $object->setStatut(1);
$action='statut';
$action='statut';
}
else
{
$object->fetch($id);
// prevent browser refresh from closing proposal several times
if ($object->statut==1)
{
$object->cloture($user, $_REQUEST['statut'], $_REQUEST['note']);
}
} }
} }
} }
// Close proposal
if ($action == 'setstatut' && $user->rights->propale->cloturer)
{
if (! $_POST['cancel'])
{
if (! GETPOST('statut'))
{
$mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("CloseAs")).'</div>';
$action='statut';
$action='statut';
}
else
{
$object->fetch($id);
// prevent browser refresh from closing proposal several times
if ($object->statut==1)
{
$object->cloture($user, $_REQUEST['statut'], $_REQUEST['note']);
}
}
}
}
/* /*
* Add file in email form * Add file in email form
@ -1051,17 +1061,19 @@ if ($id > 0 || ! empty($ref))
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('ClonePropal'),$langs->trans('ConfirmClonePropal',$object->ref),'confirm_clone',$formquestion,'yes',1); $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('ClonePropal'),$langs->trans('ConfirmClonePropal',$object->ref),'confirm_clone',$formquestion,'yes',1);
} }
/* // Confirm delete
* Confirmation de la suppression de la propale
*/
if ($action == 'delete') if ($action == 'delete')
{ {
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp'), 'confirm_delete','',0,1); $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp',$object->ref), 'confirm_delete','',0,1);
} }
/* // Confirm reopen
* Confirmation de la suppression d'une ligne produit/service if ($action == 'reopen')
*/ {
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenProp',$object->ref), 'confirm_reopen','',0,1);
}
// Confirmation delete product/service line
if ($action == 'ask_deleteline') if ($action == 'ask_deleteline')
{ {
$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline','',0,1); $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline','',0,1);
@ -1569,6 +1581,13 @@ if ($id > 0 || ! empty($ref))
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=modif">'.$langs->trans('Modify').'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=modif">'.$langs->trans('Modify').'</a>';
} }
// ReOpen
if (($object->statut == 2 || $object->statut == 3) && $user->rights->propale->cloturer)
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen'.(empty($conf->global->MAIN_JUMP_TAG)?'':'#reopen').'"';
print '>'.$langs->trans('ReOpen').'</a>';
}
// Send // Send
if ($object->statut == 1 || $object->statut == 2) if ($object->statut == 1 || $object->statut == 2)
{ {
@ -1594,9 +1613,9 @@ if ($id > 0 || ! empty($ref))
} }
// Create an invoice and classify billed // Create an invoice and classify billed
if ($conf->facture->enabled && $object->statut == 2 && $user->societe_id == 0) if ($object->statut == 2 && $user->societe_id == 0)
{ {
if ($user->rights->facture->creer) if ($conf->facture->enabled && $user->rights->facture->creer)
{ {
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddBill").'</a>'; print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddBill").'</a>';
} }

View File

@ -116,17 +116,17 @@ class Propal extends CommonObject
/** /**
* Class Constructor * Constructor
* *
* @param DoliDB $DB Database handler * @param DoliDB $db Database handler
* @param int $socid Id third party * @param int $socid Id third party
* @param int $propalid Id proposal * @param int $propalid Id proposal
*/ */
function Propal($DB, $socid="", $propalid=0) function Propal($db, $socid="", $propalid=0)
{ {
global $conf,$langs; global $conf,$langs;
$this->db = $DB ; $this->db = $db;
$this->socid = $socid; $this->socid = $socid;
$this->id = $propalid; $this->id = $propalid;
$this->products = array(); $this->products = array();
@ -157,7 +157,7 @@ class Propal extends CommonObject
* @param int $idproduct Product Id to add * @param int $idproduct Product Id to add
* @param int $qty Quantity * @param int $qty Quantity
* @param int $remise_percent Discount effected on Product * @param int $remise_percent Discount effected on Product
* *
* TODO Remplacer les appels a cette fonction par generation objet Ligne * TODO Remplacer les appels a cette fonction par generation objet Ligne
* insere dans tableau $this->products * insere dans tableau $this->products
*/ */
@ -303,7 +303,7 @@ class Propal extends CommonObject
* @param int $special_code Special code * @param int $special_code Special code
* @param int $fk_parent_line Id of parent line * @param int $fk_parent_line Id of parent line
* @return int >0 if OK, <0 if KO * @return int >0 if OK, <0 if KO
* *
* @see add_product * @see add_product
*/ */
function addline($propalid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0) function addline($propalid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $price_base_type='HT', $pu_ttc=0, $info_bits=0, $type=0, $rang=-1, $special_code=0, $fk_parent_line=0)
@ -828,7 +828,7 @@ class Propal extends CommonObject
/** /**
* Insert into DB a proposal object completely defined by its data members (ex, results from copy). * Insert into DB a proposal object completely defined by its data members (ex, results from copy).
* @param User $user User that create * @param User $user User that create
* @return int Id of the new object if ok, <0 if ko * @return int Id of the new object if ok, <0 if ko
* @see create * @see create
*/ */
@ -1249,7 +1249,7 @@ class Propal extends CommonObject
/** /**
* Set delivery date * Set delivery date
* *
* @param User $user Object user that modify * @param User $user Object user that modify
* @param timestamp $date_livraison Delivery date * @param timestamp $date_livraison Delivery date
* @return int <0 if ko, >0 if ok * @return int <0 if ko, >0 if ok
@ -1463,13 +1463,44 @@ class Propal extends CommonObject
} }
} }
/**
* Close the commercial proposal
*
* @param User $user Object user that close
* @param int $statut Statut
* @param text $note Comment
* @return int <0 if KO, >0 if OK
*/
function reopen($user, $statut, $note)
{
global $langs,$conf;
$this->statut = $statut;
$error=0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."propal";
$sql.= " SET fk_statut = ".$statut.", note = '".$this->db->escape($note)."', date_cloture=".$this->db->idate(mktime()).", fk_user_cloture=".$user->id;
$sql.= " WHERE rowid = ".$this->id;
$resql=$this->db->query($sql);
if ($resql)
{
}
}
/** /**
* Closure of the commercial proposal * Close the commercial proposal
* @param User $user Object user that closure *
* @param User $user Object user that close
* @param int $statut Statut * @param int $statut Statut
* @param text $note Commentaire * @param text $note Comment
* @return int <0 si ko, >0 si ok * @return int <0 if KO, >0 if OK
*/ */
function cloture($user, $statut, $note) function cloture($user, $statut, $note)
{ {
@ -1477,7 +1508,7 @@ class Propal extends CommonObject
$this->statut = $statut; $this->statut = $statut;
$error=0; $error=0;
$this->db->begin(); $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."propal"; $sql = "UPDATE ".MAIN_DB_PREFIX."propal";
@ -1929,7 +1960,7 @@ class Propal extends CommonObject
/** /**
* Change source demand * Change source demand
* *
* @param int $demand_reason_id Id of new source demand * @param int $demand_reason_id Id of new source demand
* @return int >0 si ok, <0 si ko * @return int >0 si ok, <0 si ko
*/ */
@ -2021,7 +2052,7 @@ class Propal extends CommonObject
/** /**
* Return label of status of proposal (draft, validated, ...) * Return label of status of proposal (draft, validated, ...)
* *
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
* @return string Label * @return string Label
*/ */
@ -2032,7 +2063,7 @@ class Propal extends CommonObject
/** /**
* Return label of a status (draft, validated, ...) * Return label of a status (draft, validated, ...)
* *
* @param int $statut id statut * @param int $statut id statut
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
* @return string Label * @return string Label
@ -2087,7 +2118,7 @@ class Propal extends CommonObject
/** /**
* Load indicators for dashboard (this->nbtodo and this->nbtodolate) * Load indicators for dashboard (this->nbtodo and this->nbtodolate)
* *
* @param User $user Object user * @param User $user Object user
* @param int $mode "opened" for proposal to close, "signed" for proposal to invoice * @param int $mode "opened" for proposal to close, "signed" for proposal to invoice
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
@ -2273,7 +2304,7 @@ class Propal extends CommonObject
} }
/** /**
* Returns the reference to the following non used Proposal used depending on the active numbering module * Returns the reference to the following non used Proposal used depending on the active numbering module
* defined into PROPALE_ADDON * defined into PROPALE_ADDON
* *
@ -2321,7 +2352,7 @@ class Propal extends CommonObject
/** /**
* Return clicable link of object (with eventually picto) * Return clicable link of object (with eventually picto)
* *
* @param int $withpicto Add picto into link * @param int $withpicto Add picto into link
* @param string $option Where point the link * @param string $option Where point the link
* @param string $get_params Parametres added to url * @param string $get_params Parametres added to url
@ -2357,7 +2388,7 @@ class Propal extends CommonObject
/** /**
* Retrieve an array of propal lines * Retrieve an array of propal lines
* *
* @return int <0 if ko, >0 if ok * @return int <0 if ko, >0 if ok
*/ */
function getLinesArray() function getLinesArray()
@ -2485,7 +2516,7 @@ class PropaleLigne
/** /**
* Class line Contructor * Class line Contructor
* *
* @param DoliDB $DB Database handler * @param DoliDB $DB Database handler
*/ */
function PropaleLigne($DB) function PropaleLigne($DB)
@ -2495,7 +2526,7 @@ class PropaleLigne
/** /**
* Retrieve the propal line object * Retrieve the propal line object
* *
* @param int $rowid propal line id * @param int $rowid propal line id
*/ */
function fetch($rowid) function fetch($rowid)
@ -2551,7 +2582,7 @@ class PropaleLigne
/** /**
* Insert object line propal in database * Insert object line propal in database
* *
* @param int $notrigger 1=Does not execute triggers, 0= execuete triggers * @param int $notrigger 1=Does not execute triggers, 0= execuete triggers
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
*/ */
@ -2560,7 +2591,7 @@ class PropaleLigne
global $conf,$langs,$user; global $conf,$langs,$user;
$error=0; $error=0;
dol_syslog("PropaleLigne::insert rang=".$this->rang); dol_syslog("PropaleLigne::insert rang=".$this->rang);
// Clean parameters // Clean parameters
@ -2686,7 +2717,7 @@ class PropaleLigne
global $conf,$langs,$user; global $conf,$langs,$user;
$error=0; $error=0;
// Clean parameters // Clean parameters
if (empty($this->tva_tx)) $this->tva_tx=0; if (empty($this->tva_tx)) $this->tva_tx=0;
if (empty($this->localtax1_tx)) $this->localtax1_tx=0; if (empty($this->localtax1_tx)) $this->localtax1_tx=0;

View File

@ -77,7 +77,8 @@ CreateEmptyPropal=Create empty commercial proposals vierge or from list of produ
DefaultProposalDurationValidity=Default commercial proposal validity duration (in days) DefaultProposalDurationValidity=Default commercial proposal validity duration (in days)
UseCustomerContactAsPropalRecipientIfExist=Use customer contact address if defined instead of third party address as proposal recipient address UseCustomerContactAsPropalRecipientIfExist=Use customer contact address if defined instead of third party address as proposal recipient address
ClonePropal=Clone commercial proposal ClonePropal=Clone commercial proposal
ConfirmClonePropal=Are you sure you want to clone this commercial proposal <b>%s</b> ? ConfirmClonePropal=Are you sure you want to clone the commercial proposal <b>%s</b> ?
ConfirmReOpenProp=Are you sure you want to open back the commercial proposal <b>%s</b> ?
ProposalsAndProposalsLines=Commercial proposal and lines ProposalsAndProposalsLines=Commercial proposal and lines
ProposalLine=Proposal line ProposalLine=Proposal line
AvailabilityPeriod=Availability delay AvailabilityPeriod=Availability delay

View File

@ -77,7 +77,8 @@ CreateEmptyPropal=Créer proposition/devis vierge
DefaultProposalDurationValidity=Délai de validité par défaut (en jours) DefaultProposalDurationValidity=Délai de validité par défaut (en jours)
UseCustomerContactAsPropalRecipientIfExist=Utiliser adresse contact suivi client si défini plutôt que adresse tiers comme destinataire des propositions UseCustomerContactAsPropalRecipientIfExist=Utiliser adresse contact suivi client si défini plutôt que adresse tiers comme destinataire des propositions
ClonePropal=Cloner proposition commerciale ClonePropal=Cloner proposition commerciale
ConfirmClonePropal=Êtes-vous sûr de vouloir cloner cette proposition commerciale <b>%s</b> ? ConfirmClonePropal=Êtes-vous sûr de vouloir cloner la proposition commerciale <b>%s</b> ?
ConfirmReOpenProp=Êtes-vous sûr de vouloir réouvrir la proposition commerciale <b>%s</b> ?
ProposalsAndProposalsLines=Propositions commerciales clientes et lignes de propositions ProposalsAndProposalsLines=Propositions commerciales clientes et lignes de propositions
ProposalLine=Ligne de proposition ProposalLine=Ligne de proposition
AvailabilityPeriod=Délai de livraison AvailabilityPeriod=Délai de livraison