Skip to content

Commit

Permalink
Use constant vor status.
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed May 5, 2017
1 parent 90542d1 commit 0bffac6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 34 deletions.
4 changes: 2 additions & 2 deletions htdocs/comm/propal/class/propal.class.php
Expand Up @@ -187,7 +187,7 @@ class Propal extends CommonObject
/**
* Billed or processed quote
*/
const STATUS_BILLED = 4;
const STATUS_BILLED = 4; // Todo rename into STATUS_CLOSE ?
/**
* Constructor
Expand Down Expand Up @@ -1301,7 +1301,7 @@ function fetch($rowid,$ref='')
$this->note = $obj->note_private; // TODO deprecated
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->statut = $obj->fk_statut;
$this->statut = (int) $obj->fk_statut;
$this->statut_libelle = $obj->statut_label;

$this->datec = $this->db->jdate($obj->datec); // TODO deprecated
Expand Down
12 changes: 6 additions & 6 deletions htdocs/install/mysql/tables/llx_supplier_proposal.sql
Expand Up @@ -18,7 +18,7 @@
CREATE TABLE llx_supplier_proposal (
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
ref varchar(30) NOT NULL,
entity integer NOT NULL DEFAULT '1',
entity integer NOT NULL DEFAULT 1,
ref_ext varchar(255) DEFAULT NULL,
ref_int varchar(255) DEFAULT NULL,
fk_soc integer DEFAULT NULL,
Expand All @@ -31,11 +31,11 @@ CREATE TABLE llx_supplier_proposal (
fk_user_modif integer DEFAULT NULL,
fk_user_valid integer DEFAULT NULL,
fk_user_cloture integer DEFAULT NULL,
fk_statut smallint NOT NULL DEFAULT '0', -- 0=draft, 1=validated, 2=accepted, 3=refused, 4=closed
price double DEFAULT '0',
remise_percent double DEFAULT '0',
remise_absolue double DEFAULT '0',
remise double DEFAULT '0',
fk_statut smallint DEFAULT 0 NOT NULL, -- 0=draft, 1=validated, 2=accepted, 3=refused, 4=billed/closed
price double DEFAULT 0,
remise_percent double DEFAULT 0,
remise_absolue double DEFAULT 0,
remise double DEFAULT 0,
total_ht double(24,8) DEFAULT 0,
tva double(24,8) DEFAULT 0,
localtax1 double(24,8) DEFAULT 0,
Expand Down
40 changes: 18 additions & 22 deletions htdocs/supplier_proposal/card.php
Expand Up @@ -261,7 +261,7 @@
$object->modelpdf = GETPOST('model');
$object->author = $user->id; // deprecated
$object->note = GETPOST('note');
$object->statut = 0;
$object->statut = SupplierProposal::STATUS_DRAFT;

$id = $object->create_from($user);
} else {
Expand Down Expand Up @@ -436,16 +436,16 @@
// Reopen proposal
else if ($action == 'confirm_reopen' && $user->rights->supplier_proposal->cloturer && ! GETPOST('cancel')) {
// prevent browser refresh from reopening proposal several times
if ($object->statut == 2 || $object->statut == 3 || $object->statut == 4) {
$object->reopen($user, 1);
if ($object->statut == SupplierProposal::STATUS_SIGNED || $object->statut == SupplierProposal::STATUS_NOTSIGNED || $object->statut == SupplierProposal::STATUS_CLOSE) {
$object->reopen($user, SupplierProposal::STATUS_VALIDATED);
}
}

// Close proposal
else if ($action == 'close' && $user->rights->supplier_proposal->cloturer && ! GETPOST('cancel')) {
// prevent browser refresh from reopening proposal several times
if ($object->statut == 2) {
$object->setStatut(4);
// prevent browser refresh from reopening proposal several times
if ($object->statut == SupplierProposal::STATUS_SIGNED) {
$object->setStatut(SupplierProposal::STATUS_CLOSE);
}
}

Expand All @@ -456,7 +456,7 @@
$action = 'statut';
} else {
// prevent browser refresh from closing proposal several times
if ($object->statut == 1) {
if ($object->statut == SupplierProposal::STATUS_VALIDATED) {
$object->cloture($user, GETPOST('statut'), GETPOST('note'));
}
}
Expand Down Expand Up @@ -1239,7 +1239,7 @@
$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 .= " AND p.fk_statut <> ".SupplierProposal::STATUS_DRAFT;
$sql .= " ORDER BY Id";

$resql = $db->query($sql);
Expand Down Expand Up @@ -1658,7 +1658,7 @@
<input type="hidden" name="id" value="' . $object->id . '">
';

if (! empty($conf->use_javascript_ajax) && $object->statut == 0) {
if (! empty($conf->use_javascript_ajax) && $object->statut == SupplierProposal::STATUS_DRAFT) {
include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
}

Expand All @@ -1673,12 +1673,10 @@
$ret = $object->printObjectLines($action, $soc, $mysoc, $lineid, 1);

// Form to add new line
if ($object->statut == 0 && $user->rights->supplier_proposal->creer)
if ($object->statut == SupplierProposal::STATUS_DRAFT && $user->rights->supplier_proposal->creer)
{
if ($action != 'editline')
{
$var = true;

// Add products/services form
$object->formAddObjectLine(1, $soc, $mysoc);

Expand Down Expand Up @@ -1735,7 +1733,7 @@
if ($action != 'statut' && $action != 'editline')
{
// Validate
if ($object->statut == 0 && $object->total_ttc >= 0 && count($object->lines) > 0 &&
if ($object->statut == SupplierProposal::STATUS_DRAFT && $object->total_ttc >= 0 && count($object->lines) > 0 &&
((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->validate_advance)))
) {
Expand All @@ -1745,39 +1743,39 @@
}

// Edit
if ($object->statut == 1 && $user->rights->supplier_proposal->creer) {
if ($object->statut == SupplierProposal::STATUS_VALIDATED && $user->rights->supplier_proposal->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=modif">' . $langs->trans('Modify') . '</a></div>';
}

// ReOpen
if (($object->statut == 2 || $object->statut == 3 || $object->statut == 4) && $user->rights->supplier_proposal->cloturer) {
if (($object->statut == SupplierProposal::STATUS_SIGNED || $object->statut == SupplierProposal::STATUS_NOTSIGNED || $object->statut == SupplierProposal::STATUS_CLOSE) && $user->rights->supplier_proposal->cloturer) {
print '<div class="inline-block divButAction"><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></div>';
}

// Send
if ($object->statut == 1 || $object->statut == 2) {
if ($object->statut == SupplierProposal::STATUS_VALIDATED || $object->statut == SupplierProposal::STATUS_SIGNED) {
if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->supplier_proposal->send_advance) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=presend&amp;mode=init">' . $langs->trans('SendByMail') . '</a></div>';
} else
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">' . $langs->trans('SendByMail') . '</a></div>';
}

// Create an order
if (! empty($conf->commande->enabled) && $object->statut == 2) {
if (! empty($conf->commande->enabled) && $object->statut == SupplierProposal::STATUS_SIGNED) {
if ($user->rights->fournisseur->commande->creer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . DOL_URL_ROOT . '/fourn/commande/card.php?action=create&amp;origin=' . $object->element . '&amp;originid=' . $object->id . '&amp;socid=' . $object->socid . '">' . $langs->trans("AddOrder") . '</a></div>';
}
}

// Set accepted/refused
if ($object->statut == 1 && $user->rights->supplier_proposal->cloturer) {
if ($object->statut == SupplierProposal::STATUS_VALIDATED && $user->rights->supplier_proposal->cloturer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=statut' . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#acceptedrefused') . '"';
print '>' . $langs->trans('SetAcceptedRefused') . '</a></div>';
}

// Close
if ($object->statut == 2 && $user->rights->supplier_proposal->cloturer) {
if ($object->statut == SupplierProposal::STATUS_SIGNED && $user->rights->supplier_proposal->cloturer) {
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=close' . (empty($conf->global->MAIN_JUMP_TAG) ? '' : '#close') . '"';
print '>' . $langs->trans('Close') . '</a></div>';
}
Expand All @@ -1788,7 +1786,7 @@
}

// Delete
if (($object->statut == 0 && $user->rights->supplier_proposal->creer) || $user->rights->supplier_proposal->supprimer) {
if (($object->statut == SupplierProposal::STATUS_DRAFT && $user->rights->supplier_proposal->creer) || $user->rights->supplier_proposal->supprimer) {
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=delete"';
print '>' . $langs->trans('Delete') . '</a></div>';
}
Expand All @@ -1811,8 +1809,6 @@
$genallowed = $user->rights->supplier_proposal->creer;
$delallowed = $user->rights->supplier_proposal->supprimer;

$var = true;

print $formfile->showdocuments('supplier_proposal', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', 0, '', $soc->default_lang);


Expand Down
7 changes: 3 additions & 4 deletions htdocs/supplier_proposal/class/supplier_proposal.class.php
Expand Up @@ -158,9 +158,9 @@ class SupplierProposal extends CommonObject
*/
const STATUS_NOTSIGNED = 3;
/**
* Billed or processed quote
* Billed or closed/processed quote
*/
const STATUS_BILLED = 4;
const STATUS_CLOSE = 4;



Expand Down Expand Up @@ -1143,9 +1143,8 @@ function fetch($rowid,$ref='')
$this->note = $obj->note_private; // TODO deprecated
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->statut = $obj->fk_statut;
$this->statut = (int) $obj->fk_statut;
$this->statut_libelle = $obj->statut_label;

$this->datec = $this->db->jdate($obj->datec); // TODO deprecated
$this->datev = $this->db->jdate($obj->datev); // TODO deprecated
$this->date_creation = $this->db->jdate($obj->datec); //Creation date
Expand Down

0 comments on commit 0bffac6

Please sign in to comment.