34require
'../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/fichinter.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
41$langs->loadLangs(array(
'admin',
'errors',
'interventions',
'other'));
47$action =
GETPOST(
'action',
'aZ09');
48$value =
GETPOST(
'value',
'alpha');
49$modulepart =
GETPOST(
'modulepart',
'aZ09');
51$label =
GETPOST(
'label',
'alpha');
52$scandir =
GETPOST(
'scan_dir',
'alpha');
60include DOL_DOCUMENT_ROOT.
'/core/actions_setmoduleoptions.inc.php';
62if ($action ==
'updateMask') {
63 $maskconst =
GETPOST(
'maskconst',
'aZ09');
64 $maskvalue =
GETPOST(
'maskvalue',
'alpha');
65 if ($maskconst && preg_match(
'/_MASK$/', $maskconst)) {
66 $res =
dolibarr_set_const($db, $maskconst, $maskvalue,
'chaine', 0,
'', $conf->entity);
78} elseif ($action ==
'specimen') {
79 $modele =
GETPOST(
'module',
'alpha');
82 $inter->initAsSpecimen();
87 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
88 foreach ($dirmodels as $reldir) {
89 $file =
dol_buildpath($reldir.
"core/modules/fichinter/doc/pdf_".$modele.
".modules.php", 0);
90 if (file_exists($file)) {
91 $classname =
"pdf_".$modele;
96 if ($classname !==
'') {
99 $module =
new $classname($db);
100 '@phan-var-force ModelePDFFicheinter $module';
102 if ($module->write_file($inter, $langs) > 0) {
103 header(
"Location: ".DOL_URL_ROOT.
"/document.php?modulepart=ficheinter&file=SPECIMEN.pdf");
111 dol_syslog($langs->trans(
"ErrorModuleNotFound"), LOG_ERR);
113} elseif ($action ==
'set') {
116} elseif ($action ==
'del') {
119 if ($conf->global->FICHEINTER_ADDON_PDF ==
"$value") {
123} elseif ($action ==
'setdoc') {
125 if (
dolibarr_set_const($db,
"FICHEINTER_ADDON_PDF", $value,
'chaine', 0,
'', $conf->entity)) {
128 $conf->global->FICHEINTER_ADDON_PDF = $value;
136} elseif ($action ==
'setmod') {
141} elseif ($action ==
'set_FICHINTER_FREE_TEXT') {
142 $freetext =
GETPOST(
'FICHINTER_FREE_TEXT',
'restricthtml');
143 $res =
dolibarr_set_const($db,
"FICHINTER_FREE_TEXT", $freetext,
'chaine', 0,
'', $conf->entity);
154} elseif ($action ==
'set_FICHINTER_DRAFT_WATERMARK') {
155 $draft =
GETPOST(
'FICHINTER_DRAFT_WATERMARK',
'alpha');
156 $res =
dolibarr_set_const($db,
"FICHINTER_DRAFT_WATERMARK", trim($draft),
'chaine', 0,
'', $conf->entity);
167} elseif ($action ==
'set_FICHINTER_PRINT_PRODUCTS') {
168 $val =
GETPOST(
'FICHINTER_PRINT_PRODUCTS',
'alpha');
169 $res =
dolibarr_set_const($db,
"FICHINTER_PRINT_PRODUCTS", ($val ==
'on' ? 1 : 0),
'bool', 0,
'', $conf->entity);
180} elseif ($action ==
'set_FICHINTER_USE_SERVICE_DURATION') {
181 $val =
GETPOST(
'FICHINTER_USE_SERVICE_DURATION',
'alpha');
182 $res =
dolibarr_set_const($db,
"FICHINTER_USE_SERVICE_DURATION", ($val ==
'on' ? 1 : 0),
'bool', 0,
'', $conf->entity);
193} elseif ($action ==
'set_FICHINTER_WITHOUT_DURATION') {
194 $val =
GETPOST(
'FICHINTER_WITHOUT_DURATION',
'alpha');
195 $res =
dolibarr_set_const($db,
"FICHINTER_WITHOUT_DURATION", ($val ==
'on' ? 1 : 0),
'bool', 0,
'', $conf->entity);
206} elseif ($action ==
'set_FICHINTER_DATE_WITHOUT_HOUR') {
207 $val =
GETPOST(
'FICHINTER_DATE_WITHOUT_HOUR',
'alpha');
208 $res =
dolibarr_set_const($db,
"FICHINTER_DATE_WITHOUT_HOUR", ($val ==
'on' ? 1 : 0),
'bool', 0,
'', $conf->entity);
219} elseif ($action ==
"set_FICHINTER_ALLOW_ONLINE_SIGN") {
220 $val =
GETPOST(
'FICHINTER_ALLOW_ONLINE_SIGN',
'alpha');
221 $res =
dolibarr_set_const($db,
"FICHINTER_ALLOW_ONLINE_SIGN", ($val ==
'on' ? 1 : 0),
'bool', 0,
'', $conf->entity);
232} elseif ($action ==
"set_FICHINTER_ALLOW_EXTERNAL_DOWNLOAD") {
233 $val =
GETPOST(
'FICHINTER_ALLOW_EXTERNAL_DOWNLOAD',
'alpha');
234 $res =
dolibarr_set_const($db,
"FICHINTER_ALLOW_EXTERNAL_DOWNLOAD", ($val ==
'on' ? 1 : 0),
'bool', 0,
'', $conf->entity);
253$dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
255llxHeader(
'',
'',
'',
'', 0, 0,
'',
'',
'',
'mod-admin page-fichinter');
257$form =
new Form($db);
259$linkback =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToModuleList").
'</a>';
260print
load_fiche_titre($langs->trans(
"InterventionsSetup"), $linkback,
'title_setup');
265print
dol_get_fiche_head($head,
'ficheinter', $langs->trans(
"Interventions"), -1,
'intervention');
271print
'<div class="div-table-responsive-no-min">';
272print
'<table class="noborder centpercent">';
273print
'<tr class="liste_titre">';
274print
'<td width="100">'.$langs->trans(
"Name").
'</td>';
275print
'<td>'.$langs->trans(
"Description").
'</td>';
276print
'<td>'.$langs->trans(
"Example").
'</td>';
277print
'<td align="center" width="60">'.$langs->trans(
"Status").
'</td>';
278print
'<td align="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
283foreach ($dirmodels as $reldir) {
287 $handle = opendir($dir);
288 if (is_resource($handle)) {
289 while (($file = readdir($handle)) !==
false) {
290 if (preg_match(
'/^(mod_.*)\.php$/i', $file, $reg)) {
292 $classname = substr($file, 4);
294 require_once $dir.$file.
'.php';
296 $module =
new $file();
298 if ($module->isEnabled()) {
300 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
303 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
308 print
'<tr class="oddeven"><td>'.$module->nom.
"</td><td>\n";
309 print $module->info($langs);
313 print
'<td class="nowrap">';
314 $tmp = $module->getExample();
315 if (preg_match(
'/^Error/', $tmp)) {
316 $langs->load(
"errors");
317 print
'<div class="error">'.$langs->trans($tmp).
'</div>';
318 } elseif ($tmp ==
'NotConfigured') {
319 print
'<span class="opacitymedium">'.$langs->trans($tmp).
'</span>';
325 print
'<td class="center">';
326 if ($conf->global->FICHEINTER_ADDON == $classname) {
327 print
img_picto($langs->trans(
"Activated"),
'switch_on');
329 print
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?action=setmod&token='.
newToken().
'&value='.urlencode($classname).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
334 $ficheinter->initAsSpecimen();
338 $htmltooltip .=
''.$langs->trans(
"Version").
': <b>'.$module->getVersion().
'</b><br>';
339 $nextval = $module->getNextValue($mysoc, $ficheinter);
340 if (
"$nextval" != $langs->trans(
"NotAvailable")) {
341 $htmltooltip .=
''.$langs->trans(
"NextValue").
': ';
343 if (preg_match(
'/^Error/', $nextval) || $nextval ==
'NotConfigured') {
344 $nextval = $langs->trans($nextval);
346 $htmltooltip .= $nextval.
'<br>';
348 $htmltooltip .= $langs->trans($module->error).
'<br>';
351 print
'<td class="center">';
352 print $form->textwithpicto(
'', $htmltooltip, 1, 0);
380$sql .=
" FROM ".MAIN_DB_PREFIX.
"document_model";
381$sql .=
" WHERE type = '".$db->escape($type).
"'";
382$sql .=
" AND entity = ".$conf->entity;
383$resql = $db->query($sql);
386 $num_rows = $db->num_rows($resql);
387 while ($i < $num_rows) {
388 $array = $db->fetch_array($resql);
389 if (is_array($array)) {
390 array_push($def, $array[0]);
399print
'<div class="div-table-responsive-no-min">';
400print
'<table class="noborder centpercent">';
401print
'<tr class="liste_titre">';
402print
'<td>'.$langs->trans(
"Name").
'</td>';
403print
'<td>'.$langs->trans(
"Description").
'</td>';
404print
'<td align="center" width="60">'.$langs->trans(
"Status").
"</td>\n";
405print
'<td align="center" width="60">'.$langs->trans(
"Default").
"</td>\n";
406print
'<td align="center" width="80">'.$langs->trans(
"ShortInfo").
'</td>';
407print
'<td align="center" width="80">'.$langs->trans(
"Preview").
'</td>';
412foreach ($dirmodels as $reldir) {
413 $realpath = $reldir.
"core/modules/fichinter/doc";
417 $handle = opendir($dir);
418 if (is_resource($handle)) {
420 while (($file = readdir($handle)) !==
false) {
426 foreach ($filelist as $file) {
427 if (preg_match(
'/\.modules\.php$/i', $file) && preg_match(
'/^(pdf_|doc_)/', $file)) {
428 if (file_exists($dir.
'/'.$file)) {
429 $name = substr($file, 4,
dol_strlen($file) - 16);
430 $classname = substr($file, 0,
dol_strlen($file) - 12);
432 require_once $dir.
'/'.$file;
433 $module =
new $classname($db);
435 $modulequalified = 1;
436 if ($module->version ==
'development' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2) {
437 $modulequalified = 0;
439 if ($module->version ==
'experimental' &&
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1) {
440 $modulequalified = 0;
443 if ($modulequalified) {
444 print
'<tr class="oddeven"><td width="100">';
445 print(empty($module->name) ? $name : $module->
name);
447 if (method_exists($module,
'info')) {
448 print $module->info($langs);
450 print $module->description;
455 if (in_array($name, $def)) {
456 print
"<td align=\"center\">\n";
457 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=del&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'">';
458 print
img_picto($langs->trans(
"Enabled"),
'switch_on');
462 print
"<td align=\"center\">\n";
463 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=set&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'">'.
img_picto($langs->trans(
"Disabled"),
'switch_off').
'</a>';
468 print
"<td align=\"center\">";
469 if ($conf->global->FICHEINTER_ADDON_PDF ==
"$name") {
470 print
img_picto($langs->trans(
"Default"),
'on');
472 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=setdoc&token='.
newToken().
'&value='.urlencode($name).
'&scan_dir='.urlencode($module->scandir).
'&label='.urlencode($module->name).
'" alt="'.$langs->trans(
"Default").
'">'.
img_picto($langs->trans(
"Disabled"),
'off').
'</a>';
477 $htmltooltip =
''.$langs->trans(
"Name").
': '.$module->name;
478 $htmltooltip .=
'<br>'.$langs->trans(
"Type").
': '.($module->type ? $module->type : $langs->trans(
"Unknown"));
479 $htmltooltip .=
'<br>'.$langs->trans(
"Width").
'/'.$langs->trans(
"Height").
': '.$module->page_largeur.
'/'.$module->page_hauteur;
480 $htmltooltip .=
'<br>'.$langs->trans(
"Path").
': '.preg_replace(
'/^\//',
'', $realpath).
'/'.$file;
482 $htmltooltip .=
'<br><br><u>'.$langs->trans(
"FeaturesSupported").
':</u>';
483 $htmltooltip .=
'<br>'.$langs->trans(
"Logo").
': '.
yn($module->option_logo, 1, 1);
484 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentMode").
': '.
yn($module->option_modereg, 1, 1);
485 $htmltooltip .=
'<br>'.$langs->trans(
"PaymentConditions").
': '.
yn($module->option_condreg, 1, 1);
486 $htmltooltip .=
'<br>'.$langs->trans(
"MultiLanguage").
': '.
yn($module->option_multilang, 1, 1);
487 $htmltooltip .=
'<br>'.$langs->trans(
"WatermarkOnDraftOrders").
': '.
yn($module->option_draft_watermark, 1, 1);
488 print
'<td class="center">';
489 print $form->textwithpicto(
'', $htmltooltip, -1, 0);
493 print
'<td class="center">';
494 if ($module->type ==
'pdf') {
495 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=specimen&module='.$name.
'">'.
img_object($langs->trans(
"Preview"),
'pdf').
'</a>';
497 print
img_object($langs->trans(
"PreviewNotAvailable"),
'generic');
520print
'<div class="div-table-responsive-no-min">';
521print
'<table class="noborder centpercent">';
522print
'<tr class="liste_titre">';
523print
'<td>'.$langs->trans(
"Parameter").
'</td>';
524print
'<td align="center" width="60">'.$langs->trans(
"Value").
'</td>';
525print
"<td> </td>\n";
529$substitutionarray[
'__(AnyTranslationKey)__'] = $langs->trans(
"Translation");
530$htmltext =
'<i>'.$langs->trans(
"AvailableVariables").
':<br>';
531foreach ($substitutionarray as $key => $val) {
532 $htmltext .= $key.
'<br>';
536print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
537print
'<input type="hidden" name="token" value="'.newToken().
'">';
538print
'<input type="hidden" name="action" value="set_FICHINTER_FREE_TEXT">';
539print
'<tr class="oddeven"><td colspan="2">';
540print $form->textwithpicto($langs->trans(
"FreeLegalTextOnInterventions"), $langs->trans(
"AddCRIfTooLong").
'<br><br>'.$htmltext, 1,
'help',
'', 0, 2,
'freetexttooltip').
'<br>';
541$variablename =
'FICHINTER_FREE_TEXT';
543 print
'<textarea name="'.$variablename.
'" class="flat" cols="120">'.
getDolGlobalString($variablename).
'</textarea>';
545 include_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
547 print $doleditor->Create();
549print
'</td><td class="right">';
550print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
555print
"<form method=\"post\" action=\"".$_SERVER[
"PHP_SELF"].
"\">";
556print
'<input type="hidden" name="token" value="'.newToken().
'">';
557print
"<input type=\"hidden\" name=\"action\" value=\"set_FICHINTER_DRAFT_WATERMARK\">";
558print
'<tr class="oddeven"><td>';
559print $form->textwithpicto($langs->trans(
"WatermarkOnDraftInterventionCards"), $htmltext, 1,
'help',
'', 0, 2,
'watermarktooltip').
'<br>';
561print
'<input class="flat minwidth200" type="text" name="FICHINTER_DRAFT_WATERMARK" value="'.dol_escape_htmltag(
getDolGlobalString(
'FICHINTER_DRAFT_WATERMARK')).
'">';
562print
'</td><td class="right">';
563print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
567print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
568print
'<input type="hidden" name="token" value="'.newToken().
'">';
569print
'<input type="hidden" name="action" value="set_FICHINTER_PRINT_PRODUCTS">';
570print
'<tr class="oddeven"><td>';
571print $langs->trans(
"PrintProductsOnFichinter").
' ('.$langs->trans(
"PrintProductsOnFichinterDetails").
')</td>';
572print
'<td align="center"><input type="checkbox" name="FICHINTER_PRINT_PRODUCTS" ';
577print
'</td><td class="right">';
578print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
582print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
583print
'<input type="hidden" name="token" value="'.newToken().
'">';
584print
'<input type="hidden" name="action" value="set_FICHINTER_USE_SERVICE_DURATION">';
585print
'<tr class="oddeven">';
587print $langs->trans(
"UseServicesDurationOnFichinter");
589print
'<td class="center">';
590print
'<input type="checkbox" name="FICHINTER_USE_SERVICE_DURATION"'.(getDolGlobalString(
"FICHINTER_USE_SERVICE_DURATION") ?
' checked' :
'').
'>';
592print
'<td class="right">';
593print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
598print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
599print
'<input type="hidden" name="token" value="'.newToken().
'">';
600print
'<input type="hidden" name="action" value="set_FICHINTER_WITHOUT_DURATION">';
601print
'<tr class="oddeven">';
603print $langs->trans(
"UseDurationOnFichinter");
605print
'<td class="center">';
606print
'<input type="checkbox" name="FICHINTER_WITHOUT_DURATION"'.(getDolGlobalString(
"FICHINTER_WITHOUT_DURATION") ?
' checked' :
'').
'>';
608print
'<td class="right">';
609print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
614print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
615print
'<input type="hidden" name="token" value="'.newToken().
'">';
616print
'<input type="hidden" name="action" value="set_FICHINTER_DATE_WITHOUT_HOUR">';
617print
'<tr class="oddeven">';
619print $langs->trans(
"UseDateWithoutHourOnFichinter");
621print
'<td class="center">';
622print
'<input type="checkbox" name="FICHINTER_DATE_WITHOUT_HOUR"'.(getDolGlobalString(
"FICHINTER_DATE_WITHOUT_HOUR") ?
' checked' :
'').
'>';
624print
'<td class="right">';
625print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
630print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
631print
'<input type="hidden" name="token" value="'.newToken().
'">';
632print
'<input type="hidden" name="action" value="set_FICHINTER_ALLOW_ONLINE_SIGN">';
633print
'<tr class="oddeven">';
635print $langs->trans(
"AllowOnlineSign");
637print
'<td class="center">';
638print
'<input type="checkbox" name="FICHINTER_ALLOW_ONLINE_SIGN"'.(getDolGlobalString(
"FICHINTER_ALLOW_ONLINE_SIGN") ?
' checked' :
'').
'>';
640print
'<td class="right">';
641print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
646print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
647print
'<input type="hidden" name="token" value="'.newToken().
'">';
648print
'<input type="hidden" name="action" value="set_FICHINTER_ALLOW_EXTERNAL_DOWNLOAD">';
649print
'<tr class="oddeven">';
651print $langs->trans(
"AllowExternalDownload");
653print
'<td class="center">';
654print
'<input type="checkbox" name="FICHINTER_ALLOW_EXTERNAL_DOWNLOAD"'.(getDolGlobalString(
"FICHINTER_ALLOW_EXTERNAL_DOWNLOAD") ?
' checked' :
'').
'>';
656print
'<td class="right">';
657print
'<input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'">';
addDocumentModel($name, $type, $label='', $description='')
Add document model used by doc generator.
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
delDocumentModel($name, $type)
Delete document model used by doc generator.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage a WYSIWYG editor.
Class to manage interventions.
fichinter_admin_prepare_head()
Return array head with list of tabs to view object information.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
yn($yesno, $case=1, $color=0)
Return yes or no in current language.
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.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
$conf db name
Only used if Module[ID]Name translation string is not found.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.