diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 38dc1fbf014..db257c4b47c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4239,13 +4239,13 @@ function yn($yesno, $case=1, $color=0) * @param string $modulepart Type of object ('invoice_supplier, 'donation', 'invoice', ...') * @return string Dir to use ending. Example '' or '1/' or '1/2/' */ -function get_exdir($num,$level,$alpha,$withoutslash,$object,$modulepart) +function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart) { global $conf; $path = ''; - $arrayforoldpath=array('cheque','user','category','holiday','shipment', 'member','don','donation','supplier_invoice','invoice_supplier','mailing'); + $arrayforoldpath=array('cheque','user','category','holiday','shipment', 'member','supplier_invoice','invoice_supplier','mailing'); if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $arrayforoldpath[]='product'; if (! empty($level) && in_array($modulepart, $arrayforoldpath)) { diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 1ac08c1d33d..c5c5c402af8 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -290,7 +290,7 @@ llxHeader('',$langs->trans("Donation"),'EN:Module_Donations|FR:Module_Dons|ES:M& $form=new Form($db); $formfile = new FormFile($db); $formcompany = new FormCompany($db); - +if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } if ($action == 'create') { @@ -363,9 +363,6 @@ if ($action == 'create') if (! empty($conf->projet->enabled)) { - - $formproject=new FormProjets($db); - print "".$langs->trans("Project").""; $formproject->select_projects(-1, $projectid,'fk_projet', 0, 0, 1, 1); print "\n"; @@ -546,21 +543,66 @@ if (! empty($id) && $action != 'edit') $head = donation_prepare_head($object); dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'generic'); - print '
'; - print ''; - print ''; - + // Print form confirm + print $formconfirm; + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref='
'; + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.=$langs->trans('Project') . ' '; + if ($user->rights->don->creer) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.=''; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + } + $morehtmlref.='
'; + + + dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); + + + print '
'; + print '
'; + print '
'; + + print '
'; $nbrows=12; if (! empty($conf->projet->enabled)) $nbrows++; // Ref + /* print ''; print ''; - + */ // Date print ''; print ''; print ''; - print ''; - - $rowspan=6; - if (! empty($conf->projet->enabled)) $rowspan++; - print ''; + // Zip / Town + print ''; + + // Country + print ''; + + // EMail + print "".''; + */ + + // Payment mode + print "\n"; + + //print "".''; + + // Project + /* + if (! empty($conf->projet->enabled)) + { + print ''; + print ''; + print ''; + print ''; + }*/ + + // Other attributes + $cols = 2; + include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; + + print '
'.$langs->trans("Ref").''; print $form->showrefnav($object, 'rowid', $linkback, 1, 'rowid', 'ref', ''); print '
'.$langs->trans("Date").''; print dol_print_date($object->date,"day"); @@ -577,12 +619,62 @@ if (! empty($id) && $action != 'edit') print '
'.$langs->trans("Company").''.$object->societe.'
'.$langs->trans("Lastname").''.$object->lastname.'
'.$langs->trans("Firstname").''.$object->firstname.'
'.$langs->trans("Address").''.dol_nl2br($object->address).''; + /*print '
'.$langs->trans("Address").''.dol_nl2br($object->address).'
'.$langs->trans("Zip").' / '.$langs->trans("Town").''; + print $object->zip.($object->zip && $object->town?' / ':'').$object->town.'
'.$langs->trans('Country').''; + if (! empty($object->country_code)) + { + $img=picto_from_langcode($object->country_code); + print ($img?$img.' ':''); + print $object->country; + } + else + { + print $object->country_olddata; + } + print '
'.$langs->trans("EMail").''.dol_print_email($object->email).'
".$langs->trans("PaymentMode").""; + $form->form_modes_reglement(null, $object->modepaymentid,'none'); + print "
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'.$langs->trans("Project").''; + $projettmp=new Project($db); + $projettmp->id=$object->fk_projet; + $projettmp->ref=$object->project; + if(! empty($object->fk_projet)) print $projettmp->getNomUrl(1); + print '
'; + + print ''; + print '
'; + print '
'; + /* * Payments */ @@ -603,13 +695,12 @@ if (! empty($id) && $action != 'edit') { $num = $db->num_rows($resql); $i = 0; $total = 0; - print ''; + print '
'; print ''; print ''; print ''; print ''; print ''; - print ''; print ''; $var=True; @@ -620,9 +711,9 @@ if (! empty($id) && $action != 'edit') print "'; print '\n"; - $labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type; - print "\n"; - print '\n"; + $labeltype=$langs->trans("PaymentType".$objp->type_code)!=("PaymentType".$objp->type_code)?$langs->trans("PaymentType".$objp->type_code):$objp->paiement_type; + print "\n"; + print '\n"; print ""; $totalpaid += $objp->amount; $i++; @@ -630,13 +721,13 @@ if (! empty($id) && $action != 'edit') if ($object->paid == 0) { - print "\n"; - print "\n"; + print "\n"; + print "\n"; $remaintopay = $object->amount - $totalpaid; - print ""; - print "\n"; + print ""; + print '\n"; } print "
'.$langs->trans("RefPayment").''.$langs->trans("Date").''.$langs->trans("Type").''.$langs->trans("Amount").' 
"; print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp),'day')."".$labeltype.' '.$objp->num_payment."'.price($objp->amount)." ".$langs->trans("Currency".$conf->currency)."".$labeltype.' '.$objp->num_payment."'.price($objp->amount)."
".$langs->trans("AlreadyPaid")." :".price($totalpaid)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AmountExpected")." :".price($object->amount)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AlreadyPaid")." :".price($totalpaid)."
".$langs->trans("AmountExpected")." :".price($object->amount)."
".$langs->trans("RemainderToPay")." :".price($remaintopay)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("RemainderToPay")." :'.price($remaintopay)."
"; $db->free($resql); @@ -645,70 +736,22 @@ if (! empty($id) && $action != 'edit') { dol_print_error($db); } - print ""; - print ""; - - // Zip / Town - print ''.$langs->trans("Zip").' / '.$langs->trans("Town").''; - print $object->zip.($object->zip && $object->town?' / ':'').$object->town.''; - - // Country - print ''.$langs->trans('Country').''; - if (! empty($object->country_code)) - { - $img=picto_from_langcode($object->country_code); - print ($img?$img.' ':''); - print $object->country; - } - else - { - print $object->country_olddata; - } - print ''; - - // EMail - print "".''.$langs->trans("EMail").''.dol_print_email($object->email).''; - - // Payment mode - print "".$langs->trans("PaymentMode").""; - $form->form_modes_reglement(null, $object->modepaymentid,'none'); - print "\n"; - - print "".''.$langs->trans("Status").''.$object->getLibStatut(4).''; - - // Project - if (! empty($conf->projet->enabled)) - { - print ''; - print ''.$langs->trans("Project").''; - print ''; - $projettmp=new Project($db); - $projettmp->id=$object->fk_projet; - $projettmp->ref=$object->project; - if(! empty($object->fk_projet)) print $projettmp->getNomUrl(1); - print ''; - print ''; - } - - // Other attributes - $parameters=array('colspan' => ' colspan="2"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - print $object->showOptionals($extrafields); - } - - print "\n"; - print "\n"; - - print "
"; + + print '
'; + print ''; + print ''; + + print '
'; + + + dol_fiche_end(); + $remaintopay = $object->amount - $totalpaid; - /** - * Actions buttons - */ + // Actions buttons + print '
'; print ''; diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index 35eb06bae54..820c2f9d1b4 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -30,8 +30,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; /** - * \class Don - * \brief Class to manage donations + * Class to manage donations */ class Don extends CommonObject { @@ -39,7 +38,8 @@ class Don extends CommonObject public $table_element='don'; // Name of table without prefix where object is stored public $fk_element = 'fk_donation'; protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - + var $picto = 'generic'; + var $date; var $amount; var $societe; @@ -48,7 +48,7 @@ class Don extends CommonObject var $town; var $email; var $public; - var $fk_projet; + var $fk_project; var $fk_typepayment; var $num_payment; var $date_valid; @@ -122,7 +122,6 @@ class Don extends CommonObject } 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'); @@ -135,14 +134,20 @@ class Don extends CommonObject 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) + 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'); } + if ($mode == 6) + { + if ($statut == -1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut5'); + if ($statut == 0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut0'); + if ($statut == 1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut1'); + if ($statut == 2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut],'statut6'); + } } @@ -601,7 +606,7 @@ class Don extends CommonObject $sql = "SELECT d.rowid, d.datec, d.date_valid, 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_projet, d.model_pdf,"; + $sql.= " d.phone_mobile, d.fk_projet as fk_project, d.model_pdf,"; $sql.= " p.ref as project_ref,"; $sql.= " c.code as country_code, c.label as country"; $sql.= " FROM ".MAIN_DB_PREFIX."don as d"; @@ -648,7 +653,8 @@ class Don extends CommonObject $this->phone = $obj->phone; $this->phone_mobile = $obj->phone_mobile; $this->project = $obj->project_ref; - $this->fk_projet = $obj->fk_projet; + $this->fk_projet = $obj->fk_project; // deprecated + $this->fk_project = $obj->fk_project; $this->public = $obj->public; $this->modepaymentid = $obj->fk_payment; $this->modepayment = $obj->libelle; diff --git a/htdocs/don/document.php b/htdocs/don/document.php index 4c5ae99e298..35df6bb338a 100644 --- a/htdocs/don/document.php +++ b/htdocs/don/document.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2015 Laurent Destailleur + * Copyright (C) 2004-2016 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2005 Simon TOSSER @@ -34,6 +34,11 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; +if (! empty($conf->projet->enabled)) +{ + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; +} $langs->load("other"); $langs->load("donations"); @@ -64,7 +69,7 @@ if (! $sortfield) $sortfield="name"; $object = new Don($db); $object->fetch($id, $ref); -$upload_dir = $conf->don->dir_output . '/' . get_exdir($filename,2,0,1,$object,'donation'). '/'. dol_sanitizeFileName($object->ref); +$upload_dir = $conf->don->dir_output . '/' . get_exdir($filename,0,0,0,$object,'donation'). '/'. dol_sanitizeFileName($object->ref); $modulepart='don'; @@ -80,6 +85,7 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; */ $form = new Form($db); +if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); } llxHeader("",$langs->trans("Donation")); @@ -102,23 +108,71 @@ if ($object->id) } + $linkback = ''.$langs->trans("BackToList").''; + + $morehtmlref='
'; + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + $morehtmlref.=$langs->trans('Project') . ' '; + if ($user->rights->don->creer) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } + } + $morehtmlref.='
'; + + + dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref); + + print '
'; + print '
'; + print ''; - $linkback = ''.$langs->trans("BackToList").''; // Ref + /* print ''; - + */ + // Societe //print ""; - print ''; + print ''; print ''; print '
'.$langs->trans("Ref").''; print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', ''); print '
".$langs->trans("Company")."".$object->client->getNomUrl(1)."
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; print '
'; + + print '
'; + + dol_fiche_end(); $modulepart = 'don'; $permission = $user->rights->don->lire;