2
0
forked from Wavyzz/dolibarr

Merge pull request #2529 from aspangaro/develop-don

NEW better integration in project for donation module
This commit is contained in:
Laurent Destailleur
2015-04-02 11:42:15 +02:00
6 changed files with 62 additions and 33 deletions

View File

@@ -106,7 +106,7 @@ if ($action == 'update')
$object->email = GETPOST("email");
$object->date = $donation_date;
$object->public = GETPOST("public");
$object->fk_project = GETPOST("fk_project");
$object->fk_projet = GETPOST("fk_projet");
$object->note_private= GETPOST("note_private");
$object->note_public = GETPOST("note_public");
@@ -161,7 +161,7 @@ if ($action == 'add')
$object->note_private= GETPOST("note_private");
$object->note_public = GETPOST("note_public");
$object->public = GETPOST("public");
$object->fk_project = GETPOST("fk_project");
$object->fk_projet = GETPOST("fk_projet");
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
@@ -343,7 +343,7 @@ if ($action == 'create')
$formproject=new FormProjets($db);
print "<tr><td>".$langs->trans("Project")."</td><td>";
$formproject->select_projects(-1, GETPOST("fk_project"),'fk_project', 0, 1, 0, 1);
$formproject->select_projects(-1, GETPOST("fk_projet"),'fk_projet', 0, 1, 0, 1);
print "</td></tr>\n";
}
@@ -459,7 +459,7 @@ if (! empty($id) && $action == 'edit')
$langs->load('projects');
print '<tr><td>'.$langs->trans('Project').'</td><td>';
$formproject->select_projects(-1, $object->fk_project,'fk_project', 0, 1, 0, 1);
$formproject->select_projects(-1, $object->fk_projet,'fk_projet', 0, 1, 0, 1);
print '</td></tr>';
}

View File

@@ -54,7 +54,7 @@ class Don extends CommonObject
var $country;
var $email;
var $public;
var $fk_project;
var $fk_projet;
var $modepaiement;
var $modepaiementid;
var $note_private;
@@ -337,7 +337,7 @@ class Don extends CommonObject
// $sql.= ", country"; -- Deprecated
$sql.= ", fk_country";
$sql.= ", public";
$sql.= ", fk_project";
$sql.= ", fk_projet";
$sql.= ", note_private";
$sql.= ", note_public";
$sql.= ", fk_user_author";
@@ -359,7 +359,7 @@ class Don extends CommonObject
$sql.= ", '".$this->db->escape($this->town)."'";
$sql.= ", ".$this->country_id;
$sql.= ", ".$this->public;
$sql.= ", ".($this->fk_project > 0?$this->fk_project:"null");
$sql.= ", ".($this->fk_projet > 0?$this->fk_projet:"null");
$sql.= ", ".(!empty($this->note_private)?("'".$this->db->escape($this->note_private)."'"):"NULL");
$sql.= ", ".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL");
$sql.= ", ".$user->id;
@@ -455,7 +455,7 @@ class Don extends CommonObject
$sql .= ",town='".$this->db->escape($this->town)."'";
$sql .= ",fk_country = ".$this->country_id;
$sql .= ",public=".$this->public;
$sql .= ",fk_project=".($this->fk_project>0?$this->fk_project:'null');
$sql .= ",fk_projet=".($this->fk_projet>0?$this->fk_projet:'null');
$sql .= ",note_private=".(!empty($this->note_private)?("'".$this->db->escape($this->note_private)."'"):"NULL");
$sql .= ",note_public=".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL");
$sql .= ",datedon='".$this->db->idate($this->date)."'";
@@ -601,11 +601,11 @@ class Don extends CommonObject
$sql = "SELECT d.rowid, d.datec, d.tms as datem, d.datedon,";
$sql.= " d.firstname, d.lastname, d.societe, d.amount, d.fk_statut, d.address, d.zip, d.town, ";
$sql.= " d.fk_country, d.country as country_olddata, d.public, d.amount, d.fk_payment, d.paid, d.note_private, d.note_public, cp.libelle, d.email, d.phone, ";
$sql.= " d.phone_mobile, d.fk_project,";
$sql.= " d.phone_mobile, d.fk_projet,";
$sql.= " p.title as project_label,";
$sql.= " c.code as country_code, c.label as country";
$sql.= " FROM ".MAIN_DB_PREFIX."don as d";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = d.fk_project";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = d.fk_projet";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON cp.id = d.fk_payment";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.fk_country = c.rowid";
if (! empty($id))
@@ -647,7 +647,7 @@ class Don extends CommonObject
$this->phone = $obj->phone;
$this->phone_mobile = $obj->phone_mobile;
$this->project = $obj->project_label;
$this->fk_project = $obj->fk_project;
$this->fk_projet = $obj->fk_projet;
$this->public = $obj->public;
$this->modepaymentid = $obj->fk_payment;
$this->modepayment = $obj->libelle;
@@ -677,8 +677,8 @@ class Don extends CommonObject
/**
* Validate a promise of donation
*
* @param int $id id of donation
* @param int $userid User who validate the promise
* @param int $id id of donation
* @param int $userid User who validate the donation/promise
* @return int <0 if KO, >0 if OK
*/
function valid_promesse($id, $userid)
@@ -706,10 +706,10 @@ class Don extends CommonObject
}
/**
* Classe le don comme paye, le don a ete recu
* Classify the donation as paid, the donation was received
*
* @param int $id id du don a modifier
* @param int $modepaiement mode de paiement
* @param int $id id of donation
* @param int $modepayment mode de payment
* @return int <0 if KO, >0 if OK
*/
function set_paid($id, $modepaiement='')
@@ -741,7 +741,7 @@ class Don extends CommonObject
}
/**
* Set donation to status canceled
* Set donation to status cancelled
*
* @param int $id id of donation
* @return int <0 if KO, >0 if OK

View File

@@ -73,7 +73,7 @@ $sql = "SELECT d.rowid, d.datedon, d.firstname, d.lastname, d.societe,";
$sql.= " d.amount, d.fk_statut as statut, ";
$sql.= " p.rowid as pid, p.ref, p.title, p.public";
$sql.= " FROM ".MAIN_DB_PREFIX."don as d LEFT JOIN ".MAIN_DB_PREFIX."projet AS p";
$sql.= " ON p.rowid = d.fk_project WHERE 1 = 1";
$sql.= " ON p.rowid = d.fk_projet WHERE 1 = 1";
if ($statut >= 0)
{
$sql .= " AND d.fk_statut = ".$statut;
@@ -125,7 +125,7 @@ if ($resql)
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
print_liste_field_titre($langs->trans("Project"),$_SERVER["PHP_SELF"],"fk_project","&page=$page&statut=$statut","","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Project"),$_SERVER["PHP_SELF"],"fk_projet","&page=$page&statut=$statut","","",$sortfield,$sortorder);
}
print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"d.amount","&page=$page&statut=$statut","",'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"d.fk_statut","&page=$page&statut=$statut","",'align="right"',$sortfield,$sortorder);

View File

@@ -425,7 +425,7 @@ ALTER TABLE llx_societe_extrafields ADD UNIQUE INDEX uk_societe_extrafields (fk_
ALTER TABLE llx_don ADD COLUMN fk_country integer NOT NULL after country;
ALTER TABLE llx_don CHANGE COLUMN fk_paiement fk_payment integer;
ALTER TABLE llx_don ADD COLUMN paid smallint default 0 NOT NULL after fk_payment;
ALTER TABLE llx_don CHANGE COLUMN fk_don_projet fk_project integer NULL;
ALTER TABLE llx_don CHANGE COLUMN fk_don_projet fk_projet integer NULL;
create table llx_don_extrafields
(

View File

@@ -27,8 +27,8 @@ create table llx_don
entity integer DEFAULT 1 NOT NULL, -- multi company id
tms timestamp,
fk_statut smallint NOT NULL DEFAULT 0, -- Status of donation promise or validate
datec datetime, -- date de creation de l'enregistrement
datedon datetime, -- date du don/promesse
datec datetime, -- Create date
datedon datetime, -- Date of the donation/promise
amount real DEFAULT 0,
fk_payment integer,
paid smallint default 0 NOT NULL,
@@ -44,7 +44,7 @@ create table llx_don
phone varchar(24),
phone_mobile varchar(24),
public smallint DEFAULT 1 NOT NULL, -- Donation is public ? (0,1)
fk_project integer NULL, -- Donation is given for a project ?
fk_projet integer NULL, -- Donation is given for a project ?
fk_user_author integer NOT NULL,
fk_user_valid integer NULL,
note_private text,

View File

@@ -254,9 +254,10 @@ $listofreferent=array(
'name'=>"Donation",
'title'=>"ListDonationsAssociatedProject",
'class'=>'Don',
'margin'=>'add',
'table'=>'don',
'datefieldname'=>'date',
'disableamount'=>1,
'disableamount'=>0,
'test'=>$conf->don->enabled && $user->rights->don->lire),
);
@@ -344,7 +345,7 @@ foreach ($listofreferent as $key => $value)
print '<td width="100" align="center">'.$langs->trans("Date").'</td>';
// Thirdparty or user
print '<td>';
if ($tablename == 'expensereport_det') print $langs->trans("User");
if ($tablename == 'expensereport_det' || 'don') print $langs->trans("User");
else print $langs->trans("ThirdParty");
print '</td>';
if (empty($value['disableamount'])) print '<td align="right" width="120">'.$langs->trans("AmountHT").'</td>';
@@ -461,15 +462,26 @@ foreach ($listofreferent as $key => $value)
$tmpuser=new User($db);
$tmpuser->fetch($expensereport->fk_user_author);
print $tmpuser->getNomUrl(1,'',48);
}
else if ($tablename == 'don')
{
$tmpuser2=new User($db);
$tmpuser2->fetch($don->fk_user_author);
print $tmpuser2->getNomUrl(1,'',48);
}
print '</td>';
// Amount without tax
if (empty($value['disableamount']))
{
if ($tablename == 'don') $total_ht_by_line=$element->amount;
else
{
$total_ht_by_line=$element->total_ht;
}
print '<td align="right">';
if (! $qualifiedfortotal) print '<strike>';
print (isset($element->total_ht)?price($element->total_ht):'&nbsp;');
print (isset($total_ht_by_line)?price($total_ht_by_line):'&nbsp;');
if (! $qualifiedfortotal) print '</strike>';
print '</td>';
}
@@ -478,9 +490,14 @@ foreach ($listofreferent as $key => $value)
// Amount inc tax
if (empty($value['disableamount']))
{
if ($tablename == 'don') $total_ttc_by_line=$element->amount;
else
{
$total_ttc_by_line=$element->total_ttc;
}
print '<td align="right">';
if (! $qualifiedfortotal) print '<strike>';
print (isset($element->total_ttc)?price($element->total_ttc):'&nbsp;');
print (isset($total_ttc_by_line)?price($total_ttc_by_line):'&nbsp;');
if (! $qualifiedfortotal) print '</strike>';
print '</td>';
}
@@ -496,11 +513,11 @@ foreach ($listofreferent as $key => $value)
if ($qualifiedfortotal)
{
$total_ht = $total_ht + $element->total_ht;
$total_ttc = $total_ttc + $element->total_ttc;
$total_ht = $total_ht + $total_ht_by_line;
$total_ttc = $total_ttc + $total_ttc_by_line;
$total_ht_by_third += $element->total_ht;
$total_ttc_by_third += $element->total_ttc;
$total_ht_by_third += $total_ht_by_line;
$total_ttc_by_third += $total_ttc_by_line;
}
if (canApplySubtotalOn($tablename))
@@ -619,9 +636,21 @@ foreach ($listofreferent as $key => $value)
{
$element->fetch($elementarray[$i]);
if ($tablename != 'expensereport_det') $element->fetch_thirdparty();
if ($tablename == 'don') $total_ht_by_line=$element->amount;
else
{
$total_ht_by_line=$element->total_ht;
}
$total_ht = $total_ht + $element->total_ht;
$total_ttc = $total_ttc + $element->total_ttc;
$total_ht = $total_ht + $total_ht_by_line;
if ($tablename == 'don') $total_ttc_by_line=$element->amount;
else
{
$total_ttc_by_line=$element->total_ttc;
}
$total_ttc = $total_ttc + $total_ttc_by_line;
}
// Calculate margin