28require
'../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/partnership/class/partnership.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/partnership/lib/partnership.lib.php';
44$langs->loadLangs(array(
"partnership",
"other"));
49$action =
GETPOST(
'action',
'aZ09');
50$confirm =
GETPOST(
'confirm',
'alpha');
52$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
53$backtopage =
GETPOST(
'backtopage',
'alpha');
54$backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
56$dol_openinpopup =
GETPOST(
'dol_openinpopup',
'aZ09');
61$diroutputmassaction = $conf->partnership->dir_output.
'/temp/massgeneration/'.$user->id;
62$hookmanager->initHooks(array(
'partnershipcard',
'globalcard'));
65$extrafields->fetch_name_optionals_label(
$object->table_element);
67$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
70$search_all =
GETPOST(
"search_all",
'alpha');
73foreach (
$object->fields as $key => $val) {
74 if (
GETPOST(
'search_'.$key,
'alpha')) {
75 $search[$key] =
GETPOST(
'search_'.$key,
'alpha');
79if (empty($action) && empty($id) && empty($ref)) {
84include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
87$permissiontoread = $user->hasRight(
'partnership',
'read');
88$permissiontoadd = $user->hasRight(
'partnership',
'write');
89$permissiontodelete = $user->hasRight(
'partnership',
'delete') || ($permissiontoadd && isset(
$object->status) &&
$object->status == $object::STATUS_DRAFT);
90$permissionnote = $user->hasRight(
'partnership',
'write');
91$permissiondellink = $user->hasRight(
'partnership',
'write');
92$upload_dir = $conf->partnership->multidir_output[isset(
$object->entity) ?
$object->entity : 1];
103if (!$permissiontoread) {
106if (
$object->id > 0 && !(
$object->fk_member > 0) && $managedfor ==
'member') {
109if (
$object->id > 0 && !(
$object->fk_soc > 0) && $managedfor ==
'thirdparty') {
118$parameters = array();
119$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
124if (empty($reshook)) {
127 $backurlforlist =
dol_buildpath(
'/partnership/partnership_list.php', 1);
129 if (empty($backtopage) || ($cancel && empty($id))) {
130 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
131 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
132 $backtopage = $backurlforlist;
134 $backtopage =
dol_buildpath(
'/partnership/partnership_card.php', 1).
'?id='.(
$id > 0 ?
$id :
'__ID__');
140 $obj_partner = ($managedfor ==
'member') ?
$object->fk_member :
$object->fk_soc;
142 $triggermodname =
'PARTNERSHIP_MODIFY';
145 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
148 if ($action ==
'confirm_validate' && $confirm ==
'yes' && $permissiontoadd) {
149 $result =
$object->validate($user);
153 $outputlangs = $langs;
156 $newlang =
GETPOST(
'lang_id',
'aZ09');
159 $newlang =
$object->thirdparty->default_lang;
161 if (!empty($newlang)) {
163 $outputlangs->setDefaultLang($newlang);
170 $retgen =
$object->generateDocument($model, $outputlangs, 0, 0, 0);
178 } elseif ($action ==
'confirm_accept' && $confirm ==
'yes' && $permissiontoadd) {
179 $result =
$object->approve($user);
183 $outputlangs = $langs;
186 $newlang =
GETPOST(
'lang_id',
'aZ09');
189 $newlang =
$object->thirdparty->default_lang;
191 if (!empty($newlang)) {
193 $outputlangs->setDefaultLang($newlang);
200 $retgen =
$object->generateDocument($model, $outputlangs, 0, 0, 0);
208 } elseif ($action ==
'confirm_refuse' && $permissiontoadd && !
GETPOST(
'cancel',
'alpha')) {
210 if (!(
GETPOST(
'reason_decline_or_cancel',
'alpha'))) {
211 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Refuse")),
null,
'errors');
215 if (
$object->status != $object::STATUS_REFUSED) {
218 $result =
$object->refused($user,
GETPOST(
'reason_decline_or_cancel',
'restricthtml'));
223 $object->reason_decline_or_cancel =
GETPOST(
'reason_decline_or_cancel',
'restricthtml');
235 include DOL_DOCUMENT_ROOT.
'/core/actions_dellink.inc.php';
238 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
244 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
246 if ($action ==
'set_thirdparty' && $permissiontoadd) {
247 $object->setValueFrom(
'fk_soc',
GETPOSTINT(
'fk_soc'),
'',
null,
'date',
'', $user, $triggermodname);
249 if ($action ==
'classin' && $permissiontoadd) {
254 $triggersendname =
'PARTNERSHIP_SENTBYMAIL';
255 $autocopy =
'MAIN_MAIL_AUTOCOPY_PARTNERSHIP_TO';
256 $trackid =
'pship'.$object->id;
257 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
259 if (!empty($id) && !empty(
GETPOST(
'confirm'))) {
260 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
265if (
$object->id > 0 &&
$object->status == $object::STATUS_REFUSED) {
266 $object->fields[
'reason_decline_or_cancel'][
'visible'] = 3;
275$form =
new Form($db);
279$title = $langs->trans(
"Partnership");
281llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-partnership page-card');
284if ($action ==
'create') {
285 if (empty($permissiontoadd)) {
289 print
load_fiche_titre($langs->trans(
"NewPartnership"),
'',
'object_'.$object->picto);
291 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
292 print
'<input type="hidden" name="token" value="'.newToken().
'">';
293 print
'<input type="hidden" name="action" value="add">';
295 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
297 if ($backtopageforcancel) {
298 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
303 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
306 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_add.tpl.php';
309 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_add.tpl.php';
311 print
'</table>'.
"\n";
315 print $form->buttonsSaveCancel(
"Create");
323if (($id || $ref) && $action ==
'edit') {
324 print
load_fiche_titre($langs->trans(
"Partnership"),
'',
'object_'.$object->picto);
326 print
'<form method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
327 print
'<input type="hidden" name="token" value="'.newToken().
'">';
328 print
'<input type="hidden" name="action" value="update">';
329 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
331 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
333 if ($backtopageforcancel) {
334 print
'<input type="hidden" name="backtopageforcancel" value="'.$backtopageforcancel.
'">';
339 print
'<table class="border centpercent tableforfieldedit">'.
"\n";
342 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_edit.tpl.php';
345 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_edit.tpl.php';
351 print $form->buttonsSaveCancel();
357if (
$object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
365 if ($action ==
'delete') {
366 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'DeletePartnership'), $langs->trans(
'ConfirmDeleteObject'),
'confirm_delete',
'', 0, 1);
369 if ($action ==
'deleteline') {
370 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&lineid='.$lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ConfirmDeleteLine'),
'confirm_deleteline',
'', 0, 1);
373 if ($action ==
'clone') {
375 $formquestion = array();
376 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneAsk',
$object->ref),
'confirm_clone', $formquestion,
'yes', 1);
379 if ($action ==
'close') {
381 $formquestion = array();
382 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToClose'), $langs->trans(
'ConfirmClosePartnershipAsk',
$object->ref),
'confirm_close', $formquestion,
'yes', 1);
385 if ($action ==
'reopen') {
387 $formquestion = array();
388 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'PartnershipToReopen'), $langs->trans(
'PartnershipConfirmReOpenAsk',
$object->ref),
'confirm_reopen', $formquestion,
'yes', 1);
392 if ($action ==
'refuse') {
394 $formquestion = array(
395 array(
'type' =>
'text',
'name' =>
'reason_decline_or_cancel',
'label' => $langs->trans(
"Note"),
'morecss' =>
'reason_decline_or_cancel minwidth400',
'value' =>
'')
406 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.
$object->id, $langs->trans(
'ToRefuse'),
'',
'confirm_refuse', $formquestion,
'', 1, 250);
410 $parameters = array(
'formConfirm' => $formconfirm,
'lineid' => $lineid);
411 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
412 if (empty($reshook)) {
413 $formconfirm .= $hookmanager->resPrint;
414 } elseif ($reshook > 0) {
415 $formconfirm = $hookmanager->resPrint;
424 $linkback =
'<a href="'.dol_buildpath(
'/partnership/partnership_list.php', 1).
'?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
426 $morehtmlref =
'<div class="refidno">';
427 $morehtmlref .=
'</div>';
429 if ($managedfor ==
'member') {
430 $object->next_prev_filter =
"te.fk_member:>:0";
432 $object->next_prev_filter =
"te.fk_soc:>:0";
435 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
438 print
'<div class="fichecenter">';
439 print
'<div class="fichehalfleft">';
440 print
'<div class="underbanner clearboth"></div>';
441 print
'<table class="border centpercent tableforfield">'.
"\n";
447 include DOL_DOCUMENT_ROOT.
'/core/tpl/commonfields_view.tpl.php';
450 if ($managedfor ==
'member') {
452 $fadherent->fetch(
$object->fk_member);
453 print
'<tr><td>'.$langs->trans(
"SubscriptionEndDate").
'</td><td class="valeur">';
454 if ($fadherent->datefin) {
456 if ($fadherent->hasDelay()) {
457 print
" ".img_warning($langs->trans(
"Late"));
460 if (!$adht->subscription) {
461 print $langs->trans(
"SubscriptionNotRecorded");
462 if ($fadherent->status > 0) {
463 print
" ".img_warning($langs->trans(
"Late"));
466 print $langs->trans(
"SubscriptionNotReceived");
467 if ($fadherent->status > 0) {
468 print
" ".img_warning($langs->trans(
"Late"));
476 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
482 print
'<div class="clearboth"></div>';
491 if (!empty(
$object->table_element_line)) {
493 $result =
$object->getLinesArray();
495 print
' <form name="addproduct" id="addproduct" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.(($action !=
'editline') ?
'' :
'#line_'.
GETPOSTINT(
'lineid')).
'" method="POST">
496 <input type="hidden" name="token" value="' .
newToken().
'">
497 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline').
'">
498 <input type="hidden" name="mode" value="">
499 <input type="hidden" name="page_y" value="">
500 <input type="hidden" name="id" value="' .
$object->id.
'">
503 if (!empty($conf->use_javascript_ajax) &&
$object->status == 0) {
504 include DOL_DOCUMENT_ROOT.
'/core/tpl/ajaxrow.tpl.php';
507 print
'<div class="div-table-responsive-no-min">';
508 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
509 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
517 if (
$object->status == 0 && $permissiontoadd && $action !=
'selectlines') {
518 if ($action !=
'editline') {
521 $parameters = array();
522 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
526 if (empty($reshook)) {
532 if (!empty(
$object->lines) || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd && $action !=
'selectlines' && $action !=
'editline')) {
543 if ($action !=
'presend' && $action !=
'editline') {
544 print
'<div class="tabsAction">'.
"\n";
545 $parameters = array();
546 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
551 if (empty($reshook)) {
553 if (empty($user->socid)) {
554 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=presend&token='.
newToken().
'&mode=init#formmailbeforetitle');
557 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=edit&token='.
newToken(),
'', $permissiontoadd);
560 if (
$object->status != $object::STATUS_DRAFT) {
561 print
dolGetButtonAction(
'', $langs->trans(
'SetToDraft'),
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_setdraft&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
565 if (
$object->status == $object::STATUS_DRAFT) {
567 print
dolGetButtonAction(
'', $langs->trans(
'Validate'),
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_validate&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
569 $langs->load(
"errors");
570 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Validate"),
'default',
'#',
'', 0);
575 if (
$object->status == $object::STATUS_VALIDATED) {
577 print
dolGetButtonAction($langs->trans(
'Approve'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=confirm_accept&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
579 $langs->load(
"errors");
580 print
dolGetButtonAction($langs->trans(
"ErrorAddAtLeastOneLineFirst"), $langs->trans(
"Approved"),
'default',
'#',
'', 0);
585 if ($permissiontoadd) {
586 if (
$object->status == $object::STATUS_APPROVED) {
587 print
dolGetButtonAction($langs->trans(
'Resiliate'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=close&token='.
newToken(),
'', $permissiontoadd);
588 } elseif (
$object->status > $object::STATUS_APPROVED) {
590 print
dolGetButtonAction($langs->trans(
'Re-Open'),
'',
'default', $_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=confirm_reopen&confirm=yes&token='.
newToken(),
'', $permissiontoadd);
595 if ($permissiontoadd) {
596 if (
$object->status != $object::STATUS_DRAFT &&
$object->status != $object::STATUS_APPROVED &&
$object->status != $object::STATUS_CANCELED &&
$object->status != $object::STATUS_REFUSED) {
597 print
dolGetButtonAction($langs->trans(
'Refuse'),
'',
'default', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=refuse&token='.
newToken(),
'', $permissiontoadd);
602 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=delete&token='.
newToken(),
'', $permissiontodelete || (
$object->status == $object::STATUS_DRAFT && $permissiontoadd));
609 if (
GETPOST(
'modelselected')) {
613 if ($action !=
'presend') {
614 print
'<div class="fichecenter"><div class="fichehalfleft">';
615 print
'<a name="builddoc"></a>';
617 $includedocgeneration = 0;
620 if ($includedocgeneration) {
622 $relativepath = $objref.
'/'.$objref.
'.pdf';
623 $filedir = $conf->partnership->dir_output.
'/'.
$object->element.
'/'.$objref;
624 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
625 $genallowed = $permissiontoread;
626 $delallowed = $permissiontoadd;
627 print $formfile->showdocuments(
'partnership:Partnership',
$object->element.
'/'.$objref, $filedir, $urlsource, $genallowed, $delallowed,
$object->model_pdf, 1, 0, 0, 28, 0,
'',
'',
'', $langs->defaultlang);
631 $tmparray = $form->showLinkToObjectBlock($object, array(), array(
'partnership'), 1);
632 $linktoelem = $tmparray[
'linktoelem'];
633 $htmltoenteralink = $tmparray[
'htmltoenteralink'];
634 print $htmltoenteralink;
636 $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
639 print
'</div><div class="fichehalfright">';
643 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/partnership/partnership_agenda.php?id='.
$object->id);
646 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
648 $somethingshown = $formactions->showactions($object,
$object->element.
'@'.
$object->module, (is_object(
$object->thirdparty) ?
$object->thirdparty->id : 0), 1,
'', $MAXEVENT,
'', $morehtmlcenter);
650 print
'</div></div>';
654 if (
GETPOST(
'modelselected')) {
659 $modelmail =
'partnership_send';
660 $defaulttopic =
'InformationMessage';
661 $diroutput = $conf->partnership->dir_output;
662 $trackid =
'pship'.$object->id;
664 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage members of a foundation.
Class to manage translations.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
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_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.