37 require
'../../main.inc.php';
38 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
45 $langs->loadLangs(array(
'companies',
'bills',
'banks',
'compta'));
47 $action =
GETPOST(
'action',
'alpha');
48 $massaction =
GETPOST(
'massaction',
'alpha');
49 $optioncss =
GETPOST(
'optioncss',
'alpha');
50 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'vendorpaymentlist';
52 $socid =
GETPOST(
'socid',
'int');
55 if ($user->socid) $socid = $user->socid;
57 $search_ref =
GETPOST(
'search_ref',
'alpha');
58 $search_date_startday =
GETPOST(
'search_date_startday',
'int');
59 $search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
60 $search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
61 $search_date_endday =
GETPOST(
'search_date_endday',
'int');
62 $search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
63 $search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
64 $search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
65 $search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
66 $search_company =
GETPOST(
'search_company',
'alpha');
67 $search_payment_type =
GETPOST(
'search_payment_type');
68 $search_cheque_num =
GETPOST(
'search_cheque_num',
'alpha');
69 $search_bank_account =
GETPOST(
'search_bank_account',
'int');
70 $search_amount =
GETPOST(
'search_amount',
'alpha');
72 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
73 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
74 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
77 if (empty($page) || $page == -1) {
80 $offset = $limit * $page;
81 $pageprev = $page - 1;
82 $pagenext = $page + 1;
88 $sortfield =
"p.datep";
94 $fieldstosearchall = array(
95 'p.ref'=>
"RefPayment",
96 's.nom'=>
"ThirdParty",
97 'p.num_paiement'=>
"Numero",
101 $arrayfields = array(
102 'p.ref' =>array(
'label'=>
"RefPayment",
'checked'=>1,
'position'=>10),
103 'p.datep' =>array(
'label'=>
"Date",
'checked'=>1,
'position'=>20),
104 's.nom' =>array(
'label'=>
"ThirdParty",
'checked'=>1,
'position'=>30),
105 'c.libelle' =>array(
'label'=>
"Type",
'checked'=>1,
'position'=>40),
106 'p.num_paiement' =>array(
'label'=>
"Numero",
'checked'=>1,
'position'=>50,
'tooltip'=>
"ChequeOrTransferNumber"),
107 'ba.label' =>array(
'label'=>
"Account",
'checked'=>1,
'position'=>60,
'enable'=>(
isModEnabled(
"banque"))),
108 'p.amount' =>array(
'label'=>
"Amount",
'checked'=>1,
'position'=>70),
113 $hookmanager->initHooks(array(
'paymentsupplierlist'));
118 $socid = $user->socid;
127 if ((!
isModEnabled(
'fournisseur') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))
128 || (!
isModEnabled(
'supplier_invoice') && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))) {
131 if ((empty($user->rights->fournisseur->facture->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))
132 || (empty($user->rights->supplier_invoice->lire) && !empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD))) {
141 $parameters = array(
'socid'=>$socid);
142 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
147 if (empty($reshook)) {
148 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
150 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
152 $search_date_startday =
'';
153 $search_date_startmonth =
'';
154 $search_date_startyear =
'';
155 $search_date_endday =
'';
156 $search_date_endmonth =
'';
157 $search_date_endyear =
'';
158 $search_date_start =
'';
159 $search_date_end =
'';
160 $search_company =
'';
161 $search_payment_type =
'';
162 $search_cheque_num =
'';
163 $search_bank_account =
'';
172 llxHeader(
'', $langs->trans(
'ListPayment'));
176 $accountstatic =
new Account($db);
177 $companystatic =
new Societe($db);
180 $sql =
'SELECT p.rowid, p.ref, p.datep, p.amount as pamount, p.num_paiement';
181 $sql .=
', s.rowid as socid, s.nom as name, s.email';
182 $sql .=
', c.code as paiement_type, c.libelle as paiement_libelle';
183 $sql .=
', ba.rowid as bid, ba.ref as bref, ba.label as blabel, ba.number, ba.account_number as account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal as accountancy_journal';
184 if (empty($user->rights->societe->client->voir)) {
185 $sql .=
', sc.fk_soc, sc.fk_user';
187 $sql .=
', SUM(pf.amount)';
189 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiementfourn AS p';
190 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'paiementfourn_facturefourn AS pf ON p.rowid=pf.fk_paiementfourn';
191 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'facture_fourn AS f ON f.rowid=pf.fk_facturefourn';
192 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement AS c ON p.fk_paiement = c.id';
193 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'societe AS s ON s.rowid = f.fk_soc';
194 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
195 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank_account as ba ON b.fk_account = ba.rowid';
196 if (empty($user->rights->societe->client->voir)) {
197 $sql .=
', '.MAIN_DB_PREFIX.
'societe_commerciaux as sc';
200 $sql .=
' WHERE f.entity = '.$conf->entity;
201 if (empty($user->rights->societe->client->voir)) {
202 $sql .=
' AND s.rowid = sc.fk_soc AND sc.fk_user = '.((int) $user->id);
205 $sql .=
' AND f.fk_soc = '.((int) $socid);
210 if ($search_date_start) {
211 $sql .=
" AND p.datep >= '" . $db->idate($search_date_start) .
"'";
213 if ($search_date_end) {
214 $sql .=
" AND p.datep <= '" . $db->idate($search_date_end) .
"'";
217 if ($search_company) {
220 if ($search_payment_type !=
'') {
221 $sql .=
" AND c.code='".$db->escape($search_payment_type).
"'";
223 if ($search_cheque_num !=
'') {
226 if ($search_amount) {
229 if ($search_bank_account > 0) {
230 $sql .=
' AND b.fk_account = '.((int) $search_bank_account);
233 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
237 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
239 $sql .=
' GROUP BY p.rowid, p.ref, p.datep, p.amount, p.num_paiement, s.rowid, s.nom, s.email, c.code, c.libelle,';
240 $sql .=
' ba.rowid, ba.ref, ba.label, ba.number, ba.account_number, ba.iban_prefix, ba.bic, ba.currency_code, ba.fk_accountancy_journal';
241 if (empty($user->rights->societe->client->voir)) {
242 $sql .=
', sc.fk_soc, sc.fk_user';
245 $sql .= $db->order($sortfield, $sortorder);
248 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
249 $result = $db->query($sql);
257 $sql .= $db->plimit($limit + 1, $offset);
259 $resql = $db->query($sql);
267 $num = $db->num_rows(
$resql);
271 if (!empty($contextpage) && $contextpage != $_SERVER[
'PHP_SELF']) {
272 $param .=
'&contextpage='.urlencode($contextpage);
274 if ($limit > 0 && $limit != $conf->liste_limit) {
275 $param .=
'&limit='.urlencode($limit);
277 if ($optioncss !=
'') {
278 $param .=
'&optioncss='.urlencode($optioncss);
282 $param .=
'&search_ref='.urlencode($search_ref);
284 if ($search_date_startday) {
285 $param .=
'&search_date_startday='.urlencode($search_date_startday);
287 if ($search_date_startmonth) {
288 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
290 if ($search_date_startyear) {
291 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
293 if ($search_date_endday) {
294 $param .=
'&search_date_endday='.urlencode($search_date_endday);
296 if ($search_date_endmonth) {
297 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
299 if ($search_date_endyear) {
300 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
302 if ($search_company) {
303 $param .=
'&search_company='.urlencode($search_company);
305 if ($search_payment_type) {
306 $param .=
'&search_company='.urlencode($search_payment_type);
308 if ($search_cheque_num) {
309 $param .=
'&search_cheque_num='.urlencode($search_cheque_num);
311 if ($search_amount) {
312 $param .=
'&search_amount='.urlencode($search_amount);
316 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
318 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
319 if ($optioncss !=
'') {
320 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
322 print
'<input type="hidden" name="token" value="'.newToken().
'">';
323 print
'<input type="hidden" name="action" value="list">';
324 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
325 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
326 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
327 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
329 print_barre_liste($langs->trans(
'SupplierPayments'), $page, $_SERVER[
'PHP_SELF'], $param, $sortfield, $sortorder,
'', $num,
$nbtotalofrecords,
'supplier_invoice', 0,
'',
'', $limit, 0, 0, 1);
332 foreach ($fieldstosearchall as $key => $val) {
333 $fieldstosearchall[$key] = $langs->trans($val);
335 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>';
340 $parameters = array();
341 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
342 if (empty($reshook)) {
343 $moreforfilter .= $hookmanager->resPrint;
345 $moreforfilter = $hookmanager->resPrint;
348 if ($moreforfilter) {
349 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
350 print $moreforfilter;
354 $varpage = empty($contextpage) ? $_SERVER[
'PHP_SELF'] : $contextpage;
355 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
356 if (!empty($massactionbutton)) {
357 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
360 print
'<div class="div-table-responsive">';
361 print
'<table class="tagtable nobottomiftotal liste'.($moreforfilter ?
" listwithfilterbefore" :
'').
'">';
363 print
'<tr class="liste_titre_filter">';
366 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
367 print
'<td class="liste_titre left">';
368 print
'<input class="flat" type="text" size="4" name="search_ref" value="'.dol_escape_htmltag($search_ref).
'">';
373 if (!empty($arrayfields[
'p.datep'][
'checked'])) {
374 print
'<td class="liste_titre center">';
375 print
'<div class="nowrap">';
376 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
378 print
'<div class="nowrap">';
379 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
385 if (!empty($arrayfields[
's.nom'][
'checked'])) {
386 print
'<td class="liste_titre">';
387 print
'<input class="flat" type="text" size="6" name="search_company" value="'.dol_escape_htmltag($search_company).
'">';
392 if (!empty($arrayfields[
'c.libelle'][
'checked'])) {
393 print
'<td class="liste_titre">';
394 $form->select_types_paiements($search_payment_type,
'search_payment_type',
'', 2, 1, 1);
399 if (!empty($arrayfields[
'p.num_paiement'][
'checked'])) {
400 print
'<td class="liste_titre">';
401 print
'<input class="flat" type="text" size="4" name="search_cheque_num" value="'.dol_escape_htmltag($search_cheque_num).
'">';
406 if (!empty($arrayfields[
'ba.label'][
'checked'])) {
407 print
'<td class="liste_titre">';
408 $form->select_comptes($search_bank_account,
'search_bank_account', 0,
'', 1);
413 if (!empty($arrayfields[
'p.amount'][
'checked'])) {
414 print
'<td class="liste_titre right">';
415 print
'<input class="flat" type="text" size="4" name="search_amount" value="'.dol_escape_htmltag($search_amount).
'">';
420 $parameters = array(
'arrayfields'=>$arrayfields);
421 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
422 print $hookmanager->resPrint;
425 print
'<td class="liste_titre maxwidthsearch">';
426 print
$form->showFilterAndCheckAddButtons(0);
431 print
'<tr class="liste_titre">';
432 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
435 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
436 print_liste_field_titre($arrayfields[
'p.ref'][
'label'], $_SERVER[
"PHP_SELF"],
'p.rowid',
'', $param,
'', $sortfield, $sortorder);
438 if (!empty($arrayfields[
'p.datep'][
'checked'])) {
439 print_liste_field_titre($arrayfields[
'p.datep'][
'label'], $_SERVER[
"PHP_SELF"],
'p.datep',
'', $param,
'', $sortfield, $sortorder,
'center ');
441 if (!empty($arrayfields[
's.nom'][
'checked'])) {
442 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
's.nom',
'', $param,
'', $sortfield, $sortorder);
444 if (!empty($arrayfields[
'c.libelle'][
'checked'])) {
445 print_liste_field_titre($arrayfields[
'c.libelle'][
'label'], $_SERVER[
"PHP_SELF"],
'c.libelle',
'', $param,
'', $sortfield, $sortorder);
447 if (!empty($arrayfields[
'p.num_paiement'][
'checked'])) {
448 print_liste_field_titre($arrayfields[
'p.num_paiement'][
'label'], $_SERVER[
"PHP_SELF"],
"p.num_paiement",
'', $param,
'', $sortfield, $sortorder,
'', $arrayfields[
'p.num_paiement'][
'tooltip']);
450 if (!empty($arrayfields[
'ba.label'][
'checked'])) {
451 print_liste_field_titre($arrayfields[
'ba.label'][
'label'], $_SERVER[
"PHP_SELF"],
'ba.label',
'', $param,
'', $sortfield, $sortorder);
453 if (!empty($arrayfields[
'p.amount'][
'checked'])) {
454 print_liste_field_titre($arrayfields[
'p.amount'][
'label'], $_SERVER[
"PHP_SELF"],
'p.amount',
'', $param,
'', $sortfield, $sortorder,
'right ');
458 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
459 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
460 print $hookmanager->resPrint;
462 print_liste_field_titre($selectedfields, $_SERVER[
'PHP_SELF'],
'',
'',
'',
'align="center"', $sortfield, $sortorder,
'maxwidthsearch ');
466 foreach ($arrayfields as $column) {
467 if ($column[
'checked']) {
473 $totalarray = array();
474 while ($i < min($num, $limit)) {
475 $objp = $db->fetch_object(
$resql);
477 $paymentfournstatic->id = $objp->rowid;
478 $paymentfournstatic->ref = $objp->ref;
479 $paymentfournstatic->datepaye = $objp->datep;
481 $companystatic->id = $objp->socid;
482 $companystatic->name = $objp->name;
483 $companystatic->email = $objp->email;
485 print
'<tr class="oddeven">';
488 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) {
489 print
'<td class="nowraponall">'.(($offset * $limit) + $i).
'</td>';
491 $totalarray[
'nbfield']++;
496 if (!empty($arrayfields[
'p.ref'][
'checked'])) {
497 print
'<td class="nowraponall">'.$paymentfournstatic->getNomUrl(1).
'</td>';
499 $totalarray[
'nbfield']++;
504 if (!empty($arrayfields[
'p.datep'][
'checked'])) {
505 $dateformatforpayment =
'dayhour';
506 print
'<td class="nowrap center">'.dol_print_date($db->jdate($objp->datep), $dateformatforpayment).
'</td>';
508 $totalarray[
'nbfield']++;
513 if (!empty($arrayfields[
's.nom'][
'checked'])) {
514 print
'<td class="tdoverflowmax125">';
515 if ($objp->socid > 0) {
516 print $companystatic->getNomUrl(1,
'', 24);
520 $totalarray[
'nbfield']++;
525 if (!empty($arrayfields[
'c.libelle'][
'checked'])) {
526 $payment_type = $langs->trans(
"PaymentType".$objp->paiement_type) != (
"PaymentType".$objp->paiement_type) ? $langs->trans(
"PaymentType".$objp->paiement_type) : $objp->paiement_libelle;
527 print
'<td>'.$payment_type.
' '.
dol_trunc($objp->num_paiement, 32).
'</td>';
529 $totalarray[
'nbfield']++;
534 if (!empty($arrayfields[
'p.num_paiement'][
'checked'])) {
535 print
'<td>'.$objp->num_paiement.
'</td>';
537 $totalarray[
'nbfield']++;
542 if (!empty($arrayfields[
'ba.label'][
'checked'])) {
543 print
'<td class="tdoverflowmax125">';
545 $accountstatic->id = $objp->bid;
546 $accountstatic->ref = $objp->bref;
547 $accountstatic->label = $objp->blabel;
548 $accountstatic->number = $objp->number;
549 $accountstatic->iban = $objp->iban_prefix;
550 $accountstatic->bic = $objp->bic;
551 $accountstatic->currency_code = $objp->currency_code;
552 $accountstatic->account_number = $objp->account_number;
555 $accountingjournal->fetch($objp->accountancy_journal);
556 $accountstatic->accountancy_journal = $accountingjournal->code;
558 print $accountstatic->getNomUrl(1);
564 $totalarray[
'nbfield']++;
569 if (!empty($arrayfields[
'p.amount'][
'checked'])) {
570 print
'<td class="right"><span class="amount">'.price($objp->pamount).
'</span></td>';
572 $totalarray[
'nbfield']++;
574 $totalarray[
'pos'][$checkedCount] =
'amount';
575 $totalarray[
'val'][
'amount'] += $objp->pamount;
581 $totalarray[
'nbfield']++;
589 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage bank accounts.
Class to manage accounting accounts.
Class to manage payments for supplier invoices.
Class to manage third parties objects (customers, suppliers, prospects...)
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
$nbtotalofrecords
Count total nb of records.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.