diff --git a/ChangeLog b/ChangeLog index 8d5a2c3bd1d..ee7f01a682c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,7 @@ For users: - When creating a contract, sales representative are preset to user. This save 4 clicks. - Can edit several fields in bank transaction line page into one update. +- New: Enhance donation module. Add a status "canceled". - New: Usage of Jquery Notify to show result or error messages on action. - New: If a service contains subproducts, subrpoducts are decrease when service is decrease. diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index b4fea76bbff..2a9e33da566 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -223,19 +223,6 @@ class Adherent extends CommonObject } - /** - * Print list of errors - */ - function print_error_list() - { - $num = sizeof($this->error); - for ($i = 0 ; $i < $num ; $i++) - { - print "
  • " . $this->error[$i]; - } - } - - /** * Renvoie le libelle traduit de la nature d'un adherent (physique ou morale) * @param morphy Nature physique ou morale de l'adherent diff --git a/htdocs/adherents/class/adherent_options.class.php b/htdocs/adherents/class/adherent_options.class.php index 637ea29221d..5da0ec49683 100644 --- a/htdocs/adherents/class/adherent_options.class.php +++ b/htdocs/adherents/class/adherent_options.class.php @@ -64,18 +64,6 @@ class AdherentOptions $this->attribute_size = array(); } - /** - * \brief fonction qui imprime un liste d'erreurs - */ - function print_error_list() - { - $num = sizeof($this->error); - for ($i = 0 ; $i < $num ; $i++) - { - print "
  • " . $this->error[$i]; - } - } - /** * Add a new optionnal attribute * @param attrname code of attribute @@ -95,7 +83,7 @@ class AdherentOptions else { $this->error=$this->db->lasterror(); - return -1; + return -1; } } else @@ -225,7 +213,7 @@ class AdherentOptions else { $this->error=$this->db->lasterror(); - return -1; + return -1; } } else diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 9a7110eaaef..05fbe6768ab 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -61,19 +61,6 @@ class AdherentType extends CommonObject } - /** - * \brief print_error_list - */ - function print_error_list() - { - $num = sizeof($this->error); - for ($i = 0 ; $i < $num ; $i++) - { - print "
  • " . $this->error[$i]; - } - } - - /** * \brief Fonction qui permet de creer le status de l'adherent * \param userid userid de l'adherent diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index d829a0a6daa..8ba89f7e90c 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -120,7 +120,6 @@ if ($resql) $db->free($resql); print ''; print ''."\n"; - $var=true; $listofstatus=array(0,1,2,3,3,-1); $bool=false; foreach ($listofstatus as $status) @@ -136,6 +135,7 @@ if ($resql) dol_print_graph('stats',300,180,$data,1,'pie',1); print ''; } + $var=true; $bool=false; foreach ($listofstatus as $status) { diff --git a/htdocs/compta/dons/class/don.class.php b/htdocs/compta/dons/class/don.class.php index 93fa5755288..47aa79c1060 100644 --- a/htdocs/compta/dons/class/don.class.php +++ b/htdocs/compta/dons/class/don.class.php @@ -34,590 +34,654 @@ require_once(DOL_DOCUMENT_ROOT ."/core/class/commonobject.class.php"); */ class Don extends CommonObject { - var $db; - var $error; - var $element='don'; - var $table_element='don'; + var $db; + var $error; + var $element='don'; + var $table_element='don'; - var $id; - var $date; - var $amount; - var $prenom; - var $nom; - var $societe; - var $adresse; - var $cp; - var $ville; - var $pays; - var $email; - var $public; - var $fk_project; - var $modepaiement; - var $modepaiementid; - var $note; - var $statut; + var $id; + var $date; + var $amount; + var $prenom; + var $nom; + var $societe; + var $adresse; + var $cp; + var $ville; + var $pays; + var $email; + var $public; + var $fk_project; + var $modepaiement; + var $modepaiementid; + var $note; + var $statut; - var $projet; + var $projet; - /** - * \brief Constructeur - * \param DB Handler d'acces base - */ - function Don($DB) - { - global $langs; + /** + * \brief Constructeur + * \param DB Handler d'acces base + */ + function Don($DB) + { + global $langs; - $this->db = $DB ; - $this->modepaiementid = 0; + $this->db = $DB ; + $this->modepaiementid = 0; - $langs->load("donations"); - $this->labelstatut[0]=$langs->trans("DonationStatusPromiseNotValidated"); - $this->labelstatut[1]=$langs->trans("DonationStatusPromiseValidated"); - $this->labelstatut[2]=$langs->trans("DonationStatusPaid"); - $this->labelstatutshort[0]=$langs->trans("DonationStatusPromiseNotValidatedShort"); - $this->labelstatutshort[1]=$langs->trans("DonationStatusPromiseValidatedShort"); - $this->labelstatutshort[2]=$langs->trans("DonationStatusPaidShort"); - } + $langs->load("donations"); + $this->labelstatut[-1]=$langs->trans("Canceled"); + $this->labelstatut[0]=$langs->trans("DonationStatusPromiseNotValidated"); + $this->labelstatut[1]=$langs->trans("DonationStatusPromiseValidated"); + $this->labelstatut[2]=$langs->trans("DonationStatusPaid"); + $this->labelstatutshort[-1]=$langs->trans("Canceled"); + $this->labelstatutshort[0]=$langs->trans("DonationStatusPromiseNotValidatedShort"); + $this->labelstatutshort[1]=$langs->trans("DonationStatusPromiseValidatedShort"); + $this->labelstatutshort[2]=$langs->trans("DonationStatusPaidShort"); + } - /** - * \brief Retourne le libelle du statut d'un don (brouillon, validee, abandonnee, payee) - * \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long - * \return string Libelle - */ - function getLibStatut($mode=0) - { - return $this->LibStatut($this->statut,$mode); - } + /** + * \brief Retourne le libelle du statut d'un don (brouillon, validee, abandonnee, payee) + * \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long + * \return string Libelle + */ + function getLibStatut($mode=0) + { + return $this->LibStatut($this->statut,$mode); + } - /** - * \brief Renvoi le libelle d'un statut donne - * \param statut Id statut - * \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * \return string Libelle du statut - */ - function LibStatut($statut,$mode=0) - { - global $langs; + /** + * \brief Renvoi le libelle d'un statut donne + * \param statut Id statut + * \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * \return string Libelle du statut + */ + function LibStatut($statut,$mode=0) + { + global $langs; - if ($mode == 0) - { - return $this->labelstatut[$statut]; - } - if ($mode == 1) - { - return $this->labelstatutshort[$statut]; - } - if ($mode == 2) - { - if ($statut == 0) return img_picto($this->labelstatut[$statut],'statut0').' '.$this->labelstatutshort[$statut]; - if ($statut == 1) return img_picto($this->labelstatut[$statut],'statut1').' '.$this->labelstatutshort[$statut]; - if ($statut == 2) return img_picto($this->labelstatut[$statut],'statut6').' '.$this->labelstatutshort[$statut]; - } - if ($mode == 3) - { - $prefix='Short'; - if ($statut == 0) return img_picto($this->labelstatut[$statut],'statut0'); - if ($statut == 1) return img_picto($this->labelstatut[$statut],'statut1'); - if ($statut == 2) return img_picto($this->labelstatut[$statut],'statut6'); - } - if ($mode == 4) - { - if ($statut == 0) return img_picto($this->labelstatut[$statut],'statut0').' '.$this->labelstatut[$statut]; - if ($statut == 1) return img_picto($this->labelstatut[$statut],'statut1').' '.$this->labelstatut[$statut]; - if ($statut == 2) return img_picto($this->labelstatut[$statut],'statut6').' '.$this->labelstatut[$statut]; - } - if ($mode == 5) - { - $prefix='Short'; - if ($statut == 0) return $this->labelstatutshort[$statut].' '.img_picto($this->labelstatut[$statut],'statut0'); - if ($statut == 1) return $this->labelstatutshort[$statut].' '.img_picto($this->labelstatut[$statut],'statut1'); - if ($statut == 2) return $this->labelstatutshort[$statut].' '.img_picto($this->labelstatut[$statut],'statut6'); - } - } + if ($mode == 0) + { + return $this->labelstatut[$statut]; + } + if ($mode == 1) + { + return $this->labelstatutshort[$statut]; + } + if ($mode == 2) + { + if ($statut == -1) return img_picto($this->labelstatut[$statut],'statut5').' '.$this->labelstatutshort[$statut]; + if ($statut == 0) return img_picto($this->labelstatut[$statut],'statut0').' '.$this->labelstatutshort[$statut]; + if ($statut == 1) return img_picto($this->labelstatut[$statut],'statut1').' '.$this->labelstatutshort[$statut]; + if ($statut == 2) return img_picto($this->labelstatut[$statut],'statut6').' '.$this->labelstatutshort[$statut]; + } + if ($mode == 3) + { + $prefix='Short'; + if ($statut == -1) return img_picto($this->labelstatut[$statut],'statut5'); + if ($statut == 0) return img_picto($this->labelstatut[$statut],'statut0'); + if ($statut == 1) return img_picto($this->labelstatut[$statut],'statut1'); + if ($statut == 2) return img_picto($this->labelstatut[$statut],'statut6'); + } + if ($mode == 4) + { + if ($statut == -1) return img_picto($this->labelstatut[$statut],'statut5').' '.$this->labelstatut[$statut]; + if ($statut == 0) return img_picto($this->labelstatut[$statut],'statut0').' '.$this->labelstatut[$statut]; + if ($statut == 1) return img_picto($this->labelstatut[$statut],'statut1').' '.$this->labelstatut[$statut]; + if ($statut == 2) return img_picto($this->labelstatut[$statut],'statut6').' '.$this->labelstatut[$statut]; + } + if ($mode == 5) + { + $prefix='Short'; + if ($statut == -1) return $this->labelstatutshort[$statut].' '.img_picto($this->labelstatut[$statut],'statut5'); + if ($statut == 0) return $this->labelstatutshort[$statut].' '.img_picto($this->labelstatut[$statut],'statut0'); + if ($statut == 1) return $this->labelstatutshort[$statut].' '.img_picto($this->labelstatut[$statut],'statut1'); + if ($statut == 2) return $this->labelstatutshort[$statut].' '.img_picto($this->labelstatut[$statut],'statut6'); + } + } - /** - * \brief Initialise le don avec valeurs fictives alaatoire - * Sert a generer un recu de don pour l'aperu des modeles ou demo - */ - function initAsSpecimen() - { - global $conf, $user,$langs; + /** + * \brief Initialise le don avec valeurs fictives alaatoire + * Sert a generer un recu de don pour l'aperu des modeles ou demo + */ + function initAsSpecimen() + { + global $conf, $user,$langs; - // Charge tableau des id de societe socids - $socids = array(); + // Charge tableau des id de societe socids + $socids = array(); - $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe"; - $sql.= " WHERE client IN (1, 3)"; - $sql.= " AND entity = ".$conf->entity; - $sql.= " LIMIT 10"; + $sql = "SELECT rowid"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe"; + $sql.= " WHERE client IN (1, 3)"; + $sql.= " AND entity = ".$conf->entity; + $sql.= " LIMIT 10"; - $resql = $this->db->query($sql); - if ($resql) - { - $num_socs = $this->db->num_rows($resql); - $i = 0; - while ($i < $num_socs) - { - $i++; + $resql = $this->db->query($sql); + if ($resql) + { + $num_socs = $this->db->num_rows($resql); + $i = 0; + while ($i < $num_socs) + { + $i++; - $row = $this->db->fetch_row($resql); - $socids[$i] = $row[0]; - } - } + $row = $this->db->fetch_row($resql); + $socids[$i] = $row[0]; + } + } - // Initialise parametres - $this->id=0; - $this->ref = 'SPECIMEN'; - $this->specimen=1; - $this->nom = 'Doe'; - $this->prenom = 'John'; - $this->socid = $socids[$socid]; - $this->date = time(); - $this->amount = 100; - $this->public = 1; - $this->societe = 'The Company'; - $this->adresse = 'Twist road'; - $this->cp = '99999'; - $this->ville = 'Town'; - $this->note_public='SPECIMEN'; - $this->email='email@email.com'; - $this->note=''; - $this->statut=1; - } + // Initialise parametres + $this->id=0; + $this->ref = 'SPECIMEN'; + $this->specimen=1; + $this->nom = 'Doe'; + $this->prenom = 'John'; + $this->socid = $socids[$socid]; + $this->date = time(); + $this->amount = 100; + $this->public = 1; + $this->societe = 'The Company'; + $this->adresse = 'Twist road'; + $this->cp = '99999'; + $this->ville = 'Town'; + $this->note_public='SPECIMEN'; + $this->email='email@email.com'; + $this->note=''; + $this->statut=1; + } - /* - * - */ - function print_error_list() - { - $num = sizeof($this->error); - for ($i = 0 ; $i < $num ; $i++) - { - print "
  • " . $this->error[$i]; - } - } + /** + * + * + */ + function check($minimum=0) + { + $err = 0; - /* - * - * - */ - function check($minimum=0) - { - $err = 0; + if (dol_strlen(trim($this->societe)) == 0) + { + if ((dol_strlen(trim($this->nom)) + dol_strlen(trim($this->prenom))) == 0) + { + $error_string[$err] = "Vous devez saisir vos nom et prenom ou le nom de votre societe."; + $err++; + } + } - if (dol_strlen(trim($this->societe)) == 0) - { - if ((dol_strlen(trim($this->nom)) + dol_strlen(trim($this->prenom))) == 0) - { - $error_string[$err] = "Vous devez saisir vos nom et prenom ou le nom de votre societe."; - $err++; - } - } + if (dol_strlen(trim($this->adresse)) == 0) + { + $error_string[$err] = "L'adresse saisie est invalide"; + $err++; + } - if (dol_strlen(trim($this->adresse)) == 0) - { - $error_string[$err] = "L'adresse saisie est invalide"; - $err++; - } + if (dol_strlen(trim($this->cp)) == 0) + { + $error_string[$err] = "Le code postal saisi est invalide"; + $err++; + } - if (dol_strlen(trim($this->cp)) == 0) - { - $error_string[$err] = "Le code postal saisi est invalide"; - $err++; - } + if (dol_strlen(trim($this->ville)) == 0) + { + $error_string[$err] = "La ville saisie est invalide"; + $err++; + } - if (dol_strlen(trim($this->ville)) == 0) - { - $error_string[$err] = "La ville saisie est invalide"; - $err++; - } + if (dol_strlen(trim($this->email)) == 0) + { + $error_string[$err] = "L'email saisi est invalide"; + $err++; + } - if (dol_strlen(trim($this->email)) == 0) - { - $error_string[$err] = "L'email saisi est invalide"; - $err++; - } + $this->amount = trim($this->amount); - $this->amount = trim($this->amount); + $map = range(0,9); + for ($i = 0; $i < dol_strlen($this->amount) ; $i++) + { + if (!isset($map[substr($this->amount, $i, 1)] )) + { + $error_string[$err] = "Le montant du don contient un/des caractere(s) invalide(s)"; + $err++; + $amount_invalid = 1; + break; + } + } - $map = range(0,9); - for ($i = 0; $i < dol_strlen($this->amount) ; $i++) - { - if (!isset($map[substr($this->amount, $i, 1)] )) - { - $error_string[$err] = "Le montant du don contient un/des caractere(s) invalide(s)"; - $err++; - $amount_invalid = 1; - break; - } - } + if (! $amount_invalid) + { + if ($this->amount == 0) + { + $error_string[$err] = "Le montant du don est null"; + $err++; + } + else + { + if ($this->amount < $minimum && $minimum > 0) + { + $error_string[$err] = "Le montant minimum du don est de $minimum"; + $err++; + } + } + } - if (! $amount_invalid) - { - if ($this->amount == 0) - { - $error_string[$err] = "Le montant du don est null"; - $err++; - } - else - { - if ($this->amount < $minimum && $minimum > 0) - { - $error_string[$err] = "Le montant minimum du don est de $minimum"; - $err++; - } - } - } + if ($err) + { + $this->error = $error_string; + return 0; + } + else + { + return 1; + } - if ($err) - { - $this->error = $error_string; - return 0; - } - else - { - return 1; - } + } - } + /** + * Create donation record into database + * @param user Objet utilisateur qui cree le don + * @return int Id don cree si ok, <0 si ko + * TODO add numbering module for Ref + */ + function create($user) + { + global $conf; - /** - * Create donation record into database - * @param user Objet utilisateur qui cree le don - * @return int Id don cree si ok, <0 si ko - * TODO add numbering module for Ref - */ - function create($user) - { - global $conf; + $now=dol_now(); - $this->date = $this->db->idate($this->date); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."don ("; + $sql.= "datec"; + $sql.= ", entity"; + $sql.= ", amount"; + $sql.= ", fk_paiement"; + $sql.= ", prenom"; + $sql.= ", nom"; + $sql.= ", societe"; + $sql.= ", adresse"; + $sql.= ", cp"; + $sql.= ", ville"; + $sql.= ", pays"; + $sql.= ", public"; + $sql.= ", fk_don_projet"; + $sql.= ", note"; + $sql.= ", fk_user_author"; + $sql.= ", fk_user_valid"; + $sql.= ", datedon"; + $sql.= ", email"; + $sql.= ") VALUES ("; + $sql.= " '".$this->db->idate($now)."'"; + $sql.= ", ".$conf->entity; + $sql.= ", ".price2num($this->amount); + $sql.= ", ".($this->modepaiementid?$this->modepaiementid:"null"); + $sql.= ", '".$this->db->escape($this->prenom)."'"; + $sql.= ", '".$this->db->escape($this->nom)."'"; + $sql.= ", '".$this->db->escape($this->societe)."'"; + $sql.= ", '".$this->db->escape($this->adresse)."'"; + $sql.= ", '".$this->cp."'"; + $sql.= ", '".$this->db->escape($this->ville)."'"; + $sql.= ", '".$this->db->escape($this->pays)."'"; // TODO use fk_pays + $sql.= ", ".$this->public; + $sql.= ", ".($this->fk_project > 0?$this->fk_project:"null"); + $sql.= ", '".$this->db->escape($this->note)."'"; + $sql.= ", ".$user->id; + $sql.= ", null"; + $sql.= ", '".$this->db->idate($this->date)."'"; + $sql.= ", '".$this->email."'"; + $sql.= ")"; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."don ("; - $sql.= "datec"; - $sql.= ", entity"; - $sql.= ", amount"; - $sql.= ", fk_paiement"; - $sql.= ", prenom"; - $sql.= ", nom"; - $sql.= ", societe"; - $sql.= ", adresse"; - $sql.= ", cp"; - $sql.= ", ville"; - $sql.= ", pays"; - $sql.= ", public"; - $sql.= ", fk_don_projet"; - $sql.= ", note"; - $sql.= ", fk_user_author"; - $sql.= ", fk_user_valid"; - $sql.= ", datedon"; - $sql.= ", email"; - $sql.= ") VALUES ("; - $sql.= $this->db->idate(mktime()); - $sql.= ", ".$conf->entity; - $sql.= ", ".price2num($this->amount); - $sql.= ", ".$this->modepaiementid; - $sql.= ", '".$this->db->escape($this->prenom)."'"; - $sql.= ", '".$this->db->escape($this->nom)."'"; - $sql.= ", '".$this->db->escape($this->societe)."'"; - $sql.= ", '".$this->db->escape($this->adresse)."'"; - $sql.= ", '".$this->cp."'"; - $sql.= ", '".$this->db->escape($this->ville)."'"; - $sql.= ", '".$this->db->escape($this->pays)."'"; // TODO use fk_pays - $sql.= ", ".$this->public; - $sql.= ", ".($this->fk_project > 0?$this->fk_project:"null"); - $sql.= ", '".$this->db->escape($this->note)."'"; - $sql.= ", ".$user->id; - $sql.= ", null"; - $sql.= ", '".$this->date."'"; - $sql.= ", '".$this->email."'"; - $sql.= ")"; + dol_syslog("Don::create sql=".$sql, LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + return $this->db->last_insert_id(MAIN_DB_PREFIX."don"); + } + else + { + dol_print_error($this->db); + return -1; + } + } - dol_syslog("Don::create sql=".$sql, LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { - return $this->db->last_insert_id(MAIN_DB_PREFIX."don"); - } - else - { - dol_print_error($this->db); - return -1; - } - } + /** + * Update a donation record + * @param user Objet utilisateur qui met a jour le don + * @return int >0 if OK, <0 if KO + */ + function update($user) + { - /** - * Update a donation record - * @param user Objet utilisateur qui met a jour le don - * @return int >0 si ok, <0 si ko - */ - function update($user) - { + $sql = "UPDATE ".MAIN_DB_PREFIX."don SET "; + $sql .= "amount = " . price2num($this->amount); + $sql .= ",fk_paiement = ".($this->modepaiementid?$this->modepaiementid:"null"); + $sql .= ",prenom = '".$this->db->escape($this->prenom)."'"; + $sql .= ",nom='".$this->db->escape($this->nom)."'"; + $sql .= ",societe='".$this->db->escape($this->societe)."'"; + $sql .= ",adresse='".$this->db->escape($this->adresse)."'"; + $sql .= ",cp='".$this->cp."'"; + $sql .= ",ville='".$this->db->escape($this->ville)."'"; + $sql .= ",pays='".$this->db->escape($this->pays)."'"; // TODO use fk_pays + $sql .= ",public=".$this->public; + $sql .= ",fk_don_projet=".($this->fk_project>0?$this->fk_project:'null'); + $sql .= ",note='".$this->db->escape($this->note)."'"; + $sql .= ",datedon='".$this->db->idate($this->date)."'"; + $sql .= ",email='".$this->email."'"; + $sql .= ",fk_statut=".$this->statut; + $sql .= " WHERE rowid = $this->id"; - $this->date = $this->db->idate($this->date); + dol_syslog("Don::update sql=".$sql); + $result = $this->db->query($sql); + if ($result) + { + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } + } - $sql = "UPDATE ".MAIN_DB_PREFIX."don SET "; - $sql .= "amount = " . price2num($this->amount); - $sql .= ",fk_paiement = ".$this->modepaiementid; - $sql .= ",prenom = '".$this->db->escape($this->prenom)."'"; - $sql .= ",nom='".$this->db->escape($this->nom)."'"; - $sql .= ",societe='".$this->db->escape($this->societe)."'"; - $sql .= ",adresse='".$this->db->escape($this->adresse)."'"; - $sql .= ",cp='".$this->cp."'"; - $sql .= ",ville='".$this->db->escape($this->ville)."'"; - $sql .= ",pays='".$this->db->escape($this->pays)."'"; // TODO use fk_pays - $sql .= ",public=".$this->public; - $sql .= ",fk_don_projet=".($this->fk_project>0?$this->fk_project:'null'); - $sql .= ",note='".$this->db->escape($this->note)."'"; - $sql .= ",datedon='".$this->date."'"; - $sql .= ",email='".$this->email."'"; - $sql .= ",fk_statut=".$this->statut; + /* + * Suppression du don de la base + * @param rowid id du don a supprimer + */ + function delete($rowid) + { - $sql .= " WHERE rowid = $this->id"; - - dol_syslog("Don::update sql=".$sql); - $result = $this->db->query($sql); - if ($result) - { - return 1; - } - else - { - dol_print_error($this->db); - return -1; - } - } - - /* - * \brief Suppression du don de la base - * \param rowid id du don a supprimer - */ - function delete($rowid) - { - - $sql = "DELETE FROM ".MAIN_DB_PREFIX."don WHERE rowid = $rowid AND fk_statut = 0;"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."don WHERE rowid = $rowid AND fk_statut = 0;"; $resql=$this->db->query($sql); - if ($resql) - { - if ( $this->db->affected_rows($resql) ) - { - return 1; - } - else - { - return -1; - } - } - else - { - dol_print_error($this->db); - return -1; - } - } + if ($resql) + { + if ( $this->db->affected_rows($resql) ) + { + return 1; + } + else + { + return -1; + } + } + else + { + dol_print_error($this->db); + return -1; + } + } - /* - * \brief Charge l'objet don en memoire depuis la base de donnee - * \param rowid Id du don a charger - * \return int <0 si ko, >0 si ok - */ - function fetch($rowid) - { - $sql = "SELECT d.rowid, d.datec,"; - $sql.= " d.datedon,"; - $sql.= " d.prenom, d.nom, d.societe, d.amount, d.fk_statut, d.adresse, d.cp, d.ville, d.pays, d.public, d.amount, d.fk_paiement, d.note, cp.libelle, d.email, d.fk_don_projet,"; - $sql.= " p.title as project_label"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_paiement as cp, ".MAIN_DB_PREFIX."don as d"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p"; - $sql.= " ON p.rowid = d.fk_don_projet"; - $sql.= " WHERE cp.id = d.fk_paiement AND d.rowid = ".$rowid; + /** + * Load donation from database + * @param rowid Id of donation toload + * @return int <0 if KO, >0 if OK + */ + function fetch($rowid,$ref='') + { + global $conf; - dol_syslog("Don::fetch sql=".$sql); - $resql=$this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + $sql = "SELECT d.rowid, d.datec, d.tms as datem, d.datedon,"; + $sql.= " d.prenom, d.nom, d.societe, d.amount, d.fk_statut, d.adresse, d.cp, d.ville, d.pays, d.public, d.amount, d.fk_paiement, d.note, cp.libelle, d.email, d.fk_don_projet,"; + $sql.= " p.title as project_label"; + $sql.= " FROM ".MAIN_DB_PREFIX."don as d"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = d.fk_don_projet"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON cp.id = d.fk_paiement"; + $sql.= " WHERE d.rowid = ".$rowid." AND d.entity = ".$conf->entity; - $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->datec = $this->db->jdate($obj->datec); - $this->date = $this->db->jdate($obj->datedon); - $this->prenom = $obj->prenom; - $this->nom = $obj->nom; - $this->societe = $obj->societe; - $this->statut = $obj->fk_statut; - $this->adresse = $obj->adresse; - $this->cp = $obj->cp; - $this->ville = $obj->ville; - $this->email = $obj->email; - $this->pays = $obj->pays; - $this->projet = $obj->project_label; - $this->fk_project = $obj->fk_don_projet; - $this->public = $obj->public; - $this->modepaiementid = $obj->fk_paiement; - $this->modepaiement = $obj->libelle; - $this->amount = $obj->amount; - $this->note = $obj->note; - $this->commentaire = $obj->note; // deprecated - } - return 1; - } - else - { - dol_print_error($this->db); - return -1; - } + dol_syslog("Don::fetch sql=".$sql); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - } + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->datec = $this->db->jdate($obj->datec); + $this->datem = $this->db->jdate($obj->datem); + $this->date = $this->db->jdate($obj->datedon); + $this->prenom = $obj->prenom; + $this->nom = $obj->nom; + $this->societe = $obj->societe; + $this->statut = $obj->fk_statut; + $this->adresse = $obj->adresse; + $this->cp = $obj->cp; + $this->ville = $obj->ville; + $this->zip = $obj->cp; + $this->town = $obj->ville; + $this->email = $obj->email; + $this->pays = $obj->pays; + $this->projet = $obj->project_label; + $this->fk_project = $obj->fk_don_projet; + $this->public = $obj->public; + $this->modepaiementid = $obj->fk_paiement; + $this->modepaiement = $obj->libelle; + $this->amount = $obj->amount; + $this->note = $obj->note; + $this->commentaire = $obj->note; // deprecated + } + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } - /* - * \brief Valide une promesse de don - * \param rowid id du don a modifier - * \param userid utilisateur qui valide la promesse - * - */ - function valid_promesse($rowid, $userid) - { + } - $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 1, fk_user_valid = $userid WHERE rowid = $rowid AND fk_statut = 0;"; + /** + * Valide une promesse de don + * @param rowid id du don a modifier + * @param userid utilisateur qui valide la promesse + * @return int <0 if KO, >0 if OK + */ + function valid_promesse($rowid, $userid) + { + + $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 1, fk_user_valid = $userid WHERE rowid = $rowid AND fk_statut = 0"; + + dol_syslog("sql=".$sql); + $resql=$this->db->query($sql); + if ($resql) + { + if ( $this->db->affected_rows($resql) ) + { + return 1; + } + else + { + return 0; + } + } + else + { + dol_print_error($this->db); + return -1; + } + } + + /** + * Classe le don comme paye, le don a ete recu + * @param rowid id du don a modifier + * @param modepaiementd mode de paiement + * @return int <0 if KO, >0 if OK + */ + function set_paye($rowid, $modepaiement='') + { + $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2"; + if ($modepaiement) + { + $sql .= ", fk_paiement=$modepaiement"; + } + $sql .= " WHERE rowid = $rowid AND fk_statut = 1"; + + dol_syslog("sql=".$sql); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->affected_rows($resql)) + { + return 1; + } + else + { + return 0; + } + } + else + { + dol_print_error($this->db); + return -1; + } + } + + + /** + * Classe le don comme encaisse + * @param rowid id du don a modifier + * @return int <0 if KO, >0 if OK + */ + function set_encaisse($rowid) + { + + $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 3 WHERE rowid = $rowid AND fk_statut = 2"; + + dol_syslog("sql=".$sql); + $resql=$this->db->query($sql); + if ($resql) + { + if ( $this->db->affected_rows($resql) ) + { + return 1; + } + else + { + return 0; + } + } + else + { + dol_print_error($this->db); + return -1; + } + } + + /** + * Set donation sto status canceled + * @param rowid id du don a modifier + * @return int <0 if KO, >0 if OK + */ + function set_cancel($rowid) + { + $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = -1 WHERE rowid = ".$rowid; + + dol_syslog("sql=".$sql); + $resql=$this->db->query($sql); + if ($resql) + { + if ( $this->db->affected_rows($resql) ) + { + return 1; + } + else + { + return 0; + } + } + else + { + dol_print_error($this->db); + return -1; + } + } + + /** + * \brief Somme des dons + * \param param 1=promesses de dons validees , 2=xxx, 3=encaisses + */ + function sum_donations($param) + { + global $conf; + + $result=0; + + $sql = "SELECT sum(amount) as total"; + $sql.= " FROM ".MAIN_DB_PREFIX."don"; + $sql.= " WHERE fk_statut = ".$param; + $sql.= " AND entity = ".$conf->entity; $resql=$this->db->query($sql); - if ($resql) - { - if ( $this->db->affected_rows($resql) ) - { - return 1; - } - else - { - return 0; - } - } - else - { - dol_print_error($this->db); - return 0; - } - } + if ($resql) + { + $obj = $this->db->fetch_object($resql); + $result=$obj->total; + } - /* - * \brief Classe le don comme paye, le don a ete recu - * \param rowid id du don a modifier - * \param modepaiementd mode de paiement - */ - function set_paye($rowid, $modepaiement='') - { - $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2"; - - if ($modepaiement) - { - $sql .= ", fk_paiement=$modepaiement"; - } - $sql .= " WHERE rowid = $rowid AND fk_statut = 1;"; - - $resql=$this->db->query($sql); - if ($resql) - { - if ($this->db->affected_rows($resql)) - { - return 1; - } - else - { - return 0; - } - } - else - { - dol_print_error($this->db); - return 0; - } - } + return $result; + } - /* - * \brief Classe le don comme encaisse - * \param rowid id du don a modifier - * - */ - function set_encaisse($rowid) - { + /** + * \brief Return clicable name (with picto eventually) + * \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul + * \return string Chaine avec URL + */ + function getNomUrl($withpicto=0) + { + global $langs; - $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 3 WHERE rowid = $rowid AND fk_statut = 2;"; + $result=''; - $resql=$this->db->query($sql); - if ($resql) - { - if ( $this->db->affected_rows($resql) ) - { - return 1; - } - else - { - return 0; - } - } - else - { - dol_print_error($this->db); - return 0; - } - } + $lien = ''; + $lienfin=''; - /** - * \brief Somme des dons - * \param param 1=promesses de dons validees , 2=xxx, 3=encaisses - */ - function sum_donations($param) - { - global $conf; + $picto='generic'; - $result=0; + $label=$langs->trans("ShowDonation").': '.$this->ref; - $sql = "SELECT sum(amount) as total"; - $sql.= " FROM ".MAIN_DB_PREFIX."don"; - $sql.= " WHERE fk_statut = ".$param; - $sql.= " AND entity = ".$conf->entity; + if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); + if ($withpicto && $withpicto != 2) $result.=' '; + if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin; + return $result; + } - $resql=$this->db->query($sql); - if ($resql) - { - $obj = $this->db->fetch_object($resql); - $result=$obj->total; - } + /** + * Return full name (civility+' '+name+' '+lastname) + * @param langs Language object for translation of civility + * @param option 0=No option, 1=Add civility + * @param nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname + * @return string String with full name + */ + function getFullName($langs,$option=0,$nameorder=-1) + { + global $conf; - return $result; - } + $ret=''; + if ($option && $this->civilite_id) + { + if ($langs->transnoentitiesnoconv("Civility".$this->civilite_id)!="Civility".$this->civilite_id) $ret.=$langs->transnoentitiesnoconv("Civility".$this->civilite_id).' '; + else $ret.=$this->civilite_id.' '; + } + // If order not defined, we use the setup + if ($nameorder < 0) $nameorder=(! $conf->global->MAIN_FIRSTNAME_NAME_POSITION); - /** - * \brief Return clicable name (with picto eventually) - * \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul - * \return string Chaine avec URL - */ - function getNomUrl($withpicto=0) - { - global $langs; + if ($nameorder) + { + if ($this->prenom) $ret.=$this->prenom; + if ($this->prenom && $this->nom) $ret.=' '; + if ($this->nom) $ret.=$this->nom; + } + else + { + if ($this->nom) $ret.=$this->nom; + if ($this->prenom && $this->nom) $ret.=' '; + if ($this->prenom) $ret.=$this->prenom; + } - $result=''; - - $lien = ''; - $lienfin=''; - - $picto='generic'; - - $label=$langs->trans("ShowDonation").': '.$this->ref; - - if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); - if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$lien.$this->ref.$lienfin; - return $result; - } + return trim($ret); + } } ?> diff --git a/htdocs/compta/dons/fiche.php b/htdocs/compta/dons/fiche.php index 59f4b13b562..aaec1ec6d6a 100644 --- a/htdocs/compta/dons/fiche.php +++ b/htdocs/compta/dons/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2004-2011 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,13 +20,14 @@ /** * \file htdocs/compta/dons/fiche.php * \ingroup don - * \brief Page de fiche de don + * \brief Page of donation card * \version $Id$ */ require("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/includes/modules/dons/modules_don.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); +require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php"); require_once(DOL_DOCUMENT_ROOT."/compta/dons/class/don.class.php"); require_once(DOL_DOCUMENT_ROOT."/compta/paiement/class/paiement.class.php"); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/lib/project.lib.php'); @@ -36,6 +37,7 @@ $langs->load("donations"); $langs->load("bills"); $mesg=""; +$mesgs=array(); $don = new Don($db); $donation_date=dol_mktime(12, 0 , 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); @@ -55,18 +57,18 @@ if ($_POST["action"] == 'update') $error=0; + if (empty($donation_date)) + { + $mesgs[]=$langs->trans("ErrorFieldRequired",$langs->trans("Date")); + $_GET["action"] = "create"; + $error++; + } + if (! $_POST["amount"] > 0) { - $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Amount")); + $mesgs[]=$langs->trans("ErrorFieldRequired",$langs->trans("Amount")); $_GET["action"] = "create"; - $error=1; - } - - if (empty($donation_date)) - { - $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Date")); - $_GET["action"] = "create"; - $error=1; + $error++; } if (! $error) @@ -79,8 +81,10 @@ if ($_POST["action"] == 'update') $don->societe = $_POST["societe"]; $don->adresse = $_POST["adresse"]; $don->amount = price2num($_POST["amount"]); - $don->cp = $_POST["cp"]; - $don->ville = $_POST["ville"]; + $don->cp = $_POST["zipcode"]; + $don->ville = $_POST["town"]; + $don->zip = $_POST["zipcode"]; + $don->town = $_POST["town"]; $don->email = $_POST["email"]; $don->date = $donation_date; $don->note = $_POST["note"]; @@ -108,18 +112,18 @@ if ($_POST["action"] == 'add') $error=0; + if (empty($donation_date)) + { + $mesgs[]=$langs->trans("ErrorFieldRequired",$langs->trans("Date")); + $_GET["action"] = "create"; + $error++; + } + if (! $_POST["amount"] > 0) { - $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Amount")); + $mesgs[]=$langs->trans("ErrorFieldRequired",$langs->trans("Amount")); $_GET["action"] = "create"; - $error=1; - } - - if (empty($donation_date)) - { - $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Date")); - $_GET["action"] = "create"; - $error=1; + $error++; } if (! $error) @@ -129,8 +133,10 @@ if ($_POST["action"] == 'add') $don->societe = $_POST["societe"]; $don->adresse = $_POST["adresse"]; $don->amount = price2num($_POST["amount"]); - $don->cp = $_POST["cp"]; - $don->ville = $_POST["ville"]; + $don->cp = $_POST["zipcode"]; + $don->ville = $_POST["town"]; + $don->zip = $_POST["zipcode"]; + $don->town = $_POST["town"]; $don->email = $_POST["email"]; $don->date = $donation_date; $don->note = $_POST["note"]; @@ -162,27 +168,39 @@ if ($_POST["action"] == 'commentaire') } if ($_GET["action"] == 'valid_promesse') { - if ($don->valid_promesse($_GET["rowid"], $user->id)) + if ($don->valid_promesse($_GET["rowid"], $user->id) >= 0) { Header("Location: fiche.php?rowid=".$_GET["rowid"]); exit; } + else $mesg=$don->error; +} +if ($_GET["action"] == 'set_cancel') +{ + if ($don->set_cancel($_GET["rowid"]) >= 0) + { + Header("Location: fiche.php?rowid=".$_GET["rowid"]); + exit; + } + else $mesg=$don->error; } if ($_GET["action"] == 'set_paid') { - if ($don->set_paye($_GET["rowid"], $modepaiement)) + if ($don->set_paye($_GET["rowid"], $modepaiement) >= 0) { Header("Location: fiche.php?rowid=".$_GET["rowid"]); exit; } + else $mesg=$don->error; } if ($_GET["action"] == 'set_encaisse') { - if ($don->set_encaisse($_GET["rowid"])) + if ($don->set_encaisse($_GET["rowid"]) >= 0) { - Header("Location: liste.php"); + Header("Location: fiche.php?rowid=".$_GET["rowid"]); exit; } + else $mesg=$don->error; } /* @@ -230,6 +248,7 @@ llxHeader('',$langs->trans("Donations"),'EN:Module_Donations|FR:Module_Dons|ES:M $html=new Form($db); $formfile = new FormFile($db); +$htmlcompany = new FormCompany($db); /* ************************************************************************** */ @@ -242,7 +261,7 @@ if ($_GET["action"] == 'create') { print_fiche_titre($langs->trans("AddDonation")); - if ($mesg) print '
    '.$mesg.'
    '; + dol_htmloutput_errors($mesg,$mesgs); print '
    '; print ''; @@ -250,28 +269,20 @@ if ($_GET["action"] == 'create') print ''; - // Date + $nbrows=11; + if ($conf->projet->enabled) $nbrows++; + + // Date print '
  • '; - $nbrows=11; - if ($conf->projet->enabled) $nbrows++; + print '"; + print ""; - print '"; - - print "\n"; - - if ($conf->projet->enabled) - { - // Si module projet actif - print "\n"; - } + // Amount + print "".''; print '".''; print "".''; - print "".''; + + // Zip / Town + print ''; + print "".''; print "".''; - print "".''; + + print "\n"; + + if ($conf->projet->enabled) + { + // Si module projet actif + print "\n"; + } + print "
    '.$langs->trans("Statistics").' - '.$langs->trans("CustomersOrders").'
    '.$langs->trans("Date").''; $html->select_date($donation_date?$donation_date:-1,'','','','',"add",1,1); print ''.$langs->trans("Comments").' :
    '; + print "
    '.$langs->trans("Comments").' :
    '; - print "
    ".$langs->trans("PaymentMode")."\n"; - $html->select_types_paiements('', 'modepaiement', 'CRDT', 0); - print "
    ".$langs->trans("Project").""; - select_projects('',$_POST["projectid"],"projectid"); - print "
    '.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->monnaie).'
    '.$langs->trans("PublicDonation").""; print $html->selectyesno("public",isset($_POST["public"])?$_POST["public"]:1,1); @@ -282,10 +293,29 @@ if ($_GET["action"] == 'create') print "
    '.$langs->trans("Lastname").'
    '.$langs->trans("Address").''; print '
    '.$langs->trans("Zip").' / '.$langs->trans("Town").'
    '.$langs->trans("Zip").' / '.$langs->trans("Town").''; + print $htmlcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$don->zip),'zipcode',array('town','selectpays_id','departement_id'),6); + print ' '; + print $htmlcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$don->town),'town',array('zipcode','selectpays_id','departement_id')); + print '
    '.$langs->trans("Country").'
    '.$langs->trans("EMail").'
    '.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->monnaie).'
    ".$langs->trans("PaymentMode")."\n"; + $html->select_types_paiements('', 'modepaiement', 'CRDT', 0, 1); + print "
    ".$langs->trans("Project").""; + select_projects('',$_POST["projectid"],"projectid"); + print "
    \n"; print '
       
    '; print "\n"; @@ -324,25 +354,20 @@ if ($_GET["rowid"] && $_GET["action"] == 'edit') print ''; print ''; - // Date - print "".''.$langs->trans("Date").''; + $nbrows=12; + if ($conf->projet->enabled) $nbrows++; + + // Date + print "".''.$langs->trans("Date").''; $html->select_date($don->date,'','','','',"update"); print ''; - $nbrows=12; - if ($conf->projet->enabled) $nbrows++; + print ''.$langs->trans("Comments").' :
    '; + print ""; + print ""; - print ''.$langs->trans("Comments").' :
    '; - print ""; - - // Project - if ($conf->projet->enabled) - { - $langs->load('projects'); - print ''.$langs->trans('Project').''; - select_projects($soc->id, isset($_POST["projectid"])?$_POST["projectid"]:$don->fk_project, 'projectid'); - print ''; - } + // Amount + print "".''.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->monnaie).''; print ''.$langs->trans("PublicDonation").""; print $html->selectyesno("public",1,1); @@ -355,17 +380,32 @@ if ($_GET["rowid"] && $_GET["action"] == 'edit') print "".''.$langs->trans("Lastname").''; print "".''.$langs->trans("Address").''; print ''; - print "".''.$langs->trans("Zip").' / '.$langs->trans("Town").' '; + + // Zip / Town + print ''.$langs->trans("Zip").' / '.$langs->trans("Town").''; + print $htmlcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$don->zip),'zipcode',array('town','selectpays_id','departement_id'),6); + print ' '; + print $htmlcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$don->town),'town',array('zipcode','selectpays_id','departement_id')); + print ''; + print "".''.$langs->trans("Country").''; print "".''.$langs->trans("EMail").''; - print "".''.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->monnaie).''; - print "".$langs->trans("PaymentMode")."\n"; - $html->select_types_paiements('', 'modepaiement', 'CRDT', 0); - print "\n"; + print "".$langs->trans("PaymentMode")."\n"; + $html->select_types_paiements('', 'modepaiement', 'CRDT', 0, 1); + print "\n"; print "".''.$langs->trans("Status").''.$don->getLibStatut(4).''; + // Project + if ($conf->projet->enabled) + { + $langs->load('projects'); + print ''.$langs->trans('Project').''; + select_projects($soc->id, isset($_POST["projectid"])?$_POST["projectid"]:$don->fk_project, 'projectid'); + print ''; + } + print "\n"; print '
       
    '; @@ -385,7 +425,7 @@ if ($_GET["rowid"] && $_GET["action"] == 'edit') if ($_GET["rowid"] && $_GET["action"] != 'edit') { $don->id = $_GET["rowid"]; - $don->fetch($_GET["rowid"]); + $result=$don->fetch($_GET["rowid"]); $h=0; @@ -400,6 +440,9 @@ if ($_GET["rowid"] && $_GET["action"] != 'edit') print ''; print ''; + $nbrows=12; + if ($conf->projet->enabled) $nbrows++; + // Ref print "".''; // Date - print ""; - $nbrows=12; - if ($conf->projet->enabled) $nbrows++; - - print ''; - // Project - if ($conf->projet->enabled) - { - print "".''; - } + print "".''; print "".''; print "".''; print "".''; - print "".''; - print "".''; + print "".''; + + // Zip / Town + print "".''; + + // Country print "".''; - print "".''; - print "".''; + + // EMail + print "".''; + + // Payment mode print "\n"; print "".''; + // Project + if ($conf->projet->enabled) + { + print "".''; + } + print "
    '.$langs->trans("Ref").''; print $html->showrefnav($don,'rowid','',1,'rowid','ref',''); @@ -407,21 +450,14 @@ if ($_GET["rowid"] && $_GET["action"] != 'edit') print '
    ".$langs->trans("Date").""; + print '
    '.$langs->trans("Date").''; print dol_print_date($don->date,"day"); print "'.$langs->trans("Comments").' :
    '; + print '
    '.$langs->trans("Comments").' :
    '; print nl2br($don->note).'
    '.$langs->trans("Project").''.$don->projet.'
    '.$langs->trans("Amount").''.price($don->amount).' '.$langs->trans("Currency".$conf->monnaie).'
    ".$langs->trans("PublicDonation").""; print yn($don->public); @@ -430,17 +466,30 @@ if ($_GET["rowid"] && $_GET["action"] != 'edit') print "
    '.$langs->trans("Company").''.$don->societe.'
    '.$langs->trans("Firstname").''.$don->prenom.'
    '.$langs->trans("Lastname").''.$don->nom.'
    '.$langs->trans("Address").''.nl2br($don->adresse).'
    '.$langs->trans("Zip").' / '.$langs->trans("Town").''.$don->cp.' '.$don->ville.'
    '.$langs->trans("Address").''.dol_nl2br($don->adresse).'
    '.$langs->trans("Zip").' / '.$langs->trans("Town").''.$don->cp.($don->cp && $don->ville?' / ':'').$don->ville.'
    '.$langs->trans("Country").''.$don->pays.'
    '.$langs->trans("EMail").''.$don->email.'
    '.$langs->trans("Amount").''.price($don->amount).' '.$langs->trans("Currency".$conf->monnaie).'
    '.$langs->trans("EMail").''.dol_print_email($don->email).'
    ".$langs->trans("PaymentMode").""; print $don->modepaiement; print "
    '.$langs->trans("Status").''.$don->getLibStatut(4).'
    '.$langs->trans("Project").''.$don->projet.'
    \n"; print "\n"; @@ -462,6 +511,11 @@ if ($_GET["rowid"] && $_GET["action"] != 'edit') print ''.$langs->trans("ValidPromess").''; } + if (($don->statut == 0 || $don->statut == 1) && $resteapayer == 0 && $don->paye == 0) + { + print "id&action=set_cancel\">".$langs->trans("ClassifyCanceled").""; + } + // TODO Gerer action emettre paiement if ($don->statut == 1 && $resteapayer > 0) { diff --git a/htdocs/compta/dons/index.php b/htdocs/compta/dons/index.php index e38e1506c88..f36059e3703 100644 --- a/htdocs/compta/dons/index.php +++ b/htdocs/compta/dons/index.php @@ -29,6 +29,15 @@ require_once(DOL_DOCUMENT_ROOT."/compta/dons/class/don.class.php"); $langs->load("donations"); +$donation_static=new Don($db); + + +/* + * Actions + */ + + + /* * View @@ -67,29 +76,47 @@ print_fiche_titre($langs->trans("DonationsArea")); print ''; -print '
    '; +// Left area +print '
    '; -print ''; +print '
    '; +print ''; +print ''; +print "\n"; + +$listofstatus=array(0,1,-1,2); +foreach ($listofstatus as $status) +{ + $dataseries[]=array('label'=>$donstatic->LibStatut($status,1),'values'=>array(0=>(isset($nb[$status])?$nb[$status]:0))); +} + +if ($conf->use_javascript_ajax) +{ + print ''; +} + print ''; print ''; print ''; -print ''; +print ''; print ''; -print "\n"; +print ''; -$var=True; - -for ($i = 0 ; $i < 3 ; $i++) +$var=true; +foreach ($listofstatus as $status) { $var=!$var; - print ""; - print ''; - print ''; - print ''; - print ''; - $totalnb += $nb[$i]; - $total += $somme[$i]; + print ""; + print ''; + print ''; + print ''; + print ''; + $totalnb += $nb[$status]; + $total += $somme[$status]; print ""; } @@ -102,6 +129,75 @@ print ''; print "
    '.$langs->trans("Statistics").'
    '; + $data=array('series'=>$dataseries); + dol_print_graph('stats',300,180,$data,1,'pie',1); + print '
    '.$langs->trans("Status").''.$langs->trans("Number").''.$langs->trans("AmountTotal").''.$langs->trans("Total").''.$langs->trans("Average").'
    '.$donstatic->LibStatut($i,4).''.$nb[$i].''.($nb[$i]?price($somme[$i],'MT'):' ').''.($nb[$i]?price(price2num($somme[$i]/$nb[$i],'MT')):' ').'
    '.$donstatic->LibStatut($status,4).''.$nb[$status].''.($nb[$status]?price($somme[$status],'MT'):' ').''.($nb[$status]?price(price2num($somme[$status]/$nb[$status],'MT')):' ').'
    "; +// Right area +print '
    '; + + + +$max=5; + +/* + * Last modified proposals + */ + +$sql = "SELECT c.rowid, c.ref, c.fk_statut, c.societe, c.nom,"; +$sql.= " tms as datem, amount"; +$sql.= " FROM ".MAIN_DB_PREFIX."don as c"; +$sql.= " WHERE c.entity = ".$conf->entity; +//$sql.= " AND c.fk_statut > 2"; +$sql.= " ORDER BY c.tms DESC"; +$sql.= $db->plimit($max, 0); + +$resql=$db->query($sql); +if ($resql) +{ + print ''; + print ''; + print ''; + + $num = $db->num_rows($resql); + if ($num) + { + $i = 0; + $var = True; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object($resql); + + print ""; + + $donation_static->id=$obj->rowid; + $donation_static->ref=$obj->ref?$obj->ref:$obj->rowid; + + print ''; + + print ''; + + print ''; + + // Date + print ''; + + print ''; + + print ''; + $i++; + } + } + print "
    '.$langs->trans("LastModifiedDonations",$max).'
    '; + print $donation_static->getNomUrl(1); + print ''; + print $obj->societe; + print ($obj->societe && $obj->nom?' / ':''); + print $obj->nom; + print ''; + print price($obj->amount); + print ''.dol_print_date($db->jdate($obj->datec),'day').''.$donation_static->LibStatut($obj->fk_statut,5).'

    "; +} +else dol_print_error($db); + + print '
    '; $db->close(); diff --git a/htdocs/compta/dons/liste.php b/htdocs/compta/dons/liste.php index 3e76a09a49f..5fc23365076 100644 --- a/htdocs/compta/dons/liste.php +++ b/htdocs/compta/dons/liste.php @@ -74,31 +74,33 @@ if ($result) $num = $db->num_rows($result); $i = 0; + $param="&statut=$statut&sortorder=$sortorder&sortfield=$sortfield"; + if ($statut >= 0) { $donationstatic->statut=$statut; $label=$donationstatic->getLibStatut(0); - print_barre_liste($label, $page, "liste.php", "&statut=$statut&sortorder=$sortorder&sortfield=$sortfield"); + print_barre_liste($label, $page, $_SERVER["PHP_SELF"], $param, '', '', '', $num); } else { - print_barre_liste($langs->trans("Donations"), $page, "liste.php", "&statut=$statut&sortorder=$sortorder&sortfield=$sortfield"); + print_barre_liste($langs->trans("Donations"), $page, $_SERVER["PHP_SELF"], $param, '', '', '', $num); } - print ""; + + print "
    "; print ''; - print_liste_field_titre($langs->trans("Ref"),"liste.php","d.rowid","&page=$page&statut=$statut","","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Firstname"),"liste.php","d.prenom","&page=$page&statut=$statut","","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Name"),"liste.php","d.nom","&page=$page&statut=$statut","","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Company"),"liste.php","d.societe","&page=$page&statut=$statut","","",$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Date"),"liste.php","d.datedon","&page=$page&statut=$statut","",'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"d.rowid","&page=$page&statut=$statut","","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"d.societe","&page=$page&statut=$statut","","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Name"),$_SERVER["PHP_SELF"],"d.nom","&page=$page&statut=$statut","","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"d.datedon","&page=$page&statut=$statut","",'align="center"',$sortfield,$sortorder); if ($conf->projet->enabled) { $langs->load("projects"); - print_liste_field_titre($langs->trans("Project"),"liste.php","projet","&page=$page&statut=$statut","","",$sortfield,$sortorder); + print_liste_field_titre($langs->trans("Project"),$_SERVER["PHP_SELF"],"fk_don_projet","&page=$page&statut=$statut","","",$sortfield,$sortorder); } - print_liste_field_titre($langs->trans("Amount"),"liste.php","d.amount","&page=$page&statut=$statut","",'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Status"),"liste.php","d.statut","&page=$page&statut=$statut","",'align="right"',$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); print "\n"; $var=True; @@ -109,11 +111,12 @@ if ($result) print ""; $donationstatic->id=$objp->rowid; $donationstatic->ref=$objp->rowid; + $donationstatic->nom=$objp->nom; + $donationstatic->prenom=$objp->prenom; print "\n"; - print "\n"; - print "\n"; - print "\n"; - print ''; + print "\n"; + print "\n"; + print ''; if ($conf->projet->enabled) { print "
    ".$donationstatic->getNomUrl(1)."".$objp->prenom."".$objp->nom."".$objp->societe."'.dol_print_date($db->jdate($objp->datedon)).'".$objp->societe."".$donationstatic->getFullName($langs)."'.dol_print_date($db->jdate($objp->datedon),'day').'"; diff --git a/htdocs/langs/en_US/donations.lang b/htdocs/langs/en_US/donations.lang index e5a5b85c8d4..bed06b63495 100644 --- a/htdocs/langs/en_US/donations.lang +++ b/htdocs/langs/en_US/donations.lang @@ -23,3 +23,4 @@ DonationStatusPaidShort=Received ValidPromess=Validate promise BuildDonationReceipt=Build receipt DonationsModels=Documents models for donation receipts +LastModifiedDonations=Last %s modified donations \ No newline at end of file diff --git a/htdocs/langs/fr_FR/donations.lang b/htdocs/langs/fr_FR/donations.lang index aa5d1de6807..b7e26c7a739 100644 --- a/htdocs/langs/fr_FR/donations.lang +++ b/htdocs/langs/fr_FR/donations.lang @@ -22,4 +22,5 @@ DonationStatusPromiseValidatedShort=Validée DonationStatusPaidShort=Payé ValidPromess=Valider promesse BuildDonationReceipt=Créer reçu -DonationsModels=Modèle de document de bon de réception de dons \ No newline at end of file +DonationsModels=Modèle de document de bon de réception de dons +LastModifiedDonations=Les %s derniers dons modifiés \ No newline at end of file