26require
'../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/partnership/lib/partnership.lib.php';
34$langs->loadLangs(array(
"partnership",
"other"));
39$action =
GETPOST(
'action',
'aZ09');
40$confirm =
GETPOST(
'confirm',
'alpha');
41$cancel =
GETPOST(
'cancel',
'aZ09');
42$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
43$backtopage =
GETPOST(
'backtopage',
'alpha');
44$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
45$lineid =
GETPOST(
'lineid',
'int');
46$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
51$diroutputmassaction = $conf->partnership->dir_output.
'/temp/massgeneration/'.$user->id;
52$hookmanager->initHooks(array(
'partnershipcard',
'globalcard'));
55$extrafields->fetch_name_optionals_label($object->table_element);
57$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
60$search_all =
GETPOST(
"search_all",
'alpha');
63foreach ($object->fields as $key => $val) {
64 if (
GETPOST(
'search_'.$key,
'alpha')) {
65 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
69if (empty($action) && empty($id) && empty($ref)) {
74include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
77$permissiontoread = $user->hasRight(
'partnership',
'read');
78$permissiontoadd = $user->hasRight(
'partnership',
'write');
79$permissiontodelete = $user->hasRight(
'partnership',
'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
80$permissionnote = $user->hasRight(
'partnership',
'write');
81$permissiondellink = $user->hasRight(
'partnership',
'write');
82$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1];
90if (!isModEnabled(
'partnership')) {
93if (!$permissiontoread) {
96if ($object->id > 0 && !($object->fk_member > 0) && $managedfor ==
'member') {
99if ($object->id > 0 && !($object->fk_soc > 0) && $managedfor ==
'thirdparty') {
108$parameters = array();
109$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
114if (empty($reshook)) {
117 $backurlforlist =
dol_buildpath(
'/partnership/partnership_list.php', 1);
119 if (empty($backtopage) || ($cancel && empty($id))) {
120 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
121 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
122 $backtopage = $backurlforlist;
124 $backtopage =
dol_buildpath(
'/partnership/partnership_card.php', 1).
'?id='.($id > 0 ? $id :
'__ID__');
129 $fk_partner = ($managedfor ==
'member') ?
GETPOST(
'fk_member',
'int') :
GETPOST(
'fk_soc',
'int');
130 $obj_partner = ($managedfor ==
'member') ? $object->fk_member : $object->fk_soc;
132 $triggermodname =
'PARTNERSHIP_MODIFY';
135 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
138 if ($action ==
'confirm_validate' && $confirm ==
'yes' && $permissiontoadd) {
139 $result = $object->validate($user);
143 if (method_exists($object,
'generateDocument')) {
144 $outputlangs = $langs;
147 $newlang =
GETPOST(
'lang_id',
'aZ09');
150 $newlang = $object->thirdparty->default_lang;
152 if (!empty($newlang)) {
154 $outputlangs->setDefaultLang($newlang);
157 $ret = $object->fetch($id);
159 $model = $object->model_pdf;
161 $retgen = $object->generateDocument($model, $outputlangs, 0, 0, 0);
170 } elseif ($action ==
'confirm_accept' && $confirm ==
'yes' && $permissiontoadd) {
171 $result = $object->approve($user);
175 if (method_exists($object,
'generateDocument')) {
176 $outputlangs = $langs;
179 $newlang =
GETPOST(
'lang_id',
'aZ09');
182 $newlang = $object->thirdparty->default_lang;
184 if (!empty($newlang)) {
186 $outputlangs->setDefaultLang($newlang);
189 $ret = $object->fetch($id);
191 $model = $object->model_pdf;
193 $retgen = $object->generateDocument($model, $outputlangs, 0, 0, 0);
202 } elseif ($action ==
'confirm_refuse' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
204 if (!(
GETPOST(
'reason_decline_or_cancel',
'alpha'))) {
205 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Refuse")),
null,
'errors');
209 if ($object->statut != $object::STATUS_REFUSED) {
212 $result = $object->refused($user,
GETPOST(
'reason_decline_or_cancel',
'restricthtml'));
217 $object->reason_decline_or_cancel =
GETPOST(
'reason_decline_or_cancel',
'restricthtml');
229 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
232 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
238 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
240 if ($action ==
'set_thirdparty' && $permissiontoadd) {
241 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user, $triggermodname);
243 if ($action ==
'classin' && $permissiontoadd) {
244 $object->setProject(
GETPOST(
'projectid',
'int'));
248 $triggersendname =
'PARTNERSHIP_SENTBYMAIL';
249 $autocopy =
'MAIN_MAIL_AUTOCOPY_PARTNERSHIP_TO';
250 $trackid =
'pship'.$object->id;
251 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
253 if (!empty($id) && !empty(
GETPOST(
'confirm'))) {
254 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
259if ($object->id > 0 && $object->status == $object::STATUS_REFUSED) {
260 $object->fields[
'reason_decline_or_cancel'][
'visible'] = 3;
269$form =
new Form($db);
273$title = $langs->trans(
"Partnership");
278if ($action ==
'create') {
279 if (empty($permissiontoadd)) {
283 print
load_fiche_titre($langs->trans(
"NewPartnership"),
'',
'object_'.$object->picto);
285 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
286 print
'<input type="hidden" name="token" value="'.newToken().
'">';
287 print
'<input type="hidden" name="action" value="add">';
289 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
291 if ($backtopageforcancel) {
292 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
297 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
300 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
303 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
305 print
'</table>'.
"\n";
309 print $form->buttonsSaveCancel(
"Create");
317if (($id || $ref) && $action ==
'edit') {
318 print
load_fiche_titre($langs->trans(
"Partnership"),
'',
'object_'.$object->picto);
320 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
321 print
'<input type="hidden" name="token" value="'.newToken().
'">';
322 print
'<input type="hidden" name="action" value="update">';
323 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
325 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
327 if ($backtopageforcancel) {
328 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
333 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
336 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
339 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
345 print $form->buttonsSaveCancel();
351if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
354 print
dol_get_fiche_head($head,
'card', $langs->trans(
"Partnership"), -1, $object->picto);
359 if ($action ==
'delete') {
360 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeletePartnership'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
363 if ($action ==
'deleteline') {
364 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
367 if ($action ==
'clone') {
369 $formquestion = array();
370 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
373 if ($action ==
'close') {
375 $formquestion = array();
376 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClose'), $langs->trans(
'ConfirmClosePartnershipAsk', $object->ref),
'confirm_close', $formquestion,
'yes', 1);
379 if ($action ==
'reopen') {
381 $formquestion = array();
382 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToReopon'), $langs->trans(
'ConfirmReoponAsk', $object->ref),
'confirm_reopen', $formquestion,
'yes', 1);
386 if ($action ==
'refuse') {
388 $formquestion = array(
389 array(
'type' =>
'text',
'name' =>
'reason_decline_or_cancel',
'label' => $langs->trans(
"Note"),
'morecss' =>
'reason_decline_or_cancel minwidth400',
'value' =>
'')
400 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToRefuse'),
'',
'confirm_refuse', $formquestion,
'', 1, 250);
404 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
405 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
406 if (empty($reshook)) {
407 $formconfirm .= $hookmanager->resPrint;
408 } elseif ($reshook > 0) {
409 $formconfirm = $hookmanager->resPrint;
418 $linkback =
'<a href="'.dol_buildpath(
'/partnership/partnership_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
420 $morehtmlref =
'<div class="refidno">';
452 $morehtmlref .=
'</div>';
454 if ($managedfor ==
'member') {
455 $object->next_prev_filter =
"te.fk_member > 0";
457 $object->next_prev_filter =
"te.fk_soc > 0";
460 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
463 print
'<div class="fichecenter">';
464 print
'<div class="fichehalfleft">';
465 print
'<div class="underbanner clearboth"></div>';
466 print
'<table class="border centpercent tableforfield">'.
"\n";
472 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
475 if ($managedfor ==
'member') {
477 $fadherent->fetch($object->fk_member);
478 print
'<tr><td>'.$langs->trans(
"SubscriptionEndDate").
'</td><td class="valeur">';
479 if ($fadherent->datefin) {
481 if ($fadherent->hasDelay()) {
482 print
" ".img_warning($langs->trans(
"Late"));
485 if (!$adht->subscription) {
486 print $langs->trans(
"SubscriptionNotRecorded");
487 if ($fadherent->statut > 0) {
488 print
" ".img_warning($langs->trans(
"Late"));
491 print $langs->trans(
"SubscriptionNotReceived");
492 if ($fadherent->statut > 0) {
493 print
" ".img_warning($langs->trans(
"Late"));
501 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
507 print
'<div class="clearboth"></div>';
516 if (!empty($object->table_element_line)) {
518 $result = $object->getLinesArray();
520 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
521 <input type="hidden" name="token" value="' . newToken().
'">
522 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
523 <input type="hidden" name="mode" value="">
524 <input type="hidden" name="page_y" value="">
525 <input type="hidden" name="id" value="' . $object->id.
'">
528 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
529 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
532 print
'<div class="div-table-responsive-no-min">';
533 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
534 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
537 if (!empty($object->lines)) {
538 $object->printObjectLines($action, $mysoc,
null,
GETPOST(
'lineid',
'int'), 1);
542 if ($object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
543 if ($action !=
'editline') {
546 $parameters = array();
547 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
551 if (empty($reshook)) {
552 $object->formAddObjectLine(1, $mysoc, $soc);
557 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
568 if ($action !=
'presend' && $action !=
'editline') {
569 print
'<div class="tabsAction">'.
"\n";
570 $parameters = array();
571 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
576 if (empty($reshook)) {
578 if (empty($user->socid)) {
579 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=presend&token='.newToken().
'&mode=init#formmailbeforetitle');
582 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&token='.newToken(),
'', $permissiontoadd);
585 if ($object->status != $object::STATUS_DRAFT) {
586 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_setdraft&confirm=yes&token='.newToken(),
'', $permissiontoadd);
590 if ($object->status == $object::STATUS_DRAFT) {
591 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
592 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_validate&confirm=yes&token='.newToken(),
'', $permissiontoadd);
594 $langs->load(
"errors");
595 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
600 if ($object->status == $object::STATUS_VALIDATED) {
601 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
602 print
dolGetButtonAction($langs->trans(
'Approve'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_accept&confirm=yes&token='.newToken(),
'', $permissiontoadd);
604 $langs->load(
"errors");
605 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Approved"),
'default',
'#',
'', 0);
610 if ($permissiontoadd) {
611 if ($object->status == $object::STATUS_APPROVED) {
612 print
dolGetButtonAction($langs->trans(
'Resiliate'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=close&token='.newToken(),
'', $permissiontoadd);
613 } elseif ($object->status > $object::STATUS_APPROVED) {
615 print
dolGetButtonAction($langs->trans(
'Re-Open'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_reopen&confirm=yes&token='.newToken(),
'', $permissiontoadd);
620 if ($permissiontoadd) {
621 if ($object->status != $object::STATUS_DRAFT && $object->status != $object::STATUS_APPROVED && $object->status != $object::STATUS_CANCELED && $object->status != $object::STATUS_REFUSED) {
622 print
dolGetButtonAction($langs->trans(
'Refuse'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=refuse&token='.newToken(),
'', $permissiontoadd);
627 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=delete&token='.newToken(),
'', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
634 if (
GETPOST(
'modelselected')) {
638 if ($action !=
'presend') {
639 print
'<div class="fichecenter"><div class="fichehalfleft">';
640 print
'<a name="builddoc"></a>';
642 $includedocgeneration = 0;
645 if ($includedocgeneration) {
647 $relativepath = $objref.
'/'.$objref.
'.pdf';
648 $filedir = $conf->partnership->dir_output.
'/'.$object->element.
'/'.$objref;
649 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
650 $genallowed = $permissiontoread;
651 $delallowed = $permissiontoadd;
652 print $formfile->showdocuments(
'partnership:Partnership', $object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
656 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'partnership'));
657 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
660 print
'</div><div class="fichehalfright">';
664 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/partnership/partnership_agenda.php?id='.$object->id);
667 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
669 $somethingshown =
$formactions->showactions($object, $object->element.
'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
671 print
'</div></div>';
675 if (
GETPOST(
'modelselected')) {
680 $modelmail =
'partnership_send';
681 $defaulttopic =
'InformationMessage';
682 $diroutput = $conf->partnership->dir_output;
683 $trackid =
'pship'.$object->id;
685 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') elseif( $action=='specimen') elseif($action=='setmodel') elseif( $action=='del') elseif($action=='setdoc') $formactions
View.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage members of a foundation.
Class to manage translations.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
partnershipPrepareHead($object)
Prepare array of tabs for Partnership.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.