function getSideMenu() { $sideMenu = ' <div class="col-md-3 hidden-xs hidden-sm" name="secondary-menu"> <ul class="nav nav-pills nav-stacked row--content--secondarymenu"> <li role="empty"></li> <li role="presentation" class="active">ACCÈS DIRECT</li> <li role="presentation"><a id ="goAcceuilFromSideMenu" href="' . getAcceuil() . '"><img src="img/menu-home.png" alt="1"> Acceuil</a></li> <li role="presentation"><a id ="goPresentationFromSideMenu" href="' . getPresentation() . '"><img src="img/menu-prez.png" alt="1"> Présentation</a></li> <li role="presentation"><a id ="goDonneesFromSideMenu" href="' . getDonnees() . '"><img src="img/menu-datas.png" alt="1"> Données</a></li> <li role="presentation"><a id ="goContactFromSideMenu" href="' . getContact() . '"><img src="img/menu-rss.png" alt="1"> Contact</a></li> </ul> </div>'; echo $sideMenu; }
function getPreDiallist($dialid) { $objResponse = new xajaxResponse(); global $db; $row = astercrm::getRecordByID($dialid, 'diallist'); if ($row['id'] == '') { } else { $phoneNum = $row['dialnumber']; $objResponse->loadXML(getContact($phoneNum)); astercrm::deleteRecord($row['id'], "diallist"); $row['dialednumber'] = $phoneNum; $row['dialedby'] = $_SESSION['curuser']['extension']; $row['trytime'] = $row['trytime'] + 1; astercrm::insertNewDialedlist($row); } $objResponse->loadXML(getPrivateDialListNumber($_SESSION['curuser']['extension'])); return $objResponse; }
/** * @brief Get the last modification time for a contact. * * Must return a UNIX time stamp or null if the backend * doesn't support it. * * @param string $addressbookid * @param mixed $id * @returns int | null */ public function lastModifiedContact($addressbookid, $id) { $contact = getContact($addressbookid, $id); if ($contact != null) { return $contact['lastmodified']; } else { return null; } }
} } else { if (isset($_GET['discussion'])) { getDiscussionMessage($bd, $_GET['destinataire']); } else { if (isset($_POST['sendDiscussion'])) { sendPrivateMessage($bd, $_POST['destinataire'], $_POST['message']); } else { if (isset($_GET['numberNewMessage'])) { echo getNumberOfNotRead($bd); } else { if (isset($_GET['loadPreviousDiscussion'])) { echo loadPreviousDiscussion($bd, $_GET['destinataire'], $_GET['offset']); } else { if (isset($_GET['getContact'])) { getContact($bd); } else { if (isset($_GET['getPrivateMessage'])) { getDiscussionMessage($bd, $_GET['destinataire']); } } } } } } } } } } } }
protected function OnInput() { parent::OnInput(); $this->title = 'Список контактов'; $this->contact = getContact($_GET['id']); }
function waitingCalls($myValue) { global $db, $config; $locate = new Localization($_SESSION['curuser']['country'], $_SESSION['curuser']['language'], 'portal'); $objResponse = new xajaxResponse(); $curid = trim($myValue['curid']); // to improve system efficiency /************************** **************************/ // modified 2007/10/30 by solo // start //print_r($_SESSION);exit; //if ($_SESSION['curuser']['channel'] == '') $call = asterEvent::checkNewCall($curid, $_SESSION['curuser']['extension'], $_SESSION['curuser']['channel'], $_SESSION['curuser']['agent']); //else // $call = asterEvent::checkNewCall($curid,$_SESSION['curuser']['channel']); // end if ($call['status'] == '') { $title = $locate->Translate("waiting"); $status = 'idle'; //$call['curid'] = $curid; $direction = ''; $info = $locate->Translate("extension") . $_SESSION['curuser']['extension'] . "-" . $locate->Translate("stand_by"); } elseif ($call['status'] == 'incoming') { //incoming calls here $title = $call['callerid']; $stauts = 'ringing'; $direction = 'in'; $info = $locate->Translate("incoming") . ' ' . $call['callerid']; $trunk = split("-", $call['callerChannel']); //print_r($trunk);exit; $trunk_name = split('@', $trunk[0]); $info = $info . ' channel: ' . $trunk_name[0]; // get trunk info $mytrunk = astercrm::getTrunkinfo($trunk[0], $call['didnumber']); if ($mytrunk) { $infomsg = "<strong>" . $mytrunk['trunkname'] . "</strong><br>"; $infomsg .= mb_substr(astercrm::db2html($mytrunk['trunknote']), 0, 10, "UTF-8") . '...'; if ($call['didnumber'] != '') { $infomsg .= " |" . $locate->Translate("Callee id") . " : <b>" . $call['didnumber'] . "</b>"; } $objResponse->addAssign('divTrunkinfo', "innerHTML", $infomsg); } else { $trunk_name = split('@', $trunk[0]); $infomsg = $locate->Translate("no information get for trunk") . ": " . $trunk_name[0]; $objResponse->addAssign('divTrunkinfo', "innerHTML", $infomsg); } $objResponse->addAssign("iptSrcNumber", "value", $call['callerid']); $objResponse->addAssign("iptCallerid", "value", $call['callerid']); $objResponse->addAssign("btnHangup", "disabled", false); if ($config['system']['pop_up_when_dial_in']) { if (strlen($call['callerid']) > $config['system']['phone_number_length'] && $call['callerid'] != '<unknown>') { if ($myValue['popup'] == 'yes') { if ($config['system']['enable_external_crm'] == false) { $objResponse->loadXML(getContact($call['callerid'])); if ($config['system']['browser_maximize_when_pop_up'] == true) { $objResponse->addScript('maximizeWin();'); } } else { //use external link $myurl = $config['system']['external_crm_url']; $myurl = preg_replace("/\\%method/", "dial_in", $myurl); $myurl = preg_replace("/\\%callerid/", $call['callerid'], $myurl); $myurl = preg_replace("/\\%calleeid/", $_SESSION['curuser']['extension'], $myurl); if ($config['system']['open_new_window'] == false) { $mycrm = '<iframe id="mycrm" name="mycrm" src="' . $myurl . '" width="100%" frameBorder=0 scrolling=auto height="100%"></iframe>'; $objResponse->addAssign("divCrm", "innerHTML", $mycrm); } else { $javascript = "openwindow('" . $myurl . "')"; $objResponse->addScript($javascript); } } } } else { } } } elseif ($call['status'] == 'dialout') { //dailing out here $title = $call['callerid']; $status = 'dialing'; $direction = 'out'; $info = $locate->Translate("dial_out") . ' ' . $call['callerid']; $objResponse->addAssign("iptCallerid", "value", $call['callerid']); $objResponse->addAssign("btnHangup", "disabled", false); if ($call['didnumber'] != '') { $didinfo = $locate->Translate("Callee id") . " : " . $call['didnumber']; $objResponse->addAssign('divDIDinfo', 'innerHTML', $didinfo); } if ($config['system']['pop_up_when_dial_out']) { if (strlen($call['callerid']) > $config['system']['phone_number_length']) { if ($myValue['popup'] == 'yes') { if ($config['system']['enable_external_crm'] == false) { $objResponse->loadXML(getContact($call['callerid'])); if ($config['system']['browser_maximize_when_pop_up'] == true) { $objResponse->addScript('maximizeWin();'); } } else { //use external link $myurl = $config['system']['external_crm_url']; $myurl = preg_replace("/\\%method/", "dial_out", $myurl); $myurl = preg_replace("/\\%callerid/", $_SESSION['curuser']['extension'], $myurl); $myurl = preg_replace("/\\%calleeid/", $call['callerid'], $myurl); if ($config['system']['open_new_window'] == false) { $mycrm = '<iframe id="mycrm" name="mycrm" src="' . $myurl . '" width="100%" frameBorder=0 scrolling=auto height="100%"></iframe>'; $objResponse->addAssign("divCrm", "innerHTML", $mycrm); } else { $javascript = "openwindow('" . $myurl . "')"; $objResponse->addScript($javascript); } } } } } } // $objResponse->addScript('document.title='.$title.';'); // $objResponse->addAssign("status","innerHTML", $stauts ); $objResponse->addAssign("extensionStatus", "value", $stauts); //echo $call['uniqueid'];exit; $objResponse->addAssign("uniqueid", "value", $call['uniqueid']); $objResponse->addAssign("callerid", "value", $call['callerid']); $objResponse->addAssign("callerChannel", "value", $call['callerChannel']); $objResponse->addAssign("calleeChannel", "value", $call['calleeChannel']); $objResponse->addAssign("curid", "value", $call['curid']); $objResponse->addAssign("direction", "value", $direction); $objResponse->addAssign("myevents", "innerHTML", $info); return $objResponse; }
function print_invoices() { global $path_to_root, $alternative_tax_include_on_docs, $suppress_tax_rates, $no_zero_lines_amount; include_once $path_to_root . "/reporting/includes/pdf_report.inc"; $from = $_POST['PARAM_0']; $to = $_POST['PARAM_1']; $currency = $_POST['PARAM_2']; $email = $_POST['PARAM_3']; $pay_service = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $customer = $_POST['PARAM_6']; $orientation = $_POST['PARAM_7']; if (!$from || !$to) { return; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $fno = explode("-", $from); $tno = explode("-", $to); $from = min($fno[0], $tno[0]); $to = max($fno[0], $tno[0]); $cols = array(-18, 40, 60, 100, 160, 200, 260, 360, 420, 450, 500); // $headers in doctext.inc $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); //$params = array('comments' => $comments); $cur = get_company_Pref('curr_default'); $company_data = get_company_prefs(); if ($email == 0) { $rep = new FrontReport(_('INVOICE'), "InvoiceBulk", user_pagesize(), 9, $orientation); } if ($orientation == 'L') { recalculate_cols($cols); } for ($i = $from; $i <= $to; $i++) { if (!exists_customer_trans(ST_SALESINVOICE, $i)) { continue; } $sign = 1; $myrow = get_customer_trans($i, ST_SALESINVOICE); if ($customer && $myrow['debtor_no'] != $customer) { continue; } $baccount = get_default_bank_account($myrow['curr_code']); $params['bankaccount'] = $baccount['id']; $branch = get_branch($myrow["branch_code"]); $sales_order = get_sales_order_header($myrow["order_"], ST_SALESORDER); if ($email == 1) { $rep = new FrontReport("", "", user_pagesize(), 9, $orientation); //$rep->title = _('INVOICE'); $rep->filename = "Invoice" . $myrow['reference'] . ".pdf"; } $rep->SetHeaderType(0); $rep->currency = $cur; $rep->Font(); $rep->Info(null, $cols, null, $aligns); $salesman = get_imc_code($branch['branch_code']); $pay_term = get_payment_terms($myrow['payment_terms']); $branch_data = get_branch_accounts($myrow['branch_code']); $invoice_no = get_custom_no($myrow['trans_no'], $myrow['type']); $contact = getContact($myrow['salesman'], $myrow['debtor_no'], $branch['branch_code']); $cnumber = getContactNumber($myrow['salesman'], $myrow['debtor_no'], $branch['branch_code']); $rep->NewPage(); $result = get_customer_trans_details(ST_SALESINVOICE, $i); $SubTotal = 0; $rep->NewLine(6); $rep->TextCol(2, 7, $invoice_no); $rep->TextCol(6, 8, $myrow['TranDate']); $rep->NewLine(); $rep->TextCol(2, 7, $branch['br_name']); $rep->TextCol(7, 8, $myrow['bulk_discount'] . "%"); $rep->NewLine(); $rep->TextCol(2, 7, $branch['branch_ref']); $rep->TextCol(6, 8, $salesman); $rep->NewLine(); $rep->TextCol(2, 6, $contact . " - " . $cnumber); if ($pay_term['terms'] == 'C.O.D.' || $pay_term['Cash Only']) { $rep->TextCol(7, 8, $pay_term['terms'], -2); } else { $oldrow = $rep->row; $newrow = $rep->row; $rep->TextColLines(7, 9, $pay_term['terms'], -2); $newrow = $rep->row; $rep->row = $oldrow; } $rep->NewLine(); $oldrow = $rep->row; $newrow = $rep->row; $rep->TextColLines(2, 6, $branch['br_address'], -2); $rep->row = $oldrow; $rep->NewLine(4); $rep->Font(); while ($myrow2 = db_fetch($result)) { if ($myrow2["quantity"] == 0) { continue; } $Net = round2($sign * ((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), user_price_dec()); $Net2 = round2($sign * ($myrow2["unit_price"] * $myrow2["quantity"]), user_price_dec()); $SubTotal += $Net; $DisplayPrice = number_format2($myrow2["unit_price"], 2); $DisplayQty = number_format2($sign * $myrow2["quantity"], get_qty_dec($myrow2['stock_id'])); $DisplayNet = number_format2($Net, 2); $dNet = number_format2($Net2, 2); $oldrow = $rep->row; $rep->TextColLines(-0.75, 4, $myrow2['StockDescription'], -2); $newrow = $rep->row; $rep->row = $oldrow; if ($Net != 0.0 || !is_service($myrow2['mb_flag']) || !isset($no_zero_lines_amount) || $no_zero_lines_amount == 0) { $rep->TextCol(4, 5, $DisplayQty . " " . $myrow2['units']); $rep->TextCol(5, 6, $DisplayPrice, -2); $rep->TextCol(6, 8, $dNet, -2); } $rep->row = $newrow; if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) { $rep->NewPage(); } } $memo = get_comments_string(ST_SALESINVOICE, $i); if ($memo != "") { $rep->NewLine(); $rep->TextColLines(1, 5, $memo, -2); } $DisplayNet = number_format2($SubTotal, 2); $DisplaySubTot = number_format2($SubTotal, 2); $DisplayTots = number_format2($myrow['Total'], 2); $DisplayDiscount = number_format2($SubTotal * ($myrow['bulk_discount'] / 100), 2); $rep->NewLine(3); $doctype = ST_SALESINVOICE; $rep->NewLine(); $rep->Font('bold'); $rep->TextCol(6, 7, "TOTAL AMOUNT :"); $rep->TextCol(6, 8, $DisplayNet, -2); $rep->NewLine(); $rep->TextCol(6, 7, "VOLUME DISCOUNT :"); $rep->TextCol(5, 8, $DisplayDiscount, -2); $rep->NewLine(); $rep->TextCol(6, 7, _("NET AMOUNT : "), -2); $rep->TextCol(5, 8, $DisplayTots, -2); $rep->NewLine(); if ($email == 1) { $rep->End($email); } } if ($email == 0) { $rep->End(); } }
function getProduct($id, $pp_kod) { $query = "SELECT * FROM p_product WHERE pp_kod='{$pp_kod}'"; $result = selQuery($query); $row = mysqli_fetch_assoc($result); $manu = "SELECT * FROM p_product_manu\n ppm_pp_kod='{$pp_kod}'"; $m_result = selQuery($manu); $m_row = mysqli_fetch_assoc($m_result); $ownerID = $row['pp_osa_kod_owner']; $holderID = $row['pp_osa_kod_holder']; $manuID = $m_row['ppm_osa_kod']; ?> <div id="preview"> <div class="row"> <div class="alert alert-sm alert-border-left alert-primary"><b>Product Information</b></div> <div class="col-md-6"> <?php if ($id == 2) { ?> <b>Call No : </b> <p><?php echo isEmpty($pp_kod); ?> </p> <?php } else { ?> <b>Reference No : </b> <p><?php echo isEmpty($row['pp_ref_no']); ?> </p> <?php } ?> </div> <div class="col-md-6"> <b>Brand Name : </b> <p><?php echo isEmpty($row["pp_nama_brand"]); ?> </p> </div> <div class="col-md-6"> <b>Generic Name : </b> <p><?php echo isEmpty($row["pp_nama_generic"]); ?> </p> </div> <div class="col-md-6"> <b>Full product name : </b> <p><?php echo isEmpty($row["pp_nama"]); ?> </p> </div> </div> <div class="row"> <div class="alert alert-sm alert-border-left alert-primary"><b>Application Details</b></div> <div class="col-md-6"> <b>Company Name :</b> <p><?php echo isEmpty(getUser($holderID, "os_sykt")); ?> </p> </div> <div class="col-md-6"> <b>Company Registration No :</b> <p><?php echo isEmpty(getUser($holderID, "os_no_reg")); ?> </p> </div> <div class="col-md-6"> <b>Company Registration Certificate :</b> <p><?php echo isEmpty(getUser($holderID, "os_att_crf")); ?> </p> </div> <div class="col-md-6"> <b>Telephone :</b> <p><?php echo isEmpty(getUser($holderID, "osa_notel")); ?> </p> </div> <div class="col-md-12"> <b>Address of Business Premise/Manufacturing Premise :</b> <p><?php echo isEmpty($holderID); ?> </p> </div> </div> <div class="row"> <div class="alert alert-sm alert-border-left alert-primary"><b>Product Owner</b></div> <div class="col-md-6"> <b>Company Name :</b> <p><?php echo isEmpty(getUser($ownerID, "os_sykt")); ?> </p> </div> <div class="col-md-6"> <b>Role of Product Owner :</b> <p><?php echo isEmpty($ownerID); ?> </p> </div> <div class="col-md-6"> <b>Letter of Authorization from Product Owner :</b><br /> <p><?php echo getFile($pp_kod, "productOwner"); ?> </p> </div> <div class="col-md-12"> <b>Address of Business Premise/Manufacturing Premise :</b> <p><?php echo isEmpty($ownerID); ?> </p> </div> </div> <div class="row"> <div class="alert alert-sm alert-border-left alert-primary"><b>Manufacturer</b></div> <div class="col-md-6"> <b>Name</b> <p><?php echo isEmpty(getUser($manuID, "os_sykt")); ?> </p> </div> <div class="col-md-12"> <b>Address of Business Premise/Manufacturing Premise :</b> <p><?php echo isEmpty($manuID); ?> </p> </div> </div> <div class="row"> <div class="alert alert-sm alert-border-left alert-primary"><b>Other Manufacturer</b></div> <div class="col-md-6"> <b>Name</b> <p><?php echo isEmpty(getUser($manuID, "os_sykt")); ?> </p> </div> <div class="col-md-12"> <b>Address of Business Premise/Manufacturing Premise :</b> <p><?php echo isEmpty($manuID); ?> </p> </div> </div> <div class="row"> <div class="alert alert-sm alert-border-left alert-primary"><b>Contact Person</b></div> <div class="col-md-6"> <b>Name :</b> <p><?php echo isEmpty(getContact(getUser($holderID, "os_kod"), "osm_nama")); ?> </p> </div> <div class="col-md-6"> <b>Contact No :</b> <p><?php echo isEmpty(getContact(getUser($holderID, "os_kod"), "osm_notel")); ?> </p> </div> <div class="col-md-12"> <b>Email :</b> <p><?php echo isEmpty(getContact(getUser($holderID, "os_kod"), "osm_email")); ?> </p> </div> </div> </div> <?php }
updateSubscription($_POST['username'], $authuser, $authpw, $subID); break; case 'deleteSub': deleteSub($_POST['username'], $authuser, $authpw, $subID); break; case 'getIndivSubInfo': getIndivSubInfo($_POST['username'], $authuser, $authpw, $subID); break; case 'getAllSubInfo': getAllSubInfo($_POST['username'], $authuser, $authpw); break; case 'getContacts': getContacts($_POST['username'], $authuser, $authpw); break; case 'getContact': getContact($_POST['username'], $authuser, $authpw, $contactID); break; case 'addEditContact': addEditContact($_POST['username'], $authuser, $authpw, $contactName, $contactID); break; case 'removeContact': removeContact($_POST['username'], $authuser, $authpw, $contactID); break; case 'getContactAttributes': getContactAttributes($_POST['username'], $authuser, $authpw, $contactID); break; case 'getContactAttribute': getContactAttribute($_POST['username'], $authuser, $authpw, $attributeName); break; case 'updateAttribute': updateAttribute($_POST['username'], $authuser, $authpw, $contactName, $contactID);
function InfusionSoft($that) { global $wpdb; if (!class_exists('xmlrpcmsg') || !class_exists('xmlrpcval') || !class_exists('xmlrpc_client')) { include_once $x = $that->pluginDir . '/extlib/xmlrpc.php'; } //All FUNCTIONS Starts Here //function for getting the product sku using the product id in infusionsoft function getProductSku($Id, $con, $key) { $msg = new xmlrpcmsg('DataService.findByField'); $msg->addParam(new xmlrpcval($key)); $msg->addParam(new xmlrpcval('Product')); $msg->addParam(new xmlrpcval(1, 'int')); $msg->addParam(new xmlrpcval(0, 'int')); $msg->addParam(new xmlrpcval('Id')); $msg->addParam(new xmlrpcval($Id)); $msg->addParam(new xmlrpcval(array(new xmlrpcval('Sku')), 'array')); $product = $con->send($msg); $product = $product->value(); if ($product) { return $product[0]; } else { return false; } } //function for getting the contact info from infusionsoft function getContact($Id, $con, $key) { $msg = new xmlrpcmsg('ContactService.load'); $msg->addParam(new xmlrpcval($key)); $msg->addParam(new xmlrpcval($Id, 'int')); $msg->addParam(new xmlrpcval(array(new xmlrpcval('Id'), new xmlrpcval('FirstName'), new xmlrpcval('LastName'), new xmlrpcval('Email'), new xmlrpcval('Company'), new xmlrpcval('StreetAddress1'), new xmlrpcval('StreetAddress2'), new xmlrpcval('City'), new xmlrpcval('State'), new xmlrpcval('PostalCode'), new xmlrpcval('Country')), 'array')); $user = $con->send($msg); $user = $user->value(); return $user; } //function for getting the invoice using invoice id function getInvoice($Id, $con, $key) { $msg = new xmlrpcmsg('DataService.findByField'); $msg->addParam(new xmlrpcval($key)); $msg->addParam(new xmlrpcval('Invoice')); $msg->addParam(new xmlrpcval(1, 'int')); $msg->addParam(new xmlrpcval(0, 'int')); $msg->addParam(new xmlrpcval('Id')); $msg->addParam(new xmlrpcval($Id)); $msg->addParam(new xmlrpcval(array(new xmlrpcval('Id'), new xmlrpcval('ContactId'), new xmlrpcval('JobId'), new xmlrpcval('DateCreated'), new xmlrpcval('TotalDue'), new xmlrpcval('PayStatus'), new xmlrpcval('CreditStatus'), new xmlrpcval('RefundStatus'), new xmlrpcval('PayPlanStatus'), new xmlrpcval('InvoiceType'), new xmlrpcval('ProductSold')), 'array')); $invoice = $con->send($msg); $invoice = $invoice->value(); if ($invoice) { return $invoice[0]; } else { return false; } } //function for getting the invoice using jobid function getInvoiceByJobId($JobId, $con, $key) { $msg = new xmlrpcmsg('DataService.findByField'); $msg->addParam(new xmlrpcval($key)); $msg->addParam(new xmlrpcval('Invoice')); $msg->addParam(new xmlrpcval(1, 'int')); $msg->addParam(new xmlrpcval(0, 'int')); $msg->addParam(new xmlrpcval('JobId')); $msg->addParam(new xmlrpcval($JobId, 'int')); $msg->addParam(new xmlrpcval(array(new xmlrpcval('Id'), new xmlrpcval('ContactId'), new xmlrpcval('DateCreated'), new xmlrpcval('TotalDue'), new xmlrpcval('JobId'), new xmlrpcval('PayStatus'), new xmlrpcval('CreditStatus'), new xmlrpcval('RefundStatus'), new xmlrpcval('PayPlanStatus'), new xmlrpcval('InvoiceType'), new xmlrpcval('ProductSold')), 'array')); $invoices = $con->send($msg); $invoices = $invoices->value(); if (empty($invoices)) { return false; } return $invoices[0]; } //function for getting the Job using order id passed in url function getJob($orderId, $con, $key) { $msg = new xmlrpcmsg('DataService.findByField'); $msg->addParam(new xmlrpcval($key)); $msg->addParam(new xmlrpcval('Job')); $msg->addParam(new xmlrpcval(1, 'int')); $msg->addParam(new xmlrpcval(0, 'int')); $msg->addParam(new xmlrpcval('Id')); $msg->addParam(new xmlrpcval($orderId, 'int')); $msg->addParam(new xmlrpcval(array(new xmlrpcval('Id'), new xmlrpcval('JobTitle'), new xmlrpcval('ContactId'), new xmlrpcval('StartDate'), new xmlrpcval('DueDate'), new xmlrpcval('JobNotes'), new xmlrpcval('ProductId'), new xmlrpcval('JobStatus'), new xmlrpcval('DateCreated'), new xmlrpcval('JobRecurringId'), new xmlrpcval('OrderType'), new xmlrpcval('OrderStatus')), 'array')); $jobs = $con->send($msg); $jobs = $jobs->value(); if (empty($jobs)) { return false; } return $jobs[0]; } //function for getting the payplan items function GetPayplanItems($payplan_id, $con, $key) { // retrieve Payplan Items $msg = new xmlrpcmsg('DataService.findByField'); $msg->addParam(new xmlrpcval($key)); $msg->addParam(new xmlrpcval('PayPlanItem')); $msg->addParam(new xmlrpcval(10, 'int')); $msg->addParam(new xmlrpcval(0, 'int')); $msg->addParam(new xmlrpcval('PayPlanId')); $msg->addParam(new xmlrpcval($payplan_id)); $msg->addParam(new xmlrpcval(array(new xmlrpcval('Id'), new xmlrpcval('PayPlanId'), new xmlrpcval('DateDue'), new xmlrpcval('AmtDue'), new xmlrpcval('Status')), 'array')); $ppi = $con->send($msg); $ppi = $ppi->value(); if ($ppi) { $ret = $ppi; } else { $ret = false; } return $ret; } //function for getting the payplan status function GetPayplanStatus($invoice_id, $con, $key) { // retrieve Payplan $msg = new xmlrpcmsg('DataService.findByField'); $msg->addParam(new xmlrpcval($key)); $msg->addParam(new xmlrpcval('PayPlan')); $msg->addParam(new xmlrpcval(1, 'int')); $msg->addParam(new xmlrpcval(0, 'int')); $msg->addParam(new xmlrpcval('InvoiceId')); $msg->addParam(new xmlrpcval($invoice_id)); $msg->addParam(new xmlrpcval(array(new xmlrpcval('Id'), new xmlrpcval('InvoiceId'), new xmlrpcval('AmtDue'), new xmlrpcval('DateDue'), new xmlrpcval('InitDate'), new xmlrpcval('StartDate')), 'array')); $pp = $con->send($msg); $pp = $pp->value(); if ($pp) { $pp = $pp[0]; if ($pp['StartDate'] > date('Ymd\\TH:i:s', strtotime('EST')) && !empty($pp['StartDate'])) { $ret = array("PayPlanId" => $pp['Id'], "OverDue" => false); } else { $ret = array("PayPlanId" => $pp['Id'], "OverDue" => true); } } else { $ret = false; } return $ret; } //function for getting the subscription using product id function GetSubscriptionStatusByPID($contactID, $PId, $con, $key) { $msg = new xmlrpcmsg('DataService.query'); $msg->addParam(new xmlrpcval($key)); $msg->addParam(new xmlrpcval('RecurringOrder')); $msg->addParam(new xmlrpcval(1, 'int')); $msg->addParam(new xmlrpcval(0, 'int')); $msg->addParam(new xmlrpcval(array('ContactId' => new xmlrpcval($contactID), 'ProductId' => new xmlrpcval($PId, 'int')), 'struct')); $msg->addParam(new xmlrpcval(array(new xmlrpcval('Id'), new xmlrpcval('ContactId'), new xmlrpcval('OriginatingOrderId'), new xmlrpcval('SubscriptionPlanId'), new xmlrpcval('ProductId'), new xmlrpcval('StartDate'), new xmlrpcval('EndDate'), new xmlrpcval('LastBillDate'), new xmlrpcval('NextBillDate'), new xmlrpcval('ReasonStopped'), new xmlrpcval('Status')), 'array')); $recur = $con->send($msg); $recur = $recur->value(); if ($recur) { return $recur[0]; } else { return false; } } //function for get the subscription using subscription id function GetSubscriptionStatusBySID($SId, $con, $key) { $msg = new xmlrpcmsg('DataService.query'); $msg->addParam(new xmlrpcval($key)); $msg->addParam(new xmlrpcval('RecurringOrder')); $msg->addParam(new xmlrpcval(1, 'int')); $msg->addParam(new xmlrpcval(0, 'int')); $msg->addParam(new xmlrpcval(array('Id' => new xmlrpcval($SId, 'int')), 'struct')); $msg->addParam(new xmlrpcval(array(new xmlrpcval('Id'), new xmlrpcval('ContactId'), new xmlrpcval('OriginatingOrderId'), new xmlrpcval('SubscriptionPlanId'), new xmlrpcval('ProductId'), new xmlrpcval('StartDate'), new xmlrpcval('EndDate'), new xmlrpcval('LastBillDate'), new xmlrpcval('NextBillDate'), new xmlrpcval('ReasonStopped'), new xmlrpcval('Status')), 'array')); $recur = $con->send($msg); $recur = $recur->value(); if ($recur) { return $recur[0]; } else { return false; } } //function for getting subscription using jobid function GetSubscriptionStatusByJID($contactID, $JId, $con, $key) { $msg = new xmlrpcmsg('DataService.query'); $msg->addParam(new xmlrpcval($key)); $msg->addParam(new xmlrpcval('RecurringOrder')); $msg->addParam(new xmlrpcval(1, 'int')); $msg->addParam(new xmlrpcval(0, 'int')); $msg->addParam(new xmlrpcval(array('ContactId' => new xmlrpcval($contactID), 'OriginatingOrderId' => new xmlrpcval($JId, 'int')), 'struct')); $msg->addParam(new xmlrpcval(array(new xmlrpcval('Id'), new xmlrpcval('ContactId'), new xmlrpcval('OriginatingOrderId'), new xmlrpcval('SubscriptionPlanId'), new xmlrpcval('ProductId'), new xmlrpcval('StartDate'), new xmlrpcval('EndDate'), new xmlrpcval('LastBillDate'), new xmlrpcval('NextBillDate'), new xmlrpcval('ReasonStopped'), new xmlrpcval('Status')), 'array')); $recur = $con->send($msg); $recur = $recur->value(); if ($recur) { return $recur[0]; } else { return false; } } function getInvoiceRefunds($con, $key, $invid) { $con->return_type = 'phpvals'; $con->setSSLVerifyHost(0); $con->setSSLVerifyPeer(0); $msg = new xmlrpcmsg('DataService.query'); $msg->addParam(new xmlrpcval($key)); $msg->addParam(new xmlrpcval('InvoicePayment')); $msg->addParam(new xmlrpcval(1000, 'int')); $msg->addParam(new xmlrpcval(0, 'int')); $msg->addParam(new xmlrpcval(array('InvoiceId' => new xmlrpcval($invid, 'int')), 'struct')); $msg->addParam(new xmlrpcval(array(new xmlrpcval('Id'), new xmlrpcval('InvoiceId'), new xmlrpcval('Amt'), new xmlrpcval('PayStatus'), new xmlrpcval('PaymentId'), new xmlrpcval('SkipCommission')), 'array')); $inv_payments = $con->send($msg); $inv_payments = $inv_payments->value(); $refunded_amount = 0; if ($inv_payments) { foreach ($inv_payments as $inv_payment) { if ($inv_payment['PayStatus'] == 'Refunded') { $refunded_amount += abs($inv_payment['Amt']); } } } return $refunded_amount; } function isLastInvoicePaid($con, $key, $invoice) { //lets get the jobs for the subscription $jobs = GetSubscriptionJobs($invoice['SubscriptionId'], $con, $key); if (!$jobs) { return false; } //no job then unpaid $job_ids = array_map(create_function('$arr', 'return $arr["Id"];'), $jobs); //we only need the ids $latest_jobid = max($job_ids); //get the latest invoice of this subscription $latest_invoice = getInvoiceByJobId($latest_jobid, $con, $key); //get the invoice of this job if (!$latest_invoice) { return false; } //if invoice unpaid return (bool) $latest_invoice["PayStatus"]; } //get jobs related for this subscription/recurringorder //in order to get the invoices for this subscription function GetSubscriptionJobs($recurid, $con, $key) { $con->return_type = 'phpvals'; $con->setSSLVerifyHost(0); $con->setSSLVerifyPeer(0); $msg = new xmlrpcmsg('DataService.query'); $msg->addParam(new xmlrpcval($key)); $msg->addParam(new xmlrpcval('Job')); $msg->addParam(new xmlrpcval(1000, 'int')); $msg->addParam(new xmlrpcval(0, 'int')); $msg->addParam(new xmlrpcval(array('JobRecurringId' => new xmlrpcval($recurid, 'int')), 'struct')); $msg->addParam(new xmlrpcval(array(new xmlrpcval('Id'), new xmlrpcval('JobTitle'), new xmlrpcval('ContactId'), new xmlrpcval('JobRecurringId'), new xmlrpcval('ProductId')), 'array')); $jobs = $con->send($msg); $jobs = $jobs->value(); return $jobs; } //function for getting the status of the invoice or subscription function GetStatus($invoice, $con, $key) { $sid = isset($invoice['SubscriptionId']) ? $invoice['SubscriptionId'] : ""; $pid = $invoice['ProductSold']; if ($sid == "") { //old transaction id, base the search from contact id and product id //THIS IS FOR OLD VERSION OF IF INTEGRATION $invoice['Status'] = $invoice['PayStatus'] == 1 && $invoice['RefundStatus'] == 0 ? 'active' : 'inactive'; $recur = GetSubscriptionStatusByPID($invoice['ContactId'], $pid, $con, $key); if ($recur && !empty($recur['Status'])) { // make sure that we're not processing an empty field. fixes issue with complete recurring subscriptions $invoice['Status'] = strtolower($recur['Status']); } } else { //NEW INFUSIONSOFT UPDATES AFTER THE SPRING RELEASE, we added subscription id for subscriptions //non subscriptions have 00 values $invoice['Status'] = $invoice['PayStatus'] == 1 && $invoice['RefundStatus'] == 0 ? 'active' : 'inactive'; //process subscriptions if ($sid != "00") { // subscriptions have number values $recur = GetSubscriptionStatusBySID($sid, $con, $key); } else { // if subscription is not available, use the job id $recur = GetSubscriptionStatusByJID($invoice['ContactId'], $invoice['JobId'], $con, $key); } //subscription if ($recur && !empty($recur['Status'])) { // make sure that we're not processing an empty field. fixes issue with complete recurring subscriptions //assign the subscription id $invoice['SubscriptionId'] = $recur['Id']; unset($recur['Id']); $invoice = array_merge($invoice, $recur); if ($recur['Status'] != "Active") { $refund = getInvoiceRefunds($con, $key, $invoice['Id']); //getrefunds of invoice $full_refund = $refund != 0 && $refund >= $invoice['TotalDue'] ? true : false; if ($full_refund || strtolower(trim($recur['ReasonStopped'])) == "refund") { $invoice['Status'] = "inactive"; } else { if ($recur['NextBillDate'] > date('Ymd\\TH:i:s', strtotime('EST'))) { //if no active, lets cancel them only when the next bill date has passed already if (isLastInvoicePaid($con, $key, $invoice)) { //if last invoice is paid, wait for next bill date because he paid $invoice['Status'] = "active"; } } else { $invoice['Status'] = strtolower($recur['Status']); } } } else { $invoice['Status'] = strtolower($recur['Status']); } } else { //one time payment if ($invoice['Status'] == "inactive" && $invoice['RefundStatus'] == 1) { //check if refunded $refund = getInvoiceRefunds($con, $key, $invoice['Id']); $full_refund = $refund != 0 && $refund >= $invoice['TotalDue'] ? true : false; if (!$full_refund) { $invoice['Status'] = "active"; } } } } //if invoice is inactive, lets check if its has payment plan if ($invoice['Status'] == "inactive") { $invstat = "inactive"; //lets get the payment plan for this invoice $pp = GetPayplanStatus($invoice['Id'], $con, $key); if ($pp) { if ($pp['OverDue']) { //if it has overdue payment plan //get the payment plan items $ppi = GetPayplanItems($pp['PayPlanId'], $con, $key); if ($ppi) { //get the payment plan items with unpaid status foreach ((array) $ppi as $ppitems) { if ($ppitems['Status'] == 1) { //if it has unpaid payment plan items and its not yet due if ($ppitems['DateDue'] > date('Ymd\\TH:i:s', strtotime('EST'))) { $invstat = "active"; } else { //else its due $invstat = "inactive"; } break; } } } } else { //if payment plan has number of days before charging and its not overdue $invstat = "active"; } } $invoice['Status'] = $invstat; } return $invoice; } //End of FUNTCTIONS // START PROCESSING HERE $url = 'https://' . $that->GetOption('ismachine') . '.infusionsoft.com:443/api/xmlrpc'; $key = $that->GetOption('isapikey'); $con = new xmlrpc_client($url); $con->return_type = 'phpvals'; $con->setSSLVerifyHost(0); $con->setSSLVerifyPeer(0); $invmarker = 'InfusionSoft'; $_GET['iscron'] = isset($_GET['iscron']) ? $_GET['iscron'] : ""; $_GET['iscron'] = isset($_POST['contactId']) ? "ProcessContact" : $_GET['iscron']; switch (wlm_arrval($_GET, 'iscron')) { case 'ProcessContact': $contactid = $_POST['contactId']; $add_level = isset($_POST['add']) ? $_POST['add'] : false; $remove_level = isset($_POST['remove']) ? $_POST['remove'] : false; $cancel_level = isset($_POST['cancel']) ? $_POST['cancel'] : false; $debug = isset($_GET['debug']) ? true : false; //if none of these are present, we stop if (!$add_level && !$remove_level && !$cancel_level) { if ($debug) { echo "No action found. <br />"; } exit; break; } //check if contact exist in infusionsoft $contact = getContact($contactid, $con, $key); if (!$contact) { if ($debug) { echo "No Contact found. <br />"; } exit; break; } usleep(1000000); $uname = isset($_POST['WLMUserName']) && $_POST['WLMUserName'] != "" ? $_POST['WLMUserName'] : $contact['Email']; $pword = isset($_POST['WLMPassWord']) && $_POST['WLMPassWord'] != "" ? $_POST['WLMPassWord'] : $that->PassGen(); $regemail = isset($_POST['WLMRegEmail']) && strtolower($_POST['WLMRegEmail']) == "no" ? false : true; $sequential = isset($_POST['WLMSequential']) && strtolower($_POST['WLMSequential']) == "no" ? false : true; //first we get check if this user exist using txnid $wpm_user = $that->GetUserIDFromTxnID("IFContact-{$contactid}"); $new_user = false; //if not, check if it exist using the email address if (!$wpm_user) { if ($debug) { echo "No User associated with this Contact.<br />Checking for contact email if matches found on user. <br />"; } if (function_exists('get_user_by')) { $wpm_user = get_user_by('email', $contact["Email"]); $wpm_user = $wpm_user ? $wpm_user->ID : false; } else { $wpm_user = email_exists($contact["Email"]); } } //if not, check if it exist using the username if (!$wpm_user) { if ($debug) { echo "Checking for username if matches found on username. <br />"; } if (function_exists('get_user_by')) { $wpm_user = get_user_by('login', $uname); $wpm_user = $wpm_user ? $wpm_user->ID : $wpm_user; } } //if the user does not exist yet and its adding to level //lets create a new user using api if (!$wpm_user && $add_level) { if ($debug) { echo "No user found. Creating user. (Available if add is present) <br />"; } $wlm_api_key = $that->GetOption("WLMAPIKey"); $wlm_site_url = home_url('/'); $wlm_apiclass = new wlmapiclass($wlm_site_url, $wlm_api_key); $wlm_apiclass->return_format = "php"; // prepare data $data = array(); $data['last_name'] = $contact['LastName']; $data['first_name'] = $contact['FirstName']; $data['user_login'] = $uname; $data['user_email'] = $contact['Email']; $data['user_pass'] = $pword; $data['display_name'] = "{$contact['FirstName']} {$contact['LastName']}"; $data['Sequential'] = $sequential; $address['address1'] = $contact['StreetAddress1']; $address['address2'] = $contact['StreetAddress2']; $address['city'] = $contact['City']; $address['state'] = $contact['State']; $address['zip'] = $contact['PostalCode']; $address['country'] = $contact['Country']; $data["SendMail"] = $regemail; $data["Levels"] = explode(",", $add_level); //add the level here $wpm_errmsg = ''; if (function_exists("wlmapi_add_member")) { if ($debug) { echo "Adding using WLM internal function.<br />"; } $ret = wlmapi_add_member($data); } else { if ($debug) { echo "Adding sing WLM API Call.<br />"; } $ret = unserialize($wlm_apiclass->post("/members", $data)); } if ($ret["success"] && isset($ret["member"][0]["ID"])) { $wpm_user = $ret["member"][0]["ID"]; } else { if ($debug) { echo " Adding User Failed. Returns the following:"; } } if ($debug) { echo "<pre>"; var_dump($ret); echo "</pre><br />"; } $new_user = true; //this is new user } //assign infusiom contact id if none is assigned to this user if ($wpm_user) { $ifcontact = $that->Get_UserMeta($wpm_user, "wlminfusionsoft_contactid"); if (!$ifcontact) { if ($debug) { echo "Updating Contact ID for user.<br />"; } $that->Update_UserMeta($wpm_user, "wlminfusionsoft_contactid", $contactid); } } $current_user_mlevels = $that->GetMembershipLevels($wpm_user); $wpm_levels = $that->GetOption('wpm_levels'); if ($debug) { echo "Performing operations. Please wait..<br />"; } //add if ($wpm_user && $add_level) { $user_mlevels = $current_user_mlevels; $add_level_arr = explode(",", $add_level); if (in_array("all", $add_level_arr)) { $add_level_arr = array_merge($add_level_arr, array_keys($wpm_levels)); $add_level_arr = array_unique($add_level_arr); } if (!$new_user) { if ($debug) { echo "Adding Levels.<br />"; } foreach ($add_level_arr as $id => $add_level) { if (isset($wpm_levels[$add_level])) { //check if valid level if (!in_array($add_level, $user_mlevels)) { $user_mlevels[] = $add_level; $that->SetMembershipLevels($wpm_user, $user_mlevels); $that->SetMembershipLevelTxnID($wpm_user, $add_level, "IFContact-{$contactid}"); } else { //just uncancel the user $ret = $that->LevelCancelled($add_level, $wpm_user, false); } } elseif (strrpos($add_level, "payperpost") !== false) { $that->SetPayPerPost($wpm_user, $add_level); } } if ($debug) { echo count($add_level_arr) . " Levels Added.<br />"; } } else { if ($debug) { echo "Updating Level Transaction ID.<br />"; } foreach ($add_level_arr as $id => $add_level) { if (isset($wpm_levels[$add_level])) { //check if valid level $that->SetMembershipLevelTxnID($wpm_user, $add_level, "IFContact-{$contactid}"); } } } } //cancel if ($wpm_user && $cancel_level) { if ($debug) { echo "Cancelling Levels.<br />"; } $user_mlevels = $current_user_mlevels; $cancel_level_arr = explode(",", $cancel_level); if (in_array("all", $cancel_level_arr)) { $cancel_level_arr = array_merge($cancel_level_arr, array_keys($wpm_levels)); $cancel_level_arr = array_unique($cancel_level_arr); } foreach ($cancel_level_arr as $id => $cancel_level) { if (isset($wpm_levels[$cancel_level])) { //check if valid level if (in_array($cancel_level, $user_mlevels)) { $ret = $that->LevelCancelled($cancel_level, $wpm_user, true); } } } if ($debug) { echo count($cancel_level_arr) . " Levels Cancelled.<br />"; } } //remove if ($wpm_user && $remove_level) { if ($debug) { echo "Removing Levels.<br />"; } $user_mlevels = $current_user_mlevels; $remove_level_arr = explode(",", $remove_level); if (in_array("all", $remove_level_arr)) { $remove_level_arr = array_merge($remove_level_arr, array_keys($wpm_levels)); $remove_level_arr = array_unique($remove_level_arr); } foreach ($remove_level_arr as $id => $remove_level) { $arr_index = array_search($remove_level, $user_mlevels); if ($arr_index !== false) { unset($user_mlevels[$arr_index]); } elseif (strrpos($remove_level, "payperpost") !== false) { list($marker, $pid) = explode("-", $remove_level); $post_type = get_post_type($pid); $that->RemovePostUsers($post_type, $pid, $wpm_user); } } $that->SetMembershipLevels($wpm_user, $user_mlevels); if ($debug) { echo count($remove_level_arr) . " Levels Removed.<br />"; } } if ($debug) { echo "Done.<br />"; } usleep(1000000); exit; break; case '1': set_time_limit(0); //override max execution time //get all the infusionsoft txn_id $qwhere = "WHERE uo.`option_value` LIKE '{$invmarker}%'"; $qjoin = "LEFT JOIN `{$that->Tables->userlevels}` AS ul ON uo.`userlevel_id` = ul.`ID`"; $query = "SELECT ul.`level_id` as levelid, ul.`user_id` as uid, uo.`option_value` as option_value FROM `{$that->Tables->userlevel_options}` AS uo {$qjoin} {$qwhere}"; $trans = $wpdb->get_results($query); $istrans = array(); foreach ($trans as $t) { $txn_id = $t->option_value; //format {marker}-{invoice#}-{subcriptionid} list($marker, $tid) = explode('-', $txn_id, 2); //seperate the marker from the others // $istrans[$t->uid] = array("level"=>$t->levelid, "invid"=>$tid); //{invoice#}-{subcriptionid} left $istrans[$tid] = array("level" => $t->levelid, "uid" => $t->uid); } $wlmlevels = $that->GetOption('wpm_levels'); // $istrans = array_unique($istrans); $cnt = count($istrans); $log = "Syncing Infusionsoft Transactions with WLM<br />"; $log .= "<i>You should see a message below saying that all records were processed.<br />If not some records might not been processed due to lack of computer resources or an error occured.</i>"; if ($cnt > 0) { $log .= "<br /><br />Found <strong>{$cnt}</strong> record/s:<br />"; $log .= "Processing please wait...<br />"; } else { $log .= "<br /><br />No Records to Sync."; } //loop through the txn_ids $rec = 1; $log_tbl = ""; foreach ((array) $istrans as $invid => $data) { list($iid, $sid) = explode('-', $invid, 2); // retrieve Invoice id and Sub id $uid = $data['uid']; $invoice = getInvoice($iid, $con, $key); $mstat = "Active"; // do we have a valid invoice? if so, retrieve the status if ($invoice) { $invoice["SubscriptionId"] = $sid; //include the subscription id $invoice = GetStatus($invoice, $con, $key); //get invoice status // update level status based on invoice status $_POST['sctxnid'] = "{$invmarker}-" . $invid; switch ($invoice['Status']) { case 'active': $that->ShoppingCartReactivate(); // Add hook for Shoppingcart reactivate so that other plugins can hook into this $_POST['sc_type'] = 'Infusionsoft'; do_action('wlm_shoppingcart_rebill', $_POST); break; default: //'inactive': $that->ShoppingCartDeactivate(); } $mstat = ucfirst($invoice['Status']); } $stat = $invoice ? "Processed" : "Invalid invoice"; $user_url = admin_url("user-edit.php?user_id={$uid}&wp_http_referer=wlm"); $lvlname = isset($wlmlevels[$data['level']]) ? $wlmlevels[$data['level']]['name'] : 'Unknown'; $log_tbl .= "<tr><td><a target='_blank' href='{$user_url}'>{$uid}</a></td><td>{$lvlname}</td><td>{$invmarker}-{$invid}</td><td>{$iid}</td><td>{$stat}</td><td>{$mstat}</td></tr>"; // $rec++ . ($invoice ? "(OK)" : "(Invalid)") . ", "; $rec++; } $log .= "<table style='width:100%;' border='1'><tr><th>User ID</th><th>Level</th><th>Transaction Id</th><th>Invoice#</th><th>Result</th><th>Membership Status</th></tr>" . $log_tbl . "</table>"; //lets end the cron job here $log .= "<br /><br /><b>FINISHED</b>.<i>All {$cnt} records were processed.</i>"; //display logs for admin only $current_user = wp_get_current_user(); if ($current_user->caps['administrator']) { echo $log; } else { echo "WLM Infusionsoft Integration syncing done. For more detailed output, login an admin account and refresh this page."; } exit; break; default: // catch the data from infusionsoft after payment //get the productid to be used for free trial subscriptions $SubscriptionPlanProductId = isset($_GET['SubscriptionPlanProductId']) ? $_GET['SubscriptionPlanProductId'] : false; //get the subscription id $SubscriptionId = isset($_GET['SubscriptionId']) ? $_GET['SubscriptionId'] : "00"; //if its a free trial $isTrial = isset($_GET['SubscriptionPlanWait']) ? true : false; //debug $debug = isset($_GET['debug']) ? true : false; // retrieve Job using OrderID passed $job = getJob($_GET['orderId'], $con, $key); if (!$job) { if ($debug) { echo "Invalid OrderID passed.({$_GET['orderId']})<br />"; exit(0); } else { return false; //if job(OrderID) does not exist, end } } /* * fix for new order form * new order form does not pass the contactId */ if (empty($_GET['contactId'])) { //get the contact id from the job $contactId = $job['ContactId']; } else { //get the contact id from $_GET $contactId = $_GET['contactId']; } //retrieve the user info $user = getContact($contactId, $con, $key); if (!$user) { if ($debug) { echo "Invalid Contact.({$contactId})<br />"; exit(0); } else { return false; //if no user exist, end } } //retrieve invoice using our job Id $invoice = getInvoiceByJobId($job['Id'], $con, $key); if (!$invoice) { if ($debug) { echo "No Invoice found for this order.({$job['Id']})<br />"; exit(0); } else { return false; //if no invoice for that job, end } } //if its a subscription plan with free trial //populate the ProductSold field of invoice if ($SubscriptionPlanProductId && $isTrial) { $invoice['ProductSold'] = (int) $SubscriptionPlanProductId; //set the product id to SubscriptionPlanProductId, they have the same value } //set the $invoice Subscription Id $invoice['SubscriptionId'] = $SubscriptionId; //process the invoice and get its status $invoice = GetStatus($invoice, $con, $key); // fetch Sku for the product of the invoice // product id is used to search for the sku // we loop through each product sold and break the loop if we find a sku that matches a WishList Member level ID $wpm_levels = $that->GetOption('wpm_levels'); foreach (explode(',', $invoice['ProductSold']) as $psold) { $product = getProductSku($psold, $con, $key); $valid_sku = $that->IsPPPLevel($product['Sku']) || isset($wpm_levels[$product['Sku']]) ? true : false; if ($product && $valid_sku) { if (!$invoice['Sku']) { $invoice['Sku'] = $product['Sku']; } else { $_POST['additional_levels'][] = $product['Sku']; } } } //if no product sku then lets end here if (!isset($invoice['Sku']) || $invoice['Sku'] == "" || empty($invoice['Sku'])) { if ($debug) { echo "Invalid Product SKU.<br />"; exit(0); } else { return false; } } // if we're active, then good. if ($invoice['Status'] != 'active') { if ($debug) { echo "Inactive Invoice.({$invoice['Id']})<br />"; exit(0); } else { return false; } } // prepare data $_POST['lastname'] = $user['LastName']; $_POST['firstname'] = $user['FirstName']; $_POST['action'] = 'wpm_register'; $_POST['wpm_id'] = $invoice['Sku']; $_POST['username'] = $user['Email']; $_POST['email'] = $user['Email']; $_POST['password1'] = $_POST['password2'] = $that->PassGen(); $_POST['sctxnid'] = "{$invmarker}-" . $invoice['Id'] . "-{$SubscriptionId}"; //prepare the address fields using info from shopping cart $address['company'] = $user['Company']; $address['address1'] = $user['StreetAddress1']; $address['address2'] = $user['StreetAddress2']; $address['city'] = $user['City']; $address['state'] = $user['State']; $address['zip'] = $user['PostalCode']; $address['country'] = $user['Country']; $_POST['wpm_useraddress'] = $address; if ($debug) { echo "Integration is working fine.<br />"; echo "<pre>"; var_dump($_POST); echo "</pre>"; exit(0); } // do registration $that->ShoppingCartRegistration(); } //END OF SWITCH CASE }
$text->addSoftKey('6','','SoftKey:Exit'); //hide default buttons $text->output(); */ $screen->setdestroyOnExit(); $screen->setBeep(); $screen->addLine(''); $screen->addLine(''); $screen->addLine(''); $screen->addLine('No Matches Found!', 'double', 'center'); $screen->setRefresh('2', $XML_SERVER_PATH . 'contactdir.php?user='******'&searchmethod=' . $searchmethod . '&searchterm=' . $search); $screen->addSoftKey('6', '', 'SoftKey:Exit'); $screen->output(); } //step 4: otherwise, we have a valid contacts, if they have details, show them } else { $contact = getContact($contact); if ($contact['tel'] || $contact['home'] || $contact['mobile']) { logit('$contact', print_r($contact, 1)); $menu->setTitleWrap(); $menu->setTitle('Please select a detail for ' . $contact['first_name'] . ' ' . $contact['last_name']); $menu->setDestroyOnExit(); if ($contact['tel']) { $menu->addEntry($contact['tel'], null, null, '1', $contact['tel']); } if ($contact['home']) { $menu->addEntry($contact['home'], null, null, '2', $contact['home']); } if ($contact['mobile']) { $menu->addEntry($contact['mobile'], null, null, '3', $contact['mobile']); } $menu->natsortByName();
// // Show the contact details page template for my.Contacts // Author: Keran McKenzie // Date: 19 Jan 2013 // // Provided as sample only, not intended for production // This page uses the $type variable to change its setup // *******************************************/ // // with this page we want to pull the contact details before we build the page // as we are going to use Google Maps & we load the maps javascript in the header of the page // we need pull and process the data before loading the header // // lets get our contact $contact = getContact($type, $id); $theAddress = $contact->Addresses[0]->Street . ', ' . $contact->Addresses[0]->City . ', ' . $contact->Addresses[0]->State . ', ' . $contact->Addresses[0]->PostCode . ', ' . $contact->Addresses[0]->Country; require_once 'header.php'; ?> <!-- setup a 2 col responsive page --> <div class="container-fluid"> <div class="row-fluid"> <!-- setup our sidebar --> <div class="span2"> <div class="hidden-phone"> <h2>Type</h2><!-- main screens --> <?php // little script to set the btn-primary on the current page switch ($type) { case "customer":
<?php error_reporting(E_ALL); $errors = array(); if (isset($_GET['contactId'])) { $contactId = $_GET['contactId']; } $contact = getContact($dbconn, $contactId); try { if (isset($_POST['create'])) { //validators $temail = trim($_POST['email']); $emailDup = checkEmailDup($dbconn, $temail); if (empty($temail)) { $errors['email'] = 'Please give us a valid email format.'; } elseif (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { $errors['email'] = "Please use a valid email format."; } else { if (mysqli_num_rows($emailDup) > 0) { $errors['email'] = "This email is already being used."; } } //password strength validation $tpw = trim($_POST['pwd']); //eliminate accidental space if (empty($tpw)) { $errors['pwd'] = 'Please create a password'; } else { if (!preg_match("/(?=^.{8,}\$)(?=.*\\d)(?=.*[!@#\$%^&*]+)(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*\$/", $_POST['pwd'])) { $errors['pwd'] = 'Must contain upper and lower case letter, numbers, and special characters.'; }
*/ $app->get('/contacts', function () use($app) { $body = $app->request->getBody(); $body = json_decode($body, true); $response = getContacts($body); header('Content-Type: application/json'); $app->response->setStatus(200); echo json_encode($response); }); /** * Get: a contact from the database. */ $app->get('/contacts/:id', function ($id) use($app) { $body = $app->request->getBody(); $body = json_decode($body, true); $response = getContact($body, $id); header('Content-Type: application/json'); $app->response->setStatus(200); echo json_encode($response); }); /** * Post: create new contact and post contact info */ $app->post('/contacts', function () use($app) { $body = $app->request->getBody(); $body = json_decode($body, true); $response = createContact($body); header('Content-Type: application/json'); $app->response->setStatus(200); echo json_encode($response); });
require_once 'Servicios/getContact.php'; $app = new \Slim\Slim(); require_once 'Servicios/Auth.php'; $log = new IOManager(); $log->logAll($app->request->headers); $deviceId = $app->request->headers->get('deviceID'); $hash = $app->request->headers->get('hash'); $respuesta = auth($deviceId, $hash); if ($respuesta != "Auth_OK") { echo $respuesta; return; } //Obtiene los parametros del header http $idContact = $app->request->headers->get('idContact'); //LLama el método que lee de la base de datos y obtiene la respuesta $respuesta = getContact($idContact); //Muestra la respuesta al cliente echo $respuesta; }); //-------------------------------------------------------------------------------------------------- $app->get('/getContacts', function () { //Importa el archivo que contiene el método require_once 'Servicios/getContacts.php'; $app = new \Slim\Slim(); require_once 'Servicios/Auth.php'; $deviceId = $app->request->headers->get('deviceID'); $hash = $app->request->headers->get('hash'); $respuesta = auth($deviceId, $hash); if ($respuesta != "Auth_OK") { echo $respuesta; return;