Example #1
0
	/**
	 * Identify same "customer" as someone with the same customer id, or ip address or email address.
	 *
	 * @return array
	 */
	public function getCustomerIdentifiers()
	{
		$ip = getIp();
		$quote = getCustomerQuote();
		$customerid = $quote->getCustomerId();
		$email = $quote->getBillingAddress()->getEmail();
		if ($email == '') {
			$customer = getCustomer($customerid);
			$email = $customer['custconemail'];
		}

		$identifiers = array(
			$ip,
			$customerid,
			$email,
		);

		return $identifiers;
	}
        echo 'selected';
    }
    ?>
>Pending</option><option value="paid" <?php 
    if ($invo[0]['status'] == 'paid') {
        echo 'selected';
    }
    ?>
>Paid</option><option value="cancelled" <?php 
    if ($invo[0]['status'] == 'pending') {
        echo 'cancelled';
    }
    ?>
>Cancelled</option></select>
<label>Customer Name </label><input type="text" name="name" value="<?php 
    $cust = getCustomer($number);
    echo $cust[0]['cust_name'];
    ?>
" readonly >
<label>Invoice Number </label><input type="text" name="invoice" value="<?php 
    echo $number;
    ?>
"  readonly >
<label>Date issued </label><input type="date" name="date_issued" value="<?php 
    echo $invo[0]['date_issued'];
    ?>
" >
<label>Amount </label><input type="number" name="amount" value="<?php 
    echo $invo[0]['amount'];
    ?>
">
<?php

include 'db/pdo.php';
$jumlah_tabung = $_GET['jumlah_tabung'];
$barangs = getBarangAvail();
$customers = getCustomer();
?>
<div id='customer' class="inner-faktur-choice"><span>Customer : </span>
<input type="text" name="pilih_customer" id="customer" list="datalist2" onchange="showCustomer(this.value)">
	<datalist id="datalist2">
	<?php 
foreach ($customers as $row) {
    ?>
	<option onclick="showCustomer(this.value)" value="<?php 
    echo $row['nama_cust'];
    ?>
"><?php 
    echo $row['nama_cust'];
    ?>
</option>
	<?php 
}
?>
	</datalist>
</div>
<?php 
for ($i = 1; $i <= $jumlah_tabung; $i++) {
    ?>

<div id='tabung-$i' class="inner-faktur-choice"><span>Tabung ke <?php 
    echo $i;
                                        <div id="collapse2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading2">
                                            <div class="panel-body">

                                    <?php 
}
?>

                                            <?php 
if (isset($_GET['phone'])) {
    ?>

                                                <?php 
    $phone = $_GET['phone'];
    ?>
                                                <?php 
    $customer = getCustomer($phone);
    ?>
                                                <?php 
    $customer = mysql_fetch_array($customer);
    ?>
                                            
                                                <form role="form" action="save-order-registered-customer.php" method="post">

                                                    <div class="form-group">
                                                        <label for="first-name">First Name</label>
                                                        <input readonly type="text" id="first-name" name="first-name" class="form-control" placeholder="First Name" value="<?php 
    echo $customer["first_name"];
    ?>
" required>
                                                    </div>
                                            
Example #5
0
		</form>
		
		<table class="adminTable col-100" cellspacing="0">
			<tr>
				<th>Order No.</th>
				<th>Date</th>
				<th>Discount</th>
				<th>Customer</th>
				<th class="col-m-0">Delivery Address</th>
				<th class="col-m-0">District</th>
				<th>Delivery Job</th>
			</tr>
			
			<?php 
foreach ($orders as $o) {
    $cust = getCustomer($o[custNo]);
    $dist = getDistrict($o[distNo]);
    echo '<tr>
							<td>' . $o[ordNo] . '</td>
							<td>' . $o[ordDate] . '</td>
							<td>' . $o[ordDiscount] . '</td>
							<td> <a href="cust_details.php?custNo=' . $cust[custName] . '">' . $cust[custName] . '</td>
							<td class="col-m-0">' . $o[deliAddr] . '</td>
							<td class="col-m-0">' . $dist[distName] . '</td>
							<td> <a href="job_details.php?jobNo=' . $o[jobNo] . '">' . $o[jobNo] . '</a></td>
						</tr>';
}
?>
			
		</table>
		
        $invoice->having_and = "date_between";
        $filter_by_date = "yes";
        $having_and_count = 1;
    }
    $invoice->sort = "date";
    $invoice_all = $invoice->select_all();
    $invoices = $invoice_all->fetchAll();
    foreach ($invoices as $i => $row) {
        $statement['total'] = $statement['total'] + $row['invoice_total'];
        $statement['owing'] = $statement['owing'] + $row['owing'];
        $statement['paid'] = $statement['paid'] + $row['INV_PAID'];
    }
}
$sql = "select DISTINCT(custom_field3) from  " . TB_PREFIX . "invoices where custom_field3 != ''";
$cf3 = $db->query($sql);
$biller_details = getBiller($biller_id);
$customer_details = getCustomer($customer_id);
$smarty->assign('biller_id', $biller_id);
$smarty->assign('biller_details', $biller_details);
$smarty->assign('customer_id', $customer_id);
$smarty->assign('customer_details', $customer_details);
$smarty->assign('cf3', $cf3->fetchAll());
$smarty->assign('custom_field3', $custom_field3);
$smarty->assign('filter_by_date', $filter_by_date);
$smarty->assign('invoices', $invoices);
$smarty->assign('statement', $statement);
$smarty->assign('start_date', $start_date);
$smarty->assign('end_date', $end_date);
$smarty->assign('pageActive', 'report');
$smarty->assign('active_tab', '#home');
$smarty->assign('menu', $menu);
Example #7
0
            logger($this)->addError("Mark a fulfillment as invalid", array('bidId' => $id));
            return internalError($response);
        }
        $response->getBody()->write(json_encode(array("code" => 200, "message" => "OK")));
        return $response;
    } catch (PDOException $e) {
        return handleError($e, $response);
    }
});
$app->post('/api/bids/place', function (Request $request, Response $response) {
    if (!array_key_exists('cst_session_id', $request->getCookieParams())) {
        logger($this)->addWarning('No contractor session id', getPath($request));
        return forbidden($response);
    }
    $customerSessionId = $request->getCookieParams()["cst_session_id"];
    $customer = getCustomer($customerSessionId);
    if (!isset($customer)) {
        logger($this)->addWarning('No contractor found by session id', array('cst_session_id' => $customerSessionId, 'uri' => $request->getUri()->getPath()));
        return forbidden($response);
    }
    $bid = json_decode($request->getBody());
    list($product, $amount, $price) = parseBid($bid);
    if (!isset($product)) {
        logger($this)->addWarning('Wrong bid', getPath($request));
        return badRequest($response);
    }
    $customerId = $customer['id'];
    if ($price > $customer['amount']) {
        logger($this)->addWarning("Customer doesn't have enough funds to place the bid with price", array('customer_id' => $customerId, 'price' => $price));
        return conflict($response);
    }
 *  - http://fakester.biz/
 *
 */
// And we're away
require_once "../app/Mage.php";
Mage::app();
// How many orders are we creating
$num_orders = (int) $_GET["orders"];
// Get some random customer information
$customers = getCustomers($num_orders);
// Create a few orders
for ($i = 1; $i <= $num_orders; $i++) {
    // Get random products
    $products = getProducts();
    // Get a customer
    $customer = getCustomer(array_pop($customers));
    // Order some mofo products for some mofo customer
    $order = createOrder($products, $customer);
    printf("Created order %s\n", $order->getIncrementId());
}
/*
 * Get random customer information from fakester.biz
 *
 * @return array
 */
function getCustomers($num_customers)
{
    $url = "http://fakester.biz/json?n={$num_customers}";
    $json = file_get_contents($url);
    $data = json_decode($json);
    /*
Example #9
0
<?php

// initialize
include_once '../../../common/init.php';
if (!isLoggedInAdmin()) {
    redirect('');
} else {
    // include needed database functions
    include_once $BASE_PATH . 'database/customers.php';
    include_once $BASE_PATH . 'database/sales.php';
    $id = $_GET['id'];
    // fetch data
    $customer = getCustomer($id);
    // send data to smarty
    $smarty->assign('customer', $customer);
    $smarty->assign('graph', getCustomerSalesGraph($id));
    // display smarty template
    $smarty->display('manager/customers/view_customer.tpl');
}
                 } else {
                     $user_assigned[$uid] = $uid;
                 }
             }
         }
     }
     addValueArray($field['var'], ${$field}['var']);
     break;
 case 'customer_id':
     if (!isset($_POST[$field['var']])) {
         ${$field}['var'] = 0;
     } else {
         ${$field}['var'] = (int) $_POST[$field['var']];
     }
     if (${$field}['var'] != 0) {
         $customer = getCustomer(${$field}['var']);
         if (!count($customer)) {
             $form_errors[] = __("Can't find the customer you tried to select") . ' (id ' . ${$field}['var'] . ')';
             ${$field}['var'] = '';
             $customer_name_ok = True;
             // Don't trigger the customer_name error
         } else {
             $customer_name = $customer['customer_name'];
             $customer_name_ok = True;
             // Don't trigger the customer_name error
         }
     } else {
         // Maybe just the customer_name is inserted?
         if (isset($_POST['customer_name']) && $_POST['customer_name'] != '') {
             // Trigger error...
             $customer_name_ok = False;
Example #11
0
function user2custInfo($custNo)
{
    $user = getCustomer($custNo);
    $retArr = array("ID" => $user[custNo], "Name" => $user[custName], "Gender" => $user[custGender], "Date of Birth" => $user[custDOB], "Contact" => $user[custTel], "Address" => $user[custAddr], "District No" => $user[distNo]);
    return $retArr;
}
Example #12
0
</div><!--end of header--->
<div style="clear: both;"></div>
<div id="content" class="content">
<h1>New Payment</h1>
<div class="main-content">
<div class="data-form">
<form action="<?php 
    echo $_SERVER['PHP_SELF'];
    ?>
" method="post">  
<label>Invoice Number :</label><input type="text" name="invoice_number" value="<?php 
    echo $invoice;
    ?>
"  readonly >
<label>Customer Name</label> <input type="text" name="name" value="<?php 
    $cust = getCustomer($invoice);
    echo $cust[0]['cust_name'];
    ?>
" readonly >
 <input type="hidden" name="invoice" value="<?php 
    echo $invoice;
    ?>
" >
 <label>Payment Date </label><input type="date" name="payment_date" id="from" value="<?php 
    echo date('m/d/Y');
    ?>
">
<label>Amount Paid </label><input type="number" name="amount">
<label>Payment Code</label> <input type="text" name="code" required>

<div class="controls">
Example #13
0
function readEntryLog($log)
{
    if (!count($log)) {
        return array();
    }
    $return = array();
    if ($log['log_action'] == 'add') {
        $middlestring = _('set to');
    } else {
        $middlestring = _('changed to');
    }
    foreach ($log['log_data'] as $index => $value) {
        if ($index != 'rev_num') {
            switch ($index) {
                case 'entry_name':
                    if ($value == '') {
                        $return[] = _('Entry name') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $return[] = _('Entry name') . ' ' . $middlestring . ' "' . $value . '"';
                    }
                    break;
                case 'entry_title':
                    if ($value == '') {
                        $return[] = _('Entry title') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $return[] = _('Entry title') . ' ' . $middlestring . ' "' . $value . '"';
                    }
                    break;
                case 'time_start':
                    $return[] = _('Start time') . ' ' . $middlestring . ' <i>' . date('H:i d-m-Y', $value) . '</i>';
                    break;
                case 'time_end':
                    $return[] = _('End time') . ' ' . $middlestring . ' <i>' . date('H:i d-m-Y', $value) . '</i>';
                    break;
                case 'area_id':
                    $area = getArea($value);
                    if (count($area)) {
                        $return[] = _('Area') . ' ' . $middlestring . ' <i>' . $area['area_name'] . '</i>';
                    } else {
                        $return[] = _('Area') . ' ' . $middlestring . ' <i>--' . _('Name not found') . '--</i>';
                    }
                    break;
                case 'room_id':
                    $value = splittIDs($value);
                    if (!count($value)) {
                        $return[] = _('Room') . ' ' . $middlestring . ' <i>' . _('Whole area') . '</i>';
                    } else {
                        $values = array();
                        foreach ($value as $id) {
                            if ($id == '0') {
                                $values[] = _('Whole area');
                            } else {
                                $thisone = getRoom($id);
                                if (count($thisone)) {
                                    $values[] = $thisone['room_name'];
                                }
                            }
                        }
                        $return[] = _('Room') . ' ' . $middlestring . ' <i>' . implode(', ', $values) . '</i>';
                    }
                    break;
                case 'user_assigned':
                    $value = splittIDs($value);
                    if (!count($value)) {
                        $return[] = _('Users assigned') . ' ' . $middlestring . ' <i>' . _('Nobody') . '</i>';
                    } else {
                        $values = array();
                        foreach ($value as $id) {
                            if ($id == '0') {
                                $values[] = _('Nobody');
                            } else {
                                $thisone = getUser($id);
                                if (count($thisone)) {
                                    $values[] = $thisone['user_name'];
                                }
                            }
                        }
                        $return[] = _('Users assigned') . ' ' . $middlestring . ' <i>' . implode(', ', $values) . '</i>';
                    }
                    break;
                case 'user_assigned2':
                    if ($value == '') {
                        $return[] = _('Manual user assigned') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $return[] = _('Manual user assigned') . ' ' . $middlestring . ' "' . $value . '"';
                    }
                    break;
                    /*
                    				 * Not in use...
                    				 case 'customer_name':
                    					$return .= _('Customer').' '.$middlestring.' "'.$value.'"';
                    					break;*/
                /*
                				 * Not in use...
                				 case 'customer_name':
                					$return .= _('Customer').' '.$middlestring.' "'.$value.'"';
                					break;*/
                case 'customer_id':
                    if ($value == 0) {
                        $return[] = _('Customer') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $customer = getCustomer($value);
                        if (count($customer)) {
                            $return[] = _('Customer') . ' ' . $middlestring . ' <i>' . $customer['customer_name'] . '</i>';
                        } else {
                            $return[] = _('Customer ID') . ' ' . $middlestring . ' "' . $value . '"';
                        }
                    }
                    break;
                    /*
                    				 * Not in use...	
                    				case 'customer_municipal':
                    					$return .= _('Municipal').' '.$middlestring.' "'.$value.'"';
                    					break;*/
                /*
                				 * Not in use...	
                				case 'customer_municipal':
                					$return .= _('Municipal').' '.$middlestring.' "'.$value.'"';
                					break;*/
                case 'customer_municipal_num':
                    require "libs/municipals_norway.php";
                    if (isset($municipals[$value])) {
                        $return[] = _('Municipal') . ' ' . $middlestring . ' <i>' . $municipals[$value] . '</i>';
                    } elseif ($value == '') {
                        $return[] = _('Municipal') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $return[] = _('Municipal') . ' ' . $middlestring . ' "' . $value . '"';
                    }
                    break;
                case 'contact_person_name':
                    if ($value == '') {
                        $return[] = _('Contact person') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $return[] = _('Contact person') . ' ' . $middlestring . ' "' . $value . '"';
                    }
                    break;
                case 'contact_person_phone':
                    if ($value == '') {
                        $return[] = _('Contact persons phone number') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $return[] = _('Contact persons phone number') . ' ' . $middlestring . ' "' . $value . '"';
                    }
                    break;
                case 'contact_person_email':
                    if ($value == '') {
                        $return[] = _('Contact persons email') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $return[] = _('Contact persons email') . ' ' . $middlestring . ' "' . $value . '"';
                    }
                    break;
                case 'num_person_child':
                    if ($value == "" || $value == 0) {
                        $return[] = _('Number of children') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $return[] = _('Number of children') . ' ' . $middlestring . ' ' . $value;
                    }
                    break;
                case 'num_person_adult':
                    if ($value == "" || $value == 0) {
                        $return[] = _('Number of adults') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $return[] = _('Number of adults') . ' ' . $middlestring . ' ' . $value;
                    }
                    break;
                case 'num_person_count':
                    if ($value == "" || $value == 0) {
                        $return[] = _('Count these numbers') . ' ' . $middlestring . ' <i>' . _('not count in booking system / Datanova / cash register') . '</i>';
                    } else {
                        $return[] = _('Count these numbers') . ' ' . $middlestring . ' <i>' . _('count in booking system') . '</i>';
                    }
                    break;
                case 'program_description':
                    if ($value == '') {
                        $return[] = _('Program description') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $return[] = _('Program description') . ' ' . $middlestring . ' "' . $value . '"';
                    }
                    break;
                case 'service_alco':
                    if ($value) {
                        $return[] = _('Alcohol') . ' <i>' . _('is to be served') . '</i>';
                    } else {
                        $return[] = _('Alcohol') . ' <i>' . _('is not to be served') . '</i>';
                    }
                    break;
                case 'service_description':
                    if ($value == '') {
                        $return[] = _('Service description') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $return[] = _('Service description') . ' ' . $middlestring . ' "' . $value . '"';
                    }
                    break;
                case 'comment':
                    if ($value == '') {
                        $return[] = _('Comment') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $return[] = _('Comment') . ' ' . $middlestring . ' "' . $value . '"';
                    }
                    break;
                case 'infoscreen_txt':
                    if ($value == '') {
                        $return[] = _('Text on infoscreen') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $return[] = _('Text on infoscreen') . ' ' . $middlestring . ' "' . $value . '"';
                    }
                    break;
                case 'invoice':
                    if ($value) {
                        $return[] = _('Invoice') . ' <i>' . _('should be made') . '</i>';
                    } else {
                        $return[] = _('Invoice') . ' <i>' . _('should not be made') . '</i>';
                    }
                    break;
                case 'invoice_info':
                case 'invoice_internal_comment':
                    if ($value == '') {
                        $return[] = _('Invoice') . ' - ' . _('Internal comment') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $return[] = _('Invoice') . ' - ' . _('Internal comment') . ' ' . $middlestring . ' "' . $value . '"';
                    }
                    break;
                case 'invoice_comment':
                    if ($value == '') {
                        $return[] = _('Invoice') . ' - ' . _('Comment') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $return[] = _('Invoice') . ' - ' . _('Comment') . ' ' . $middlestring . ' "' . $value . '"';
                    }
                    break;
                case 'invoice_ref_your':
                    if ($value == '') {
                        $return[] = _('Invoice') . ' - ' . _('Your reference') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $return[] = _('Invoice') . ' - ' . _('Your reference') . ' ' . $middlestring . ' "' . $value . '"';
                    }
                    break;
                case 'invoice_electronic':
                    if ($value) {
                        $return[] = _('Invoice') . ' <i>' . _('is to be sendt by e-mail') . '</i> (' . _('E-delivery') . ')';
                    } else {
                        $return[] = _('Invoice') . ' <i>' . _('is to be sendt by regular mail') . '</i> (' . _('Not') . ' ' . strtolower(_('E-delivery')) . ')';
                    }
                    break;
                case 'invoice_email':
                    if ($value == '') {
                        $return[] = _('Invoice') . ' - ' . _('E-mail') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $return[] = _('Invoice') . ' - ' . _('E-mail') . ' ' . $middlestring . ' "' . $value . '"';
                    }
                    break;
                case 'invoice_address_id':
                    if ($value == 0) {
                        $return[] = _('Invoice') . ' - ' . _('Address') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $address = getAddress($value);
                        if (count($address)) {
                            $return[] = _('Invoice') . ' - ' . _('Address') . ' ' . $middlestring . ' <i>' . str_replace("\n", ', ', $address['address_full']) . '</i>';
                        } else {
                            $return[] = _('Invoice') . ' - ' . _('Address') . ' ' . $middlestring . ' "' . $value . '"';
                        }
                    }
                    break;
                case 'invoice_content':
                    if (!is_array($value)) {
                        $return[] = _('Invoice') . ' - ' . _('Content') . ' has got syntax error in the log.';
                    } else {
                        foreach ($value as $linenr => $line) {
                            $return[] = _('Invoice') . ' - ' . _('Content') . ' - ' . _('line') . ' <i>' . $linenr . '</i> ' . $middlestring . ': ' . _('name') . ': <i>' . $line['name'] . '</i>, ' . 'pris/stk: <i>' . $line['belop_hver'] . '</i>, ' . _('amount') . ': <i>' . $line['antall'] . '</i>, ' . _('tax') . ': <i>' . $line['mva'] * 100 . '%</i>, ' . 'sum u/MVA: <i>' . $line['belop_sum_netto'] . '</i>';
                        }
                    }
                    break;
                case 'program_id':
                    if ($value == 0) {
                        $return[] = _('Fixed program') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $program = getProgram($value);
                        if (count($program)) {
                            $return[] = _('Fixed program') . ' ' . $middlestring . ' <i>' . $program['program_name'] . '</i>';
                        } else {
                            $return[] = _('ID of fixed program') . ' ' . $middlestring . ' "' . $value . '"';
                        }
                    }
                    break;
                case 'entry_type_id':
                    if ($value == 0) {
                        $return[] = _('Entry type') . ' <i>' . _('not set') . '</i>';
                    } else {
                        $entry_type = getEntryType($value);
                        if (count($entry_type)) {
                            $return[] = _('Entry type') . ' ' . $middlestring . ' <i>' . $entry_type['entry_type_name'] . '</i>';
                        } else {
                            $return[] = _('ID of entry type') . ' ' . $middlestring . ' "' . $value . '"';
                        }
                    }
                    break;
                case 'confirm_id':
                    $return[] = '<a href="entry_confirm_view.php?confirm_id=' . $value . '">' . _('Confirmation sent') . '</a>';
                    break;
                case 'confirm_comment':
                    $return[] = _('Comment') . ': ' . $value;
                    break;
                default:
                    if (substr($index, 0, 11) == 'email_faild') {
                        $return[] = _('Confirmation was <b>not sent</b> to') . ' <i>' . $value . '</i>';
                        break;
                    } elseif (substr($index, 0, 5) == 'email') {
                        $return[] = _('Confirmation was sent to') . ' <i>' . $value . '</i>';
                        break;
                    }
                    if (is_array($value)) {
                        $return[] = $index . ' = ' . print_r($value, true);
                    } else {
                        $return[] = $index . ' = ' . $value;
                    }
                    break;
            }
        }
    }
    return $return;
}
Example #14
0
     if ($listtype == 'servering') {
         echo '  <th style="vertical-align: bottom;">Alkohol?</th>' . chr(10);
         echo '  <th style="vertical-align: bottom;">' . __('Service description') . '</th>' . chr(10);
     }
     echo '  <th style="vertical-align: bottom;">' . __('Room') . '</th>' . chr(10);
 }
 echo ' </tr>' . chr(10);
 while ($R = mysql_fetch_assoc($Q)) {
     $entry = getEntryParseDatabaseArray($R);
     if ($listtype == 'customer_list') {
         if (isset($customer_list[$entry['customer_id']])) {
             $customer_list[$entry['customer_id']]['c'] += $entry['num_person_child'];
             $customer_list[$entry['customer_id']]['a'] += $entry['num_person_adult'];
             $customer_list[$entry['customer_id']]['e']++;
         } else {
             $customer_list[$entry['customer_id']] = getCustomer($entry['customer_id']);
             if (!count($customer_list[$entry['customer_id']])) {
                 $customer_list[$entry['customer_id']]['customer_id'] = $entry['customer_id'];
                 if ($entry['customer_id'] == 0) {
                     $customer_list[$entry['customer_id']]['customer_name'] = 'Ingen kunde valgt';
                 } else {
                     $customer_list[$entry['customer_id']]['customer_name'] = 'KUNDE IKKE FUNNET I DATABASE';
                 }
                 $customer_names[$entry['customer_id']] = '';
                 // Sort the unknowns to the top
             } else {
                 $customer_names[$entry['customer_id']] = $customer_list[$entry['customer_id']]['customer_name'];
             }
             $customer_list[$entry['customer_id']]['c'] = $entry['num_person_child'];
             $customer_list[$entry['customer_id']]['a'] = $entry['num_person_adult'];
             $customer_list[$entry['customer_id']]['e'] = 1;
<?php

include_once ROOT . "includes/customers.php";
$lang = get_language();
$firstname = '';
$lastname = '';
$zip = '';
$city = '';
$address1 = '';
$address2 = '';
$email = '';
if (isset($_SESSION["user"])) {
    $customer = getCustomer($_SESSION["user"]->getCostumerId());
    if ($customer != null) {
        $firstname = $customer->getFirstname();
        $lastname = $customer->getLastname();
        if ($customer->getShippingAddress() != null) {
            $zip = $customer->getShippingAddress()->getZip();
            $city = $customer->getShippingAddress()->getCity();
            $address1 = $customer->getShippingAddress()->getAddress1();
            $address2 = $customer->getShippingAddress()->getAddress2();
        }
        $email = $customer->getEmail();
    }
}
echo "<form name=\"billingForm\" action=\"index.php?site=confirm\" onsubmit=\"return validateForm();\" method=\"post\">";
echo "<table class=\"address-form-table\">";
echo "<tr>";
echo "<td class=\"address-form-table-label\">{$AddressFirstnameLabel}: </td>";
echo "<td>";
echo "<input class=\"address-form-field\" type=\"text\" name=\"firstname\" value=\"{$firstname}\"  /input>";
Example #16
0
<?php

//stop the direct browsing to this file - let index.php handle which files get displayed
checkLogin();
$menu = false;
$payment = getPayment($_GET['id']);
/*Code to get the Invoice preference - so can link from this screen back to the invoice - START */
$invoice = getInvoice($payment['ac_inv_id']);
$biller = getBiller($payment['biller_id']);
$logo = getLogo($biller);
$logo = str_replace(" ", "%20", $logo);
$customer = getCustomer($payment['customer_id']);
$invoiceType = getInvoiceType($invoice['type_id']);
$customFieldLabels = getCustomFieldLabels();
$paymentType = getPaymentType($payment['ac_payment_type']);
$preference = getPreference($invoice['preference_id']);
$smarty->assign("payment", $payment);
$smarty->assign("invoice", $invoice);
$smarty->assign("biller", $biller);
$smarty->assign("logo", $logo);
$smarty->assign("customer", $customer);
$smarty->assign("invoiceType", $invoiceType);
$smarty->assign("paymentType", $paymentType);
$smarty->assign("preference", $preference);
$smarty->assign("customFieldLabels", $customFieldLabels);
$smarty->assign('pageActive', 'payment');
$smarty->assign('active_tab', '#money');
Example #17
0
 if (!$db || !@mysql_select_db(DB_NAME, $db)) {
     $rsp['error'] = SL_DB_FAILURE;
     $rsp['info'] = mysql_error();
     respond($rsp);
 }
 error_log("salesApi: action " . $_REQUEST['action']);
 $_silent = isset($_REQUEST['silent']) && $_REQUEST['silent'] == 'true' ? true : false;
 switch ($_REQUEST['action']) {
     case 'getCustomerList':
         return getCustomerList();
     case 'getPaymentList':
         return getPaymentList();
     case 'getCustomerNames':
         return getCustomerNames();
     case 'getCustomer':
         return getCustomer();
     case 'getPaymentDetails':
         return getPaymentDetails();
     case 'getPaymentHistory':
         return getPaymentHistory();
     case 'getLastPayment':
         return getLastPayment();
     case 'newInstance':
         return newInstance($_silent);
     case 'updateInstanceData':
         return updateInstanceData();
     default:
         break;
 }
 // Respond positively
 $rsp['status'] = SL_OK;
Example #18
0
                if (count($address)) {
                    $invoice->invoice_to_line1 = $address['address_line_1'];
                    $invoice->invoice_to_line2 = $address['address_line_2'];
                    $invoice->invoice_to_line3 = $address['address_line_3'];
                    $invoice->invoice_to_line4 = $address['address_line_4'];
                    $invoice->invoice_to_line5 = $address['address_line_5'];
                    $invoice->invoice_to_line6 = $address['address_line_6'];
                    $invoice->invoice_to_line7 = $address['address_line_7'];
                } else {
                    $invoice->invoice_to_address_id = '';
                }
            } else {
                $invoice->invoice_to_address_id = '';
            }
            if ($invoice->invoice_to_customer_id > 0) {
                $customer = getCustomer($invoice->invoice_to_customer_id);
                if (count($customer)) {
                    $invoice->invoice_to_customer_name = $customer['customer_name'];
                }
            }
        }
    }
}
require "include/invoice_menu.php";
if (isset($preview) && $preview) {
    echo '<h1>ForhĂ¥ndsvisning</h2>';
    echo '<b>(Opprettelse forsetter under)</b><br>';
    echo '<div style="border: 1px solid black; overflow: auto; width: 800px; height: 400px;">';
    $smarty = new Smarty();
    templateAssignInvoice('smarty', $invoice);
    templateAssignSystemvars('smarty');
Example #19
0
include_once "Brain/User.php";
include "header1.php";
?>
<link href="css/register.css" rel="stylesheet" type="text/css" />
<script src='js/register.js'> </script>
<?php 
include "Brain/District.php";
include "Brain/UserControl.php";
include "header2.php";
include_once "Brain/ShoppingCart.php";
$cart = new SCart();
if (isset($_GET["error"])) {
    echo "<script> alert('Sorry, we only delivery two day after order.')</script>";
}
if (UserControl::checkState() && UserControl::getType() == 'c') {
    $cust = getCustomer(getInfo(UserControl::getUserNo())[ID]);
    if (isset($_POST[distNo], $_POST[custAddr], $_POST["sdate"])) {
        $date = strtotime($_POST["sdate"]);
        $minday = strtotime(date("Y-m-d", strtotime("+ 2 days")));
        if ($date < $minday) {
            header("Location: checkout.php?error=true");
        } else {
            if ($cart->checkout($_POST["sdate"], "100", $_POST[custAddr], $cust[custNo], $_POST[distNo])) {
                header("Location: shoppingcart.php?sucess=true");
            } else {
                echo "<script> alert('Sorry!');</script>";
            }
        }
    }
    $district = getAllDistricts();
    $box = "<select name='distNo'>";
Example #20
0
 public function run()
 {
     global $db;
     $today = date('Y-m-d');
     $cron = new cron();
     $data = $cron->select_crons_to_run();
     $return['cron_message'] = "Cron started";
     $number_of_crons_run = "0";
     $cron_log = new cronlog();
     $cron_log->run_date = $today;
     foreach ($data as $key => $value) {
         $cron->domain_id = $value['domain_id'];
         $cron_log->cron_id = $value['id'];
         $cron_log->domain_id = $domain_id = $value['domain_id'];
         $check_cron_log = $cron_log->check();
         $i = "0";
         if ($check_cron_log == 0) {
             //only proceed if cron has not been run for today
             $run_cron = false;
             $start_date = date('Y-m-d', strtotime($value['start_date']));
             $end_date = $value['end_date'];
             // Seconds in a day = 60 * 60 * 24 = 86400
             $diff = number_format((strtotime($today) - strtotime($start_date)) / 86400, 0);
             //only check if diff is positive
             if ($diff >= 0 and ($end_date == "" or $end_date >= $today)) {
                 if ($value['recurrence_type'] == 'day') {
                     $modulus = $diff % $value['recurrence'];
                     if ($modulus == 0) {
                         $run_cron = true;
                     } else {
                         #$return .= "cron does not runs TODAY-days";
                     }
                 }
                 if ($value['recurrence_type'] == 'week') {
                     $period = 7 * $value['recurrence'];
                     $modulus = $diff % $period;
                     if ($modulus == 0) {
                         $run_cron = true;
                     } else {
                         #$return .= "cron is not runs TODAY-week";
                     }
                 }
                 if ($value['recurrence_type'] == 'month') {
                     $start_day = date('d', strtotime($value['start_date']));
                     $start_month = date('m', strtotime($value['start_date']));
                     $start_year = date('Y', strtotime($value['start_date']));
                     $today_day = date('d');
                     $today_month = date('m');
                     $today_year = date('Y');
                     $months = $today_month - $start_month + 12 * ($today_year - $start_year);
                     $modulus = $months % $value['recurrence'];
                     if ($modulus == 0 and $start_day == $today_day) {
                         $run_cron = true;
                     } else {
                         #$return .= "cron is not runs TODAY-month";
                     }
                 }
                 if ($value['recurrence_type'] == 'year') {
                     $start_day = date('d', strtotime($value['start_date']));
                     $start_month = date('m', strtotime($value['start_date']));
                     $start_year = date('Y', strtotime($value['start_date']));
                     $today_day = date('d');
                     $today_month = date('m');
                     $today_year = date('Y');
                     $years = $today_year - $start_year;
                     $modulus = $years % $value['recurrence'];
                     if ($modulus == 0 and $start_day == $today_day and $start_month == $today_month) {
                         $run_cron = true;
                     } else {
                         #$return .= "cron is not runs TODAY-year";
                     }
                 }
                 //run the recurrence for this invoice
                 if ($run_cron) {
                     $number_of_crons_run++;
                     $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " - Cron for " . $value['index_name'] . " with start date of " . $value['start_date'] . ", end date of " . $value['end_date'] . " where it runs each " . $value['recurrence'] . " " . $value['recurrence_type'] . " was run today :: Info diff=" . $diff;
                     $i++;
                     $ni = new invoice();
                     $ni->id = $value['invoice_id'];
                     $ni->domain_id = $domain_id;
                     // $domain_id gets propagated from invoice to be copied from
                     $new_invoice_id = $ni->recur();
                     //insert into cron_log date of run
                     //$cron_log = new cronlog();
                     //$cron_log->run_date = $today;
                     //$cron_log->domain_id = $domain_id;
                     //$cron_log->cron_id = $value['cron_id'];
                     $cron_log->insert();
                     ## email the people
                     $invoiceobj = new invoice();
                     $invoice = $invoiceobj->select($new_invoice_id, $domain_id);
                     $preference = getPreference($invoice['preference_id'], $domain_id);
                     $biller = getBiller($invoice['biller_id'], $domain_id);
                     $customer = getCustomer($invoice['customer_id'], $domain_id);
                     #print_r($customer);
                     #create PDF nameVj
                     $spc2us_pref = str_replace(" ", "_", $invoice['index_name']);
                     $pdf_file_name_invoice = $spc2us_pref . ".pdf";
                     // email invoice
                     if ($value['email_biller'] == "1" or $value['email_customer'] == "1") {
                         $export = new export();
                         $export->domain_id = $domain_id;
                         $export->format = "pdf";
                         $export->file_location = 'file';
                         $export->module = 'invoice';
                         $export->id = $invoice['id'];
                         $export->execute();
                         #$attachment = file_get_contents('./tmp/cache/' . $pdf_file_name);
                         $email = new email();
                         $email->domain_id = $domain_id;
                         $email->format = 'cron_invoice';
                         $email_body = new email_body();
                         $email_body->email_type = 'cron_invoice';
                         $email_body->customer_name = $customer['name'];
                         $email_body->invoice_name = $invoice['index_name'];
                         $email_body->biller_name = $biller['name'];
                         $email->notes = $email_body->create();
                         $email->from = $biller['email'];
                         $email->from_friendly = $biller['name'];
                         $email->to = $this->getEmailSendAddresses($value, $customer['email'], $biller['email']);
                         $email->invoice_name = $invoice['index_name'];
                         $email->subject = $email->set_subject();
                         $email->attachment = $pdf_file_name_invoice;
                         $return['email_message'] = $email->send();
                     }
                     //Check that all details are OK before doing the eway payment
                     $eway_check = new eway();
                     $eway_check->domain_id = $domain_id;
                     $eway_check->invoice = $invoice;
                     $eway_check->customer = $customer;
                     $eway_check->biller = $biller;
                     $eway_check->preference = $preference;
                     $eway_pre_check = $eway_check->pre_check();
                     //do eway payment
                     if ($eway_pre_check == 'true') {
                         // input customerID,  method (REAL_TIME, REAL_TIME_CVN, GEO_IP_ANTI_FRAUD) and liveGateway or not
                         $eway = new eway();
                         $eway->domain_id = $domain_id;
                         $eway->invoice = $invoice;
                         $eway->biller = $biller;
                         $eway->customer = $customer;
                         $payment_done = $eway->payment();
                         $payment_id = $db->lastInsertID();
                         $pdf_file_name_receipt = 'payment' . $payment_id . '.pdf';
                         if ($payment_done == 'true') {
                             //do email of receipt to biller and customer
                             if ($value['email_biller'] == "1" or $value['email_customer'] == "1") {
                                 /*
                                  * If you want a new copy of the invoice being emailed to the customer 
                                  * use this code
                                  */
                                 $export_rec = new export();
                                 $export_rec->domain_id = $domain_id;
                                 $export_rec->format = "pdf";
                                 $export_rec->file_location = 'file';
                                 $export_rec->module = 'invoice';
                                 $export_rec->id = $invoice['id'];
                                 $export_rec->execute();
                                 #$attachment = file_get_contents('./tmp/cache/' . $pdf_file_name);
                                 $email_rec = new email();
                                 $email_rec->domain_id = $domain_id;
                                 $email_rec->format = 'cron_invoice';
                                 $email_body_rec = new email_body();
                                 $email_body_rec->email_type = 'cron_invoice_receipt';
                                 $email_body_rec->customer_name = $customer['name'];
                                 $email_body_rec->invoice_name = $invoice['index_name'];
                                 $email_body_rec->biller_name = $biller['name'];
                                 $email_rec->notes = $email_body_rec->create();
                                 $email_rec->from = $biller['email'];
                                 $email_rec->from_friendly = $biller['name'];
                                 $email_rec->to = $this->getEmailSendAddresses($value, $customer['email'], $biller['email']);
                                 $email_rec->invoice_name = $invoice['index_name'];
                                 $email_rec->attachment = $pdf_file_name_invoice;
                                 $email_rec->subject = $email_rec->set_subject('invoice_eway_receipt');
                                 $return['email_message'] = $email_rec->send();
                                 /*
                                  * If you want a receipt as PDF being emailed to the customer
                                  * uncomment the code below
                                  */
                                 /*
                                 $export = new export();
                                 $export -> format = "pdf";
                                 $export -> file_location = 'file';
                                 $export -> module = 'payment';
                                 $export -> id = $payment_id;
                                 $export -> execute();
                                 
                                 $email = new email();
                                 $email -> format = 'cron_payment';
                                 
                                     $email_body = new email_body();
                                     $email_body->email_type = 'cron_payment';
                                     $email_body->customer_name = $customer['name'];
                                     $email_body->invoice_name = 'payment'.$payment_id;
                                     $email_body->biller_name = $biller['name'];
                                 
                                 $email -> notes = $email_body->create();
                                 $email -> from = $biller['email'];
                                 $email -> from_friendly = $biller['name'];
                                 if($value['email_customer'] == "1")
                                 {
                                     $email -> to = $customer['email'];
                                 }
                                 if($value['email_biller'] == "1" AND $value['email_customer'] == "1")
                                 {
                                     $email -> to = $customer['email'].";".$biller['email'];
                                 }
                                 if($value['email_biller'] == "1" AND $value['email_customer'] == "0")
                                 {
                                     $email -> to = $customer['email'];
                                 }
                                 $email -> subject = $pdf_file_name_receipt." from ".$biller['name'];
                                 $email -> attachment = $pdf_file_name_receipt;
                                 $return['email_message'] = $email->send();
                                 */
                             }
                         } else {
                             //do email to biller/admin - say error
                             $email = new email();
                             $email->domain_id = $domain_id;
                             $email->format = 'cron_payment';
                             $email->from = $biller['email'];
                             $email->from_friendly = $biller['name'];
                             $email->to = $biller['email'];
                             $email->subject = "Payment failed for " . $invoice['index_name'];
                             $error_message = "Invoice:  " . $invoice['index_name'] . "<br /> Amount: " . $invoice['total'] . " <br />";
                             foreach ($eway->get_message() as $key => $value) {
                                 $error_message .= "\n<br>\$ewayResponseFields[\"{$key}\"] = {$value}";
                             }
                             $email->notes = $error_message;
                             $return['email_message'] = $email->send();
                         }
                     }
                 } else {
                     //cron not run for this cron_id
                     $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " NOT RUN: Cron for " . $value['index_name'] . " with start date of " . $value['start_date'] . ", end date of " . $value['end_date'] . " where it runs each " . $value['recurrence'] . " " . $value['recurrence_type'] . " did not recur today :: Info diff=" . $diff;
                 }
             } else {
                 //days diff is negative - whats going on
                 $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " NOT RUN: - Not cheduled for today - Cron for " . $value['index_name'] . " with start date of " . $value['start_date'] . ", end date of " . $value['end_date'] . " where it runs each " . $value['recurrence'] . " " . $value['recurrence_type'] . " did not recur today :: Info diff=" . $diff;
             }
         } else {
             // cron has already been run for that cron_id today
             $return['cron_message_' . $value['cron_id']] = "Cron ID: " . $value['cron_id'] . " - Cron has already been run for domain: " . $domain_id . " for the date: " . $today . " for invoice " . $value['invoice_id'];
             $return['email_message'] = "";
         }
     }
     // no crons scheduled for today
     if ($number_of_crons_run == '0') {
         $return['id'] = $i;
         $return['cron_message'] = "No invoices recurred for this cron run for domain: " . $domain_id . " for the date: " . $today;
         $return['email_message'] = "";
     }
     //insert into cron_log date of run
     /*
     		    $cron_log = new cronlog();
         $cron_log->run_date = $today;
         $cron_log->domain_id = $domain_id;
         $cron_log->insert();
     */
     /*
      * If you want to get an email once cron has been run edit the below details
      *
      */
     /*
         $email = new email();
         $email -> format = 'cron';
         #$email -> notes = $return;
         $email -> from = "simpleinvoices@localhost";
         $email -> from_friendly = "Simple Invoices - Cron";
         $email -> to = "simpleinvoices@localhost";
         #$email -> bcc = $_POST['email_bcc'];
         $email -> subject = "Cron for Simple Invoices has been run for today:";
         $email -> send ();
     */
     return $return;
 }
Example #21
0
/**
 * Checks the invoice data an entry contains
 * 
 * @param array getEntry-array
 * @return array Things that failed, [0] is errors, [1] is warnings
 */
function checkInvoicedata($entry)
{
    $errors = array();
    $warnings = array();
    // Any invoice content?
    if (!count($entry['invoice_content'])) {
        $errors[] = 'Ingen fakturalinjer er lagt inn p&aring; bookingen. Det m&aring; v&aerlig;re fakturalinjer for at fakturering skal kunne finne sted.';
    } else {
        $line_num = 0;
        foreach ($entry['invoice_content'] as $line) {
            $line_num++;
            if ($line['name'] == '') {
                $warnings[] = 'Fakturalinje nr ' . $line_num . ' har ikke beskrivelse.';
            } else {
                //$text_split = explode(chr(10), $line['name']);
                //foreach($text_split as $this_text)
                //{
                //	$this_text = trim($this_text);
                //	if(strlen($this_text) > 50)
                //	{
                //		$warnings[] =
                //			'Fakturalinje nr '.$line_num.' har beskrivelse som har bredd lenger enn 50 bokstaver. '.
                //			'Ved eksport blir teksten kuttet til 50 bokstaver. '.
                //			'Du kan fikse dette ved &aring; fordele teksten p&aring; to linjer i beskrivelsesfeltet.';
                //	}
                //}
            }
            // Checking amount
            if ($line['antall'] < 0) {
                $warnings[] = 'Fakturalinje nr ' . $line_num . ' har minus i antall. Pris per stykk kan v&aerlig;re minus.';
            } elseif ($line['antall'] == 0) {
                $warnings[] = 'Fakturalinje nr ' . $line_num . ' har null i antall.';
            }
            // Checking a few export limits
            if ($line['belop_hver'] > 99999999) {
                $errors[] = 'Fakturalinje nr ' . $line_num . ' har for stort bel&oslash;p per stykk. Maks er 99 millioner. Kan ikke fortsette uten at dette rettes f.eks. ved &aring; dele opp i flere fakturalinjer.';
            }
            if ($line['belop_sum_netto'] > 9999999999.0) {
                $errors[] = 'Fakturalinje nr ' . $line_num . ' har for stort bel&oslash;p totalt. Maks er 9999 millioner. Kan ikke fortsette uten at dette rettes f.eks. ved &aring; dele opp i flere fakturalinjer.';
            }
            if ($line['antall'] > 99999999) {
                $errors[] = 'Fakturalinje nr ' . $line_num . ' har for stort antall. Maks er 99 millioner. Kan ikke fortsette uten at dette rettes f.eks. ved &aring; dele opp i flere fakturalinjer.';
            }
        }
    }
    // Checking customer
    if ($entry['customer_id'] == 0) {
        $errors[] = 'Ingen kunde er valgt. Dette m&aring; rettes.';
    } else {
        $customer = getCustomer($entry['customer_id']);
        if (!count($customer)) {
            $errors[] = 'Finner ikke kunden som er valgt. Det kan hende den er slettet. Velg en ny kunde. Dette m&aring; rettes.';
        } else {
            // We have got the customer
            if (strlen($customer['customer_name']) < 1) {
                $errors[] = 'Kundens navn er ikke lagt inn p&aring; kunden. Dette g&aring;r ikke og m&aring; rettes. Kunde m&aring; endres.';
            }
            // Checking address
            if ($entry['invoice_address_id'] == 0) {
                $errors[] = 'Ingen fakturaadresse er valgt. Dette m&aring; rettes.';
            } else {
                $address = getAddress($entry['invoice_address_id']);
                if (!count($address)) {
                    $errors[] = 'Finner ikke addressen som er valgt. Det kan hende den er slettet. Velg en ny adresse. Dette m&aring; rettes.';
                } else {
                    // We got a address
                    if ($address['address_postalnum'] == '') {
                        $warnings[] = 'Det er ikke valgt noe postnummer/poststed for adressen.';
                    }
                }
            }
        }
    }
    return array($errors, $warnings);
}
Example #22
0
    foreach ($postfil as $line) {
        //echo trim(substr($line,4,strlen($_GET['postal_place'])+1)).' <b>----</b> '.$_GET['postal_place'].'<br>';
        if (strtolower(trim(substr($line, 4, strlen($_GET['postal_place'])))) == strtolower($_GET['postal_place'])) {
            $poststed = trim(substr($line, 4, 31));
            $postnum = trim(substr($line, 0, 4));
            $aResults[] = array('id' => $postnum, 'value' => $poststed . ' (' . $postnum . ')', 'info' => $poststed);
            // Returnerer poststedet
        }
    }
} elseif (isset($_GET['postal_num'])) {
    if (strlen($_GET['postal_num']) == 4 && postalNumber($_GET['postal_num'])) {
        echo postalNumber($_GET['postal_num']);
    }
    exit;
} elseif (isset($_GET['customer_id'])) {
    $customer = getCustomer($_GET['customer_id']);
    if (count($customer)) {
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
        // Date in the past
        header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
        // always modified
        header("Cache-Control: no-cache, must-revalidate");
        // HTTP/1.1
        header("Pragma: no-cache");
        // HTTP/1.0
        header("Content-Type: application/json");
        //echo "{\"customer\": [";
        echo "{";
        $arr = array();
        foreach ($customer as $var => $value) {
            if (!is_array($value)) {
Example #23
0
*	 Justin Kelly, Nicolas Ruflin
*
* Last edited:
* 	 2007-07-19
*
* License:
*	 GPL v2 or above
*
* Website:
* 	http://www.simpleinvoices.org
*/
//stop the direct browsing to this file - let index.php handle which files get displayed
checkLogin();
#get the invoice id
$customer_id = $_GET['id'];
$customer = getCustomer($customer_id);
$customer['wording_for_enabled'] = $customer['enabled'] == 1 ? $LANG['enabled'] : $LANG['disabled'];
//TODO: Perhaps possible a bit nicer?
$stuff = null;
$stuff['total'] = calc_customer_total($customer['id'], domain_id::get(), true);
#amount paid calc - start
$stuff['paid'] = calc_customer_paid($customer['id'], domain_id::get(), true);
#amount paid calc - end
#amount owing calc - start
$stuff['owing'] = $stuff['total'] - $stuff['paid'];
#get custom field labels
$customFieldLabel = getCustomFieldLabels();
$invoices = getCustomerInvoices($customer_id);
//$start = (isset($_POST['start'])) ? $_POST['start'] : "0" ;
$dir = "DESC";
$sort = "id";
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
/*
	Merging of customers
*/
$section = 'customer_merge';
include "include/admin_top.php";
if (isset($_GET['cid1']) && is_numeric($_GET['cid1']) && isset($_GET['cid2']) && is_numeric($_GET['cid2'])) {
    $cid1 = $_GET['cid1'];
    $cid2 = $_GET['cid2'];
    $customer1 = getCustomer($cid1);
    $customer2 = getCustomer($cid2);
    if (!count($customer1) || $customer1['slettet']) {
        echo 'Finner ikke kunde 1. ID: ' . $cid1;
        exit;
    }
    if (!count($customer2) || $customer2['slettet']) {
        echo 'Finner ikke kunde 2. ID: ' . $cid2;
        exit;
    }
    filterMakeAlternatives();
    if (isset($_GET['mergego'])) {
        include "include/admin_middel.php";
        echo '<h1>Kundeopprydding</h1>';
        $Q_entries = mysql_query("update `entry` set `customer_id` = '" . $customer1['customer_id'] . "' where `customer_id` = '" . $customer2['customer_id'] . "'");
        echo 'Flyttet bookinger til kundeid ' . $customer1['customer_id'] . ': <span style="color: green">OK, ' . mysql_affected_rows() . ' bookinger flyttet</span><br>';
        $Q_customer = mysql_query("update `customer` set `slettet` = '1' where `customer_id` = '" . $customer2['customer_id'] . "'");
Example #25
0
*
* License:
*	 GPL v3 or above
*
* Website:
* 	http://www.simpleinvoices.org
*/
//stop the direct browsing to this file - let index.php handle which files get displayed
checkLogin();
#get the invoice id
$invoice_id = $_GET['id'];
$invoiceobj = new invoice();
$invoice = $invoiceobj->select($invoice_id);
$preference = getPreference($invoice['preference_id']);
$biller = getBiller($invoice['biller_id']);
$customer = getCustomer($invoice['customer_id']);
$invoiceType = getInvoiceType($invoice['type_id']);
#create PDF name
$spc2us_pref = str_replace(" ", "_", $invoice['index_name']);
$pdf_file_name = $spc2us_pref . '.pdf';
if ($_GET['stage'] == 2) {
    #echo $block_stage2;
    // Create invoice
    $export = new export();
    $export->format = "pdf";
    $export->file_location = 'file';
    $export->module = 'invoice';
    $export->id = $invoice_id;
    $export->execute();
    #$attachment = file_get_contents('./tmp/cache/' . $pdf_file_name);
    $email = new email();
Example #26
0
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
require "glob_inc.inc.php";
filterMakeAlternatives();
print_header($day, $month, $year, $area);
$Q = mysql_query("SELECT customer_id FROM `customer` WHERE `slettet` = '0' ORDER BY customer_name");
echo '<h1>' . __('Customers') . '</h1>' . chr(10);
echo '- ' . iconHTML('group_add') . ' <a href="customer_edit.php?returnToCustomerView=1">' . __('Create new customer') . '</a><br><br>' . chr(10);
echo '<table>' . chr(10);
//echo '	<tr>'.chr(10);
//echo '		<td><b>'._('Customer').'</b></td>'.chr(10);
//echo '		<td>&nbsp;</td>'.chr(10);
//echo '	</tr>'.chr(10).chr(10);
while ($R = mysql_fetch_assoc($Q)) {
    $customer = getCustomer($R['customer_id']);
    if (count($customer)) {
        $filter = addFilter(array(), 'customer_id', $customer['customer_id']);
        $filters_serialized = filterSerialized($filter);
        echo '	<tr>' . chr(10);
        echo '		<td><b>' . $customer['customer_id'] . ' </b></td>' . chr(10);
        echo '		<td><b>' . '<a href="customer.php?customer_id=' . $customer['customer_id'] . '">' . iconHTML('group') . ' ' . $customer['customer_name'] . '</a></b></td>' . chr(10);
        echo '		<td><font size="1">' . '<a href="customer_edit.php?customer_id=' . $customer['customer_id'] . '&amp;returnToCustomerList=1">' . iconHTML('group_edit') . ' ' . __('Edit') . '</a>' . ' -:- <a href="entry_list.php?filters=' . $filters_serialized . '">' . iconHTML('page_white') . ' ' . __('View entries') . '</a>' . '</font></td>' . chr(10);
        echo '	</tr>' . chr(10) . chr(10);
    }
}
echo '</table>' . chr(10);
Example #27
0
* Last edited:
* 	 2009-02-08
*
* License:
*	 GPL v2 or above
*
* Website:
* 	http://www.simpleinvoices.org
*/
#table
//stop the direct browsing to this file - let index.php handle which files get displayed
checkLogin();
#get the invoice id
$defaults = getSystemDefaults();
$master_customer_id = $_GET['customer_id'];
$customer = getCustomer($master_customer_id);
if ($_GET['action'] == 'update_template') {
    /* update default template for customer */
    $sql = "UPDATE " . TB_PREFIX . "customers SET custom_field4 = :cf4 WHERE id = :id AND domain_id = :domain_id";
    dbQuery($sql, ':cf4', $_GET['id'], ':id', $master_customer_id, ':domain_id', domain_id::get());
    $smarty->assign("view", "quick_view");
    $smarty->assign("spec", "id");
    $smarty->assign("id", $_GET['id']);
    # print("debug=$sql");
} else {
    $template = $defaults['default_invoice'];
    /* GET DEFAULT TEMPLATE, OR NULL */
    $customer['custom_field4'] != null && ($template = $customer['custom_field4']);
    /* OVERRIDE WITH CF4 IF IT EXISTS */
    $invoice = getInvoice($template);
    $template = $invoice['id'];
Example #28
0
 public function payment()
 {
     global $config;
     global $logger;
     //set customer,biller and preference if not defined
     if (empty($this->customer)) {
         $this->customer = getCustomer($this->invoice['customer_id'], $this->domain_id);
     }
     if (empty($this->biller)) {
         $this->biller = getBiller($this->invoice['biller_id'], $this->domain_id);
     }
     if (empty($this->preference)) {
         $this->preference = getPreference($this->invoice['preference_id'], $this->domain_id);
     }
     $eway = new ewaylib($this->biller['eway_customer_id'], 'REAL_TIME', false);
     //Eway only accepts amount in cents - so times 100
     $value = $this->invoice['total'] * 100;
     $eway_invoice_total = htmlsafe(trim($value));
     $logger->log("eway total: " . $eway_invoice_total, Zend_Log::INFO);
     $enc = new encryption();
     $key = $config->encryption->default->key;
     $credit_card_number = $enc->decrypt($key, $this->customer['credit_card_number']);
     $eway->setTransactionData("TotalAmount", $eway_invoice_total);
     //mandatory field
     $eway->setTransactionData("CustomerFirstName", $this->customer['name']);
     $eway->setTransactionData("CustomerLastName", "");
     $eway->setTransactionData("CustomerAddress", "");
     $eway->setTransactionData("CustomerPostcode", "");
     $eway->setTransactionData("CustomerInvoiceDescription", "");
     $eway->setTransactionData("CustomerEmail", $this->customer['email']);
     $eway->setTransactionData("CustomerInvoiceRef", $this->invoice['index_name']);
     $eway->setTransactionData("CardHoldersName", $this->customer['credit_card_holder_name']);
     //mandatory field
     $eway->setTransactionData("CardNumber", $credit_card_number);
     //mandatory field
     $eway->setTransactionData("CardExpiryMonth", $this->customer['credit_card_expiry_month']);
     //mandatory field
     $eway->setTransactionData("CardExpiryYear", $this->customer['credit_card_expiry_year']);
     //mandatory field
     $eway->setTransactionData("Option1", "");
     $eway->setTransactionData("Option2", "");
     $eway->setTransactionData("Option3", "");
     $eway->setTransactionData("TrxnNumber", $this->invoice['id']);
     //special preferences for php Curl
     //pass a long set to zero value stops curl from verifying peer's certificate
     $eway->setCurlPreferences(CURLOPT_SSL_VERIFYPEER, 0);
     $ewayResponseFields = $eway->doPayment();
     $this->message = $ewayResponseFields;
     $message = "";
     if ($ewayResponseFields["EWAYTRXNSTATUS"] == "False") {
         $logger->log("Transaction Error: " . $ewayResponseFields["EWAYTRXNERROR"] . "<br>\n", Zend_Log::INFO);
         foreach ($ewayResponseFields as $key => $value) {
             $message .= "\n<br>\$ewayResponseFields[\"{$key}\"] = {$value}";
         }
         $logger->log("Eway message: " . $message . "<br>\n", Zend_Log::INFO);
         //header("Location: trasnactionerrorpage.php");
         //exit();
         $return = 'false';
     } else {
         if ($ewayResponseFields["EWAYTRXNSTATUS"] == "True") {
             $logger->log("Transaction Success: " . $ewayResponseFields["EWAYTRXNERROR"] . "<br>\n", Zend_Log::INFO);
             foreach ($ewayResponseFields as $key => $value) {
                 $message .= "\n<br>\$ewayResponseFields[\"{$key}\"] = {$value}";
             }
             $logger->log("Eway message: " . $message . "<br>\n", Zend_Log::INFO);
             //header("Location: trasnactionsuccess.php");
             //exit();
             $payment = new payment();
             $payment->ac_inv_id = $this->invoice['id'];
             #$payment->ac_inv_id = $_POST['invoice'];
             $payment->ac_amount = $this->invoice['total'];
             #$payment->ac_amount = $ewayResponseFields['EWAYRETURNAMOUNT']/100;
             #$payment->ac_amount = $_POST['mc_gross'];
             $payment->ac_notes = $message;
             $payment->ac_date = date('Y-m-d');
             $payment->online_payment_id = $ewayResponseFields['EWAYTRXNNUMBER'];
             $payment->domain_id = $this->domain_id;
             $payment_type = new payment_type();
             $payment_type->type = "Eway";
             $payment_type->domain_id = $this->domain_id;
             $payment->ac_payment_type = $payment_type->select_or_insert_where();
             $logger->log('Paypal - payment_type=' . $payment->ac_payment_type, Zend_Log::INFO);
             $payment->insert();
             #echo $db->lastInsertID();
             $return = 'true';
         }
     }
     return $return;
 }
Example #29
0
function agent_monitoring_checkStatus($module_name, $smarty, $sDirLocalPlantillas, $oPaloConsola)
{
    $respuesta = array();
    //return 'test';
    ignore_user_abort(true);
    set_time_limit(0);
    // Estado del lado del cliente
    $estadoHash = getParameter('clientstatehash');
    if (!is_null($estadoHash)) {
        $estadoCliente = isset($_SESSION[$module_name]['estadoCliente']) ? $_SESSION[$module_name]['estadoCliente'] : array();
    } else {
        $estadoCliente = getParameter('clientstate');
        if (!is_array($estadoCliente)) {
            return;
        }
    }
    foreach (array_keys($estadoCliente) as $k) {
        $estadoCliente[$k]['oncallupdate'] = $estadoCliente[$k]['oncallupdate'] == 'true';
    }
    // Modo a funcionar: Long-Polling, o Server-sent Events
    $sModoEventos = getParameter('serverevents');
    $bSSE = !is_null($sModoEventos) && $sModoEventos;
    if ($bSSE) {
        Header('Content-Type: text/event-stream');
        printflush("retry: 1\n");
    } else {
        Header('Content-Type: application/json');
    }
    // Verificar hash correcto
    if (!is_null($estadoHash) && $estadoHash != $_SESSION[$module_name]['estadoClienteHash']) {
        $respuesta['estadoClienteHash'] = 'mismatch';
        jsonflush($bSSE, $respuesta);
        $oPaloConsola->desconectarTodo();
        return;
    }
    // Estado del lado del servidor
    $estadoMonitor = $oPaloConsola->listarEstadoMonitoreoAgentes();
    if (!is_array($estadoMonitor)) {
        $respuesta['error'] = $oPaloConsola->errMsg;
        jsonflush($bSSE, $respuesta);
        $oPaloConsola->desconectarTodo();
        return;
    }
    //tri
    // Acumular inmediatamente las filas que son distintas en estado
    ksort($estadoMonitor);
    $estadoMonitor = mergeQueueAgent($estadoMonitor);
    $jsonData = contructDataJSON($estadoMonitor);
    foreach ($jsonData as $jsonKey => $jsonRow) {
        if (isset($estadoCliente[$jsonKey])) {
            if ($estadoCliente[$jsonKey]['agentstatus'] != $jsonRow['agentstatus'] || $estadoCliente[$jsonKey]['oncallupdate'] != $jsonRow['oncallupdate']) {
                $respuesta[$jsonKey] = $jsonRow;
                $estadoCliente[$jsonKey]['agentstatus'] = $jsonRow['agentstatus'];
                $estadoCliente[$jsonKey]['oncallupdate'] = $jsonRow['oncallupdate'];
                unset($respuesta[$jsonKey]['agentname']);
            }
        }
    }
    $iTimeoutPoll = PaloSantoConsola::recomendarIntervaloEsperaAjax();
    do {
        $oPaloConsola->desconectarEspera();
        // Se inicia espera larga con el navegador...
        session_commit();
        $iTimestampInicio = time();
        while (connection_status() == CONNECTION_NORMAL && count($respuesta) <= 0 && time() - $iTimestampInicio < $iTimeoutPoll) {
            $listaEventos = $oPaloConsola->esperarEventoSesionActiva();
            if (is_null($listaEventos)) {
                $respuesta['error'] = $oPaloConsola->errMsg;
                jsonflush($bSSE, $respuesta);
                $oPaloConsola->desconectarTodo();
                return;
            }
            $iTimestampActual = time();
            foreach ($listaEventos as $evento) {
                $sNumeroAgente = $sCanalAgente = $evento['agent_number'];
                if (substr($sNumeroAgente, 0, 4) == 'SIP/') {
                    $sNumeroAgente = substr($sNumeroAgente, 4);
                }
                //$sCanalAgente = str_replace('/','_',$sCanalAgente);
                switch ($evento['event']) {
                    case 'agentloggedin':
                        // foreach (array_keys($estadoMonitor) as $sAgent) {
                        if (isset($estadoMonitor[$sCanalAgente])) {
                            $jsonKey = 'Agent_' . $sNumeroAgente;
                            if (isset($jsonData[$jsonKey]) && $jsonData[$jsonKey]['agentstatus'] == 'offline') {
                                // Estado en el estado de monitor
                                $estadoMonitor[$sCanalAgente]['agentstatus'] = 'online';
                                $estadoMonitor[$sCanalAgente]['lastsessionstart'] = date('Y-m-d H:i:s', $iTimestampActual);
                                $estadoMonitor[$sCanalAgente]['lastsessionend'] = NULL;
                                if (!is_null($estadoMonitor[$sCanalAgente]['lastpausestart']) && is_null($estadoMonitor[$sCanalAgente]['lastpauseend'])) {
                                    $estadoMonitor[$sCanalAgente]['lastpauseend'] = date('Y-m-d H:i:s', $iTimestampActual);
                                }
                                $estadoMonitor[$sCanalAgente]['linkstart'] = NULL;
                                // Estado en la estructura JSON
                                $jsonData[$jsonKey]['agentstatus'] = $estadoMonitor[$sCanalAgente]['agentstatus'];
                                $jsonData[$jsonKey]['sec_laststatus'] = 0;
                                $jsonData[$jsonKey]['oncallupdate'] = FALSE;
                                // Get customer information //tri
                                $agentState = getAgentState($jsonRow['agent_number']);
                                $arrSmartyData[$jsonKey]['callnumber'] = $agentState['callnumber'];
                                $arrSmartyData[$jsonKey]['callid'] = $agentState['callid'];
                                $customer = getCustomer($arrSmartyData[$jsonKey]['callnumber']);
                                $arrSmartyData[$jsonKey]['customer'] = $customer ? $customer : $arrSmartyData[$jsonKey]['callnumber'];
                                // Estado del cliente
                                $estadoCliente[$jsonKey]['agentstatus'] = $jsonData[$jsonKey]['agentstatus'];
                                $estadoCliente[$jsonKey]['oncallupdate'] = $jsonData[$jsonKey]['oncallupdate'];
                                // Estado a emitir al cliente
                                $respuesta[$jsonKey] = $jsonData[$jsonKey];
                                unset($respuesta[$jsonKey]['agentname']);
                            }
                        }
                        // }
                        break;
                    case 'agentloggedout':
                        //foreach (array_keys($estadoMonitor) as $sAgent) {
                        if (isset($estadoMonitor[$sCanalAgente])) {
                            $jsonKey = 'Agent_' . $sNumeroAgente;
                            if (isset($jsonData[$jsonKey]) && $jsonData[$jsonKey]['agentstatus'] != 'offline') {
                                // Estado en el estado de monitor
                                $estadoMonitor[$sCanalAgente]['agentstatus'] = 'offline';
                                $estadoMonitor[$sCanalAgente]['lastsessionend'] = date('Y-m-d H:i:s', $iTimestampActual);
                                if (!is_null($estadoMonitor[$sCanalAgente]['lastpausestart']) && is_null($estadoMonitor[$sCanalAgente]['lastpauseend'])) {
                                    $estadoMonitor[$sCanalAgente]['lastpauseend'] = date('Y-m-d H:i:s', $iTimestampActual);
                                }
                                $estadoMonitor[$sCanalAgente]['linkstart'] = NULL;
                                if (!is_null($estadoMonitor[$sCanalAgente]['lastsessionstart'])) {
                                    $iTimestampInicio = strtotime($estadoMonitor[$sCanalAgente]['lastsessionstart']);
                                    $iDuracionSesion = $iTimestampActual - $iTimestampInicio;
                                    if ($iDuracionSesion >= 0) {
                                        $estadoMonitor[$sCanalAgente]['logintime'] += $iDuracionSesion;
                                    }
                                }
                                // Estado en la estructura JSON
                                $jsonData[$jsonKey]['agentstatus'] = $estadoMonitor[$sCanalAgente]['agentstatus'];
                                $jsonData[$jsonKey]['sec_laststatus'] = 0;
                                $jsonData[$jsonKey]['oncallupdate'] = FALSE;
                                $jsonData[$jsonKey]['logintime'] = $estadoMonitor[$sCanalAgente]['logintime'];
                                // Estado del cliente
                                $estadoCliente[$jsonKey]['agentstatus'] = $jsonData[$jsonKey]['agentstatus'];
                                $estadoCliente[$jsonKey]['oncallupdate'] = $jsonData[$jsonKey]['oncallupdate'];
                                // Estado a emitir al cliente
                                $respuesta[$jsonKey] = $jsonData[$jsonKey];
                                unset($respuesta[$jsonKey]['agentname']);
                            }
                        }
                        // }
                        break;
                    case 'pausestart':
                        //foreach (array_keys($estadoMonitor) as $sAgent) {
                        if (isset($estadoMonitor[$sCanalAgente])) {
                            $jsonKey = 'Agent_' . $sNumeroAgente;
                            if (isset($jsonData[$jsonKey]) && $jsonData[$jsonKey]['agentstatus'] != 'offline') {
                                // Estado en el estado de monitor
                                if ($estadoMonitor[$sCanalAgente]['agentstatus'] != 'oncall') {
                                    $estadoMonitor[$sCanalAgente]['agentstatus'] = 'paused';
                                }
                                $estadoMonitor[$sCanalAgente]['lastpausestart'] = date('Y-m-d H:i:s', $iTimestampActual);
                                $estadoMonitor[$sCanalAgente]['lastpauseend'] = NULL;
                                // Estado en la estructura JSON
                                $jsonData[$jsonKey]['agentstatus'] = $estadoMonitor[$sCanalAgente]['agentstatus'];
                                if ($jsonData[$jsonKey]['agentstatus'] == 'oncall') {
                                    if (!is_null($estadoMonitor[$sCanalAgente]['linkstart'])) {
                                        $iTimestampInicio = strtotime($estadoMonitor[$sCanalAgente]['linkstart']);
                                        $iDuracionLlamada = $iTimestampActual - $iTimestampInicio;
                                        if ($iDuracionLlamada >= 0) {
                                            $jsonData[$jsonKey]['sec_laststatus'] = $iDuracionLlamada;
                                            $jsonData[$jsonKey]['sec_calls'] = $estadoMonitor[$sCanalAgente]['sec_calls'] + $iDuracionLlamada;
                                        }
                                    }
                                } else {
                                    $jsonData[$jsonKey]['sec_laststatus'] = 0;
                                }
                                $jsonData[$jsonKey]['logintime'] = $estadoMonitor[$sCanalAgente]['logintime'];
                                if (!is_null($estadoMonitor[$sCanalAgente]['lastsessionstart'])) {
                                    $iTimestampInicio = strtotime($estadoMonitor[$sCanalAgente]['lastsessionstart']);
                                    $iDuracionSesion = $iTimestampActual - $iTimestampInicio;
                                    if ($iDuracionSesion >= 0) {
                                        $jsonData[$jsonKey]['logintime'] += $iDuracionSesion;
                                    }
                                }
                                // Estado del cliente
                                $estadoCliente[$jsonKey]['agentstatus'] = $jsonData[$jsonKey]['agentstatus'];
                                $estadoCliente[$jsonKey]['oncallupdate'] = $jsonData[$jsonKey]['oncallupdate'];
                                // Estado a emitir al cliente
                                $respuesta[$jsonKey] = $jsonData[$jsonKey];
                                unset($respuesta[$jsonKey]['agentname']);
                            }
                        }
                        // }
                        break;
                    case 'pauseend':
                        //foreach (array_keys($estadoMonitor) as $sAgent) {
                        if (isset($estadoMonitor[$sCanalAgente])) {
                            $jsonKey = 'Agent_' . $sNumeroAgente;
                            if (isset($jsonData[$jsonKey]) && $jsonData[$jsonKey]['agentstatus'] != 'offline') {
                                // Estado en el estado de monitor
                                if ($estadoMonitor[$sCanalAgente]['agentstatus'] != 'oncall') {
                                    $estadoMonitor[$sCanalAgente]['agentstatus'] = 'online';
                                }
                                $estadoMonitor[$sCanalAgente]['lastpauseend'] = date('Y-m-d H:i:s', $iTimestampActual);
                                // Estado en la estructura JSON
                                $jsonData[$jsonKey]['agentstatus'] = $estadoMonitor[$sCanalAgente]['agentstatus'];
                                if ($jsonData[$jsonKey]['agentstatus'] == 'oncall') {
                                    if (!is_null($estadoMonitor[$sCanalAgente]['linkstart'])) {
                                        $iTimestampInicio = strtotime($estadoMonitor[$sCanalAgente]['linkstart']);
                                        $iDuracionLlamada = $iTimestampActual - $iTimestampInicio;
                                        if ($iDuracionLlamada >= 0) {
                                            $jsonData[$jsonKey]['sec_laststatus'] = $iDuracionLlamada;
                                            $jsonData[$jsonKey]['sec_calls'] = $estadoMonitor[$sCanalAgente]['sec_calls'] + $iDuracionLlamada;
                                        }
                                    }
                                } else {
                                    $jsonData[$jsonKey]['sec_laststatus'] = $iTimestampActual - strtotime($estadoMonitor[$sCanalAgente]['lastsessionstart']);
                                }
                                $jsonData[$jsonKey]['logintime'] = $estadoMonitor[$sCanalAgente]['logintime'];
                                if (!is_null($estadoMonitor[$sCanalAgente]['lastsessionstart'])) {
                                    $iTimestampInicio = strtotime($estadoMonitor[$sCanalAgente]['lastsessionstart']);
                                    $iDuracionSesion = $iTimestampActual - $iTimestampInicio;
                                    if ($iDuracionSesion >= 0) {
                                        $jsonData[$jsonKey]['logintime'] += $iDuracionSesion;
                                    }
                                }
                                // Estado del cliente
                                $estadoCliente[$jsonKey]['agentstatus'] = $jsonData[$jsonKey]['agentstatus'];
                                $estadoCliente[$jsonKey]['oncallupdate'] = $jsonData[$jsonKey]['oncallupdate'];
                                // Estado a emitir al cliente
                                $respuesta[$jsonKey] = $jsonData[$jsonKey];
                                unset($respuesta[$jsonKey]['agentname']);
                            }
                        }
                        //}
                        break;
                    case 'agentlinked':
                        // Averiguar la cola por la que entrĂ³ la llamada nueva
                        $sCallQueue = $evento['queue'];
                        if (is_null($sCallQueue)) {
                            $infoCampania = $oPaloConsola->leerInfoCampania($evento['call_type'], $evento['campaign_id']);
                            if (!is_null($infoCampania)) {
                                $sCallQueue = $infoCampania['queue'];
                            }
                        }
                        if (isset($estadoMonitor[$sCanalAgente])) {
                            $jsonKey = 'Agent_' . $sNumeroAgente;
                            if (isset($jsonData[$jsonKey]) && $jsonData[$jsonKey]['agentstatus'] != 'offline') {
                                // Estado en el estado de monitor
                                $estadoMonitor[$sCanalAgente]['agentstatus'] = 'oncall';
                                $estadoMonitor[$sCanalAgente]['linkstart'] = NULL;
                                $estadoMonitor[$sCanalAgente]['num_calls']++;
                                $estadoMonitor[$sCanalAgente]['linkstart'] = $evento['datetime_linkstart'];
                                // Estado en la estructura JSON
                                $jsonData[$jsonKey]['agentstatus'] = $estadoMonitor[$sCanalAgente]['agentstatus'];
                                $jsonData[$jsonKey]['sec_laststatus'] = is_null($estadoMonitor[$sCanalAgente]['linkstart']) ? NULL : $iTimestampActual - strtotime($estadoMonitor[$sCanalAgente]['linkstart']);
                                $jsonData[$jsonKey]['num_calls'] = $estadoMonitor[$sCanalAgente]['num_calls'];
                                $jsonData[$jsonKey]['sec_calls'] = $estadoMonitor[$sCanalAgente]['sec_calls'] + (is_null($jsonData[$jsonKey]['sec_laststatus']) ? 0 : $jsonData[$jsonKey]['sec_laststatus']);
                                $jsonData[$jsonKey]['oncallupdate'] = !is_null($estadoMonitor[$sCanalAgente]['linkstart']);
                                $jsonData[$jsonKey]['logintime'] = $estadoMonitor[$sCanalAgente]['logintime'];
                                if (!is_null($estadoMonitor[$sCanalAgente]['lastsessionstart'])) {
                                    $iTimestampInicio = strtotime($estadoMonitor[$sCanalAgente]['lastsessionstart']);
                                    $iDuracionSesion = $iTimestampActual - $iTimestampInicio;
                                    if ($iDuracionSesion >= 0) {
                                        $jsonData[$jsonKey]['logintime'] += $iDuracionSesion;
                                    }
                                }
                                $jsonData[$jsonKey]['linkqueue'] = $evento['queue'];
                                //tri
                                $customer = getCustomer($evento['phone']);
                                $jsonData[$jsonKey]['customer'] = $customer ? $customer : $evento['phone'];
                                // Estado del cliente
                                $estadoCliente[$jsonKey]['agentstatus'] = $jsonData[$jsonKey]['agentstatus'];
                                $estadoCliente[$jsonKey]['oncallupdate'] = $jsonData[$jsonKey]['oncallupdate'];
                                // Estado a emitir al cliente
                                $respuesta[$jsonKey] = $jsonData[$jsonKey];
                                unset($respuesta[$jsonKey]['agentname']);
                                //$respuesta = $evento;
                            }
                        }
                        break;
                    case 'agentunlinked':
                        //foreach (array_keys($estadoMonitor) as $sAgent) {
                        if (isset($estadoMonitor[$sCanalAgente])) {
                            $jsonKey = 'Agent_' . $sNumeroAgente;
                            if (isset($jsonData[$jsonKey]) && $jsonData[$jsonKey]['agentstatus'] != 'offline') {
                                // Estado en el estado de monitor
                                $estadoMonitor[$sCanalAgente]['agentstatus'] = !is_null($estadoMonitor[$sCanalAgente]['lastpausestart']) && is_null($estadoMonitor[$sCanalAgente]['lastpauseend']) ? 'paused' : 'online';
                                if (!is_null($estadoMonitor[$sCanalAgente]['linkstart'])) {
                                    $iTimestampInicio = strtotime($estadoMonitor[$sCanalAgente]['linkstart']);
                                    $iDuracionLlamada = $iTimestampActual - $iTimestampInicio;
                                    if ($iDuracionLlamada >= 0) {
                                        $estadoMonitor[$sCanalAgente]['sec_calls'] += $iDuracionLlamada;
                                    }
                                }
                                $estadoMonitor[$sCanalAgente]['linkstart'] = NULL;
                                // Estado en la estructura JSON
                                $jsonData[$jsonKey]['agentstatus'] = $estadoMonitor[$sCanalAgente]['agentstatus'];
                                if ($jsonData[$jsonKey]['agentstatus'] == 'paused') {
                                    $jsonData[$jsonKey]['sec_laststatus'] = $iTimestampActual - strtotime($estadoMonitor[$sCanalAgente]['lastpausestart']);
                                } else {
                                    $jsonData[$jsonKey]['sec_laststatus'] = $iTimestampActual - strtotime($estadoMonitor[$sCanalAgente]['lastsessionstart']);
                                }
                                $jsonData[$jsonKey]['num_calls'] = $estadoMonitor[$sCanalAgente]['num_calls'];
                                $jsonData[$jsonKey]['sec_calls'] = $estadoMonitor[$sCanalAgente]['sec_calls'];
                                $jsonData[$jsonKey]['oncallupdate'] = FALSE;
                                $jsonData[$jsonKey]['logintime'] = $estadoMonitor[$sCanalAgente]['logintime'];
                                if (!is_null($estadoMonitor[$sCanalAgente]['lastsessionstart'])) {
                                    $iTimestampInicio = strtotime($estadoMonitor[$sCanalAgente]['lastsessionstart']);
                                    $iDuracionSesion = $iTimestampActual - $iTimestampInicio;
                                    if ($iDuracionSesion >= 0) {
                                        $jsonData[$jsonKey]['logintime'] += $iDuracionSesion;
                                    }
                                }
                                // Estado del cliente
                                $estadoCliente[$jsonKey]['agentstatus'] = $jsonData[$jsonKey]['agentstatus'];
                                $estadoCliente[$jsonKey]['oncallupdate'] = $jsonData[$jsonKey]['oncallupdate'];
                                // Estado a emitir al cliente
                                $respuesta[$jsonKey] = $jsonData[$jsonKey];
                                unset($respuesta[$jsonKey]['agentname']);
                            }
                        }
                        //}
                        break;
                }
            }
        }
        if (count($respuesta) > 0) {
            @session_start();
            $estadoHash = generarEstadoHash($module_name, $estadoCliente);
            $respuesta['estadoClienteHash'] = $estadoHash;
            session_commit();
        }
        //$respuesta = $estadoMonitor;
        jsonflush($bSSE, $respuesta);
        jsonflush($bSSE, var_dump($respuesta));
        $respuesta = array();
    } while ($bSSE && connection_status() == CONNECTION_NORMAL);
    $oPaloConsola->desconectarTodo();
}
Example #30
-1
 function getData()
 {
     //echo "export - get data";
     global $smarty;
     global $siUrl;
     switch ($this->module) {
         case "statement":
             $invoice = new invoice();
             $invoice->biller = $this->biller_id;
             $invoice->customer = $this->customer_id;
             if ($this->filter_by_date == "yes") {
                 if (isset($this->start_date)) {
                     $invoice->start_date = $this->start_date;
                 }
                 if (isset($this->end_date)) {
                     $invoice->end_date = $this->end_date;
                 }
                 if (isset($this->start_date) and isset($this->end_date)) {
                     $invoice->having = "date_between";
                 }
                 $having_count = 1;
             }
             if ($this->show_only_unpaid == "yes") {
                 if ($having_count == 1) {
                     $invoice->having_and = "money_owed";
                 } else {
                     $invoice->having = "money_owed";
                 }
             }
             $invoice_all = $invoice->select_all('count');
             $invoices = $invoice_all->fetchAll();
             foreach ($invoices as $i => $row) {
                 $statement['total'] = $statement['total'] + $row['invoice_total'];
                 $statement['owing'] = $statement['owing'] + $row['owing'];
                 $statement['paid'] = $statement['paid'] + $row['INV_PAID'];
             }
             $templatePath = "./templates/default/statement/index.tpl";
             $biller_details = getBiller($this->biller_id);
             $customer_details = getCustomer($this->customer_id);
             $this->file_name = "statement_" . $this->biller_id . "_" . $this->customer_id . "_" . $invoice->start_date . "_" . $invoice->end_date;
             $smarty->assign('biller_id', $biller_id);
             $smarty->assign('biller_details', $biller_details);
             $smarty->assign('customer_id', $customer_id);
             $smarty->assign('customer_details', $customer_details);
             $smarty->assign('show_only_unpaid', $show_only_unpaid);
             $smarty->assign('filter_by_date', $this->filter_by_date);
             $smarty->assign('invoices', $invoices);
             $smarty->assign('start_date', $this->start_date);
             $smarty->assign('end_date', $this->end_date);
             $smarty->assign('invoices', $invoices);
             $smarty->assign('statement', $statement);
             $data = $smarty->fetch("." . $templatePath);
             break;
         case "payment":
             $payment = getPayment($this->id);
             /*Code to get the Invoice preference - so can link from this screen back to the invoice - START */
             $invoice = getInvoice($payment['ac_inv_id']);
             $biller = getBiller($payment['biller_id']);
             $logo = getLogo($biller);
             $logo = str_replace(" ", "%20", $logo);
             $customer = getCustomer($payment['customer_id']);
             $invoiceType = getInvoiceType($invoice['type_id']);
             $customFieldLabels = getCustomFieldLabels();
             $paymentType = getPaymentType($payment['ac_payment_type']);
             $preference = getPreference($invoice['preference_id']);
             $smarty->assign("payment", $payment);
             $smarty->assign("invoice", $invoice);
             $smarty->assign("biller", $biller);
             $smarty->assign("logo", $logo);
             $smarty->assign("customer", $customer);
             $smarty->assign("invoiceType", $invoiceType);
             $smarty->assign("paymentType", $paymentType);
             $smarty->assign("preference", $preference);
             $smarty->assign("customFieldLabels", $customFieldLabels);
             $smarty->assign('pageActive', 'payment');
             $smarty->assign('active_tab', '#money');
             $css = $siUrl . "/templates/invoices/default/style.css";
             $smarty->assign('css', $css);
             $templatePath = "./templates/default/payments/print.tpl";
             $data = $smarty->fetch("." . $templatePath);
             break;
         case "invoice":
             $invoice = invoice::select($this->id);
             $invoice_number_of_taxes = numberOfTaxesForInvoice($this->id);
             $customer = getCustomer($invoice['customer_id']);
             $biller = biller::select($invoice['biller_id']);
             $preference = getPreference($invoice['preference_id']);
             $defaults = getSystemDefaults();
             $logo = getLogo($biller);
             $logo = str_replace(" ", "%20", $logo);
             $invoiceItems = invoice::getInvoiceItems($this->id);
             $spc2us_pref = str_replace(" ", "_", $invoice['index_name']);
             $this->file_name = $spc2us_pref;
             $customFieldLabels = getCustomFieldLabels();
             /*Set the template to the default*/
             $template = $defaults['template'];
             $templatePath = "./templates/invoices/{$template}/template.tpl";
             $template_path = "../templates/invoices/{$template}";
             $css = $siUrl . "/templates/invoices/{$template}/style.css";
             $pluginsdir = "./templates/invoices/{$template}/plugins/";
             //$smarty = new Smarty();
             $smarty->plugins_dir = $pluginsdir;
             $pageActive = "invoices";
             $smarty->assign('pageActive', $pageActive);
             if (file_exists($templatePath)) {
                 //echo "test";
                 $smarty->assign('biller', $biller);
                 $smarty->assign('customer', $customer);
                 $smarty->assign('invoice', $invoice);
                 $smarty->assign('invoice_number_of_taxes', $invoice_number_of_taxes);
                 $smarty->assign('preference', $preference);
                 $smarty->assign('logo', $logo);
                 $smarty->assign('template', $template);
                 $smarty->assign('invoiceItems', $invoiceItems);
                 $smarty->assign('template_path', $template_path);
                 $smarty->assign('css', $css);
                 $smarty->assign('customFieldLabels', $customFieldLabels);
                 $data = $smarty->fetch("." . $templatePath);
             }
             break;
     }
     return $data;
 }