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')
accessforbidden();
97if ($object->id > 0 && !($object->fk_soc > 0) && $managedfor ==
'thirdparty')
accessforbidden();
104$parameters = array();
105$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
110if (empty($reshook)) {
113 $backurlforlist =
dol_buildpath(
'/partnership/partnership_list.php', 1);
115 if (empty($backtopage) || ($cancel && empty($id))) {
116 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
117 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
118 $backtopage = $backurlforlist;
120 $backtopage =
dol_buildpath(
'/partnership/partnership_card.php', 1).
'?id='.($id > 0 ? $id :
'__ID__');
125 $fk_partner = ($managedfor ==
'member') ?
GETPOST(
'fk_member',
'int') :
GETPOST(
'fk_soc',
'int');
126 $obj_partner = ($managedfor ==
'member') ? $object->fk_member : $object->fk_soc;
128 $triggermodname =
'PARTNERSHIP_MODIFY';
131 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
134 if ($action ==
'confirm_validate' && $confirm ==
'yes' && $permissiontoadd) {
135 $result = $object->validate($user);
138 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
139 if (method_exists($object,
'generateDocument')) {
140 $outputlangs = $langs;
143 $newlang =
GETPOST(
'lang_id',
'aZ09');
146 $newlang = $object->thirdparty->default_lang;
148 if (!empty($newlang)) {
150 $outputlangs->setDefaultLang($newlang);
153 $ret = $object->fetch($id);
155 $model = $object->model_pdf;
157 $retgen = $object->generateDocument($model, $outputlangs, 0, 0, 0);
166 } elseif ($action ==
'confirm_accept' && $confirm ==
'yes' && $permissiontoadd) {
167 $result = $object->approve($user);
170 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
171 if (method_exists($object,
'generateDocument')) {
172 $outputlangs = $langs;
175 $newlang =
GETPOST(
'lang_id',
'aZ09');
178 $newlang = $object->thirdparty->default_lang;
180 if (!empty($newlang)) {
182 $outputlangs->setDefaultLang($newlang);
185 $ret = $object->fetch($id);
187 $model = $object->model_pdf;
189 $retgen = $object->generateDocument($model, $outputlangs, 0, 0, 0);
198 } elseif ($action ==
'confirm_refuse' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
200 if (!(
GETPOST(
'reason_decline_or_cancel',
'alpha'))) {
201 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Refuse")),
null,
'errors');
205 if ($object->statut != $object::STATUS_REFUSED) {
208 $result = $object->refused($user,
GETPOST(
'reason_decline_or_cancel',
'restricthtml'));
213 $object->reason_decline_or_cancel =
GETPOST(
'reason_decline_or_cancel',
'restricthtml');
225 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
228 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
234 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
236 if ($action ==
'set_thirdparty' && $permissiontoadd) {
237 $object->setValueFrom(
'fk_soc',
GETPOST(
'fk_soc',
'int'),
'',
'',
'date',
'', $user, $triggermodname);
239 if ($action ==
'classin' && $permissiontoadd) {
240 $object->setProject(
GETPOST(
'projectid',
'int'));
244 $triggersendname =
'PARTNERSHIP_SENTBYMAIL';
245 $autocopy =
'MAIN_MAIL_AUTOCOPY_PARTNERSHIP_TO';
246 $trackid =
'pship'.$object->id;
247 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
249 if (!empty($id) && !empty(
GETPOST(
'confirm'))) {
250 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
255if ($object->id > 0 && $object->status == $object::STATUS_REFUSED) $object->fields[
'reason_decline_or_cancel'][
'visible'] = 3;
263$form =
new Form($db);
267$title = $langs->trans(
"Partnership");
272if ($action ==
'create') {
273 if (empty($permissiontoadd)) {
277 print
load_fiche_titre($langs->trans(
"NewPartnership"),
'',
'object_'.$object->picto);
279 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
280 print
'<input type="hidden" name="token" value="'.newToken().
'">';
281 print
'<input type="hidden" name="action" value="add">';
283 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
285 if ($backtopageforcancel) {
286 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
291 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
294 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
297 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
299 print
'</table>'.
"\n";
303 print $form->buttonsSaveCancel(
"Create");
311if (($id || $ref) && $action ==
'edit') {
312 print
load_fiche_titre($langs->trans(
"Partnership"),
'',
'object_'.$object->picto);
314 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
315 print
'<input type="hidden" name="token" value="'.newToken().
'">';
316 print
'<input type="hidden" name="action" value="update">';
317 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
319 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
321 if ($backtopageforcancel) {
322 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
327 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
330 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
333 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
339 print $form->buttonsSaveCancel();
345if ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
348 print
dol_get_fiche_head($head,
'card', $langs->trans(
"Partnership"), -1, $object->picto);
353 if ($action ==
'delete') {
354 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'DeletePartnership'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
357 if ($action ==
'deleteline') {
358 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
361 if ($action ==
'clone') {
363 $formquestion = array();
364 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk', $object->ref),
'confirm_clone', $formquestion,
'yes', 1);
367 if ($action ==
'close') {
369 $formquestion = array();
370 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClose'), $langs->trans(
'ConfirmClosePartnershipAsk', $object->ref),
'confirm_close', $formquestion,
'yes', 1);
373 if ($action ==
'reopen') {
375 $formquestion = array();
376 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToReopon'), $langs->trans(
'ConfirmReoponAsk', $object->ref),
'confirm_reopen', $formquestion,
'yes', 1);
380 if ($action ==
'refuse') {
382 $formquestion = array(
383 array(
'type' =>
'text',
'name' =>
'reason_decline_or_cancel',
'label' => $langs->trans(
"Note"),
'morecss' =>
'reason_decline_or_cancel minwidth400',
'value' =>
'')
394 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToRefuse'),
'',
'confirm_refuse', $formquestion,
'', 1, 250);
398 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
399 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
400 if (empty($reshook)) {
401 $formconfirm .= $hookmanager->resPrint;
402 } elseif ($reshook > 0) {
403 $formconfirm = $hookmanager->resPrint;
412 $linkback =
'<a href="'.dol_buildpath(
'/partnership/partnership_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
414 $morehtmlref =
'<div class="refidno">';
446 $morehtmlref .=
'</div>';
448 if ($managedfor ==
'member') {
449 $object->next_prev_filter =
"te.fk_member > 0";
451 $object->next_prev_filter =
"te.fk_soc > 0";
454 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
457 print
'<div class="fichecenter">';
458 print
'<div class="fichehalfleft">';
459 print
'<div class="underbanner clearboth"></div>';
460 print
'<table class="border centpercent tableforfield">'.
"\n";
466 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
469 if ($managedfor ==
'member') {
471 $fadherent->fetch($object->fk_member);
472 print
'<tr><td>'.$langs->trans(
"SubscriptionEndDate").
'</td><td class="valeur">';
473 if ($fadherent->datefin) {
475 if ($fadherent->hasDelay()) {
476 print
" ".img_warning($langs->trans(
"Late"));
479 if (!$adht->subscription) {
480 print $langs->trans(
"SubscriptionNotRecorded");
481 if ($fadherent->statut > 0) {
482 print
" ".img_warning($langs->trans(
"Late"));
485 print $langs->trans(
"SubscriptionNotReceived");
486 if ($fadherent->statut > 0) {
487 print
" ".img_warning($langs->trans(
"Late"));
495 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
501 print
'<div class="clearboth"></div>';
510 if (!empty($object->table_element_line)) {
512 $result = $object->getLinesArray();
514 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOST(
'lineid',
'int')).
'" method="POST">
515 <input type="hidden" name="token" value="' . newToken().
'">
516 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
517 <input type="hidden" name="mode" value="">
518 <input type="hidden" name="page_y" value="">
519 <input type="hidden" name="id" value="' . $object->id.
'">
522 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
523 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
526 print
'<div class="div-table-responsive-no-min">';
527 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
528 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
531 if (!empty($object->lines)) {
532 $object->printObjectLines($action, $mysoc,
null,
GETPOST(
'lineid',
'int'), 1);
536 if ($object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
537 if ($action !=
'editline') {
540 $parameters = array();
541 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
542 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
544 $object->formAddObjectLine(1, $mysoc, $soc);
548 if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
559 if ($action !=
'presend' && $action !=
'editline') {
560 print
'<div class="tabsAction">'.
"\n";
561 $parameters = array();
562 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
567 if (empty($reshook)) {
569 if (empty($user->socid)) {
570 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=presend&token='.newToken().
'&mode=init#formmailbeforetitle');
573 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=edit&token='.newToken(),
'', $permissiontoadd);
576 if ($object->status != $object::STATUS_DRAFT) {
577 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_setdraft&confirm=yes&token='.newToken(),
'', $permissiontoadd);
581 if ($object->status == $object::STATUS_DRAFT) {
582 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
583 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_validate&confirm=yes&token='.newToken(),
'', $permissiontoadd);
585 $langs->load(
"errors");
586 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
591 if ($object->status == $object::STATUS_VALIDATED) {
592 if (empty($object->table_element_line) || (is_array($object->lines) && count($object->lines) > 0)) {
593 print
dolGetButtonAction($langs->trans(
'Approve'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=confirm_accept&confirm=yes&token='.newToken(),
'', $permissiontoadd);
595 $langs->load(
"errors");
596 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Approved"),
'default',
'#',
'', 0);
601 if ($permissiontoadd) {
602 if ($object->status == $object::STATUS_APPROVED) {
603 print
dolGetButtonAction($langs->trans(
'Resiliate'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=close&token='.newToken(),
'', $permissiontoadd);
604 } elseif ($object->status > $object::STATUS_APPROVED) {
606 print
dolGetButtonAction($langs->trans(
'Re-Open'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=confirm_reopen&confirm=yes&token='.newToken(),
'', $permissiontoadd);
611 if ($permissiontoadd) {
612 if ($object->status != $object::STATUS_DRAFT && $object->status != $object::STATUS_APPROVED && $object->status != $object::STATUS_CANCELED && $object->status != $object::STATUS_REFUSED) {
613 print
dolGetButtonAction($langs->trans(
'Refuse'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=refuse&token='.newToken(),
'', $permissiontoadd);
618 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=delete&token='.newToken(),
'', $permissiontodelete || ($object->status == $object::STATUS_DRAFT && $permissiontoadd));
625 if (
GETPOST(
'modelselected')) {
629 if ($action !=
'presend') {
630 print
'<div class="fichecenter"><div class="fichehalfleft">';
631 print
'<a name="builddoc"></a>';
633 $includedocgeneration = 0;
636 if ($includedocgeneration) {
638 $relativepath = $objref.
'/'.$objref.
'.pdf';
639 $filedir = $conf->partnership->dir_output.
'/'.$object->element.
'/'.$objref;
640 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
641 $genallowed = $permissiontoread;
642 $delallowed = $permissiontoadd;
643 print $formfile->showdocuments(
'partnership:Partnership', $object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
647 $linktoelem = $form->showLinkToObjectBlock($object,
null, array(
'partnership'));
648 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
651 print
'</div><div class="fichehalfright">';
655 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/partnership/partnership_agenda.php?id='.$object->id);
658 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
660 $somethingshown =
$formactions->showactions($object, $object->element.
'@'.$object->module, (is_object($object->thirdparty) ? $object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
662 print
'</div></div>';
666 if (
GETPOST(
'modelselected')) {
671 $modelmail =
'partnership_send';
672 $defaulttopic =
'InformationMessage';
673 $diroutput = $conf->partnership->dir_output;
674 $trackid =
'pship'.$object->id;
676 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 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.