/**
  * A custom method within the Plugin to generate the content
  * 
  */
 function generateRecurrentInvoiceContent()
 {
     $output = '';
     $do_rec_inv = new RecurrentInvoice();
     $do_rec_inv->getRecurrentInvoiceDetail($_SESSION['do_invoice']->idinvoice);
     if ($do_rec_inv->getNumRows()) {
         $do_rec_inv->fetch();
         if ($do_rec_inv->recurrence > 1) {
             $output .= $rec_inv_text = _('This invoice repeats every') . $do_rec_inv->recurrence . " " . $do_rec_inv->recurrencetype . "s.";
         } else {
             $output .= $rec_inv_text = _('This invoice repeats') . " <i>" . _('every') . " " . $do_rec_inv->recurrencetype . "</i>.";
         }
         $output .= '<br />';
         $next_rec_inv_date = date("l F d, Y", strtotime($do_rec_inv->nextdate));
         $output .= _('The next invoice will be generated on ') . '<i>' . $next_rec_inv_date . '.</i>';
     } else {
         $this->setIsActive(false);
     }
     return $output;
 }
示例#2
0
//$do_contact = new Contact($GLOBALS['conx']);
//$do_company = new Company($GLOBALS['conx']);
//$do_task = new Task($GLOBALS['conx']);
//$do_task_category = new TaskCategory($GLOBALS['conx']);
//$do_contact_task = new Contact();
$invoice_access = true;
if ($invoice_access) {
    if (!is_object($_SESSION['do_invoice'])) {
        //$do_invoice = new Invoice();
        //$do_invoice->sessionPersistent("do_invoice", "index.php", OFUZ_TTL);
        echo _('Your page session has been expired. Please go back to the Invoice page and try again.');
        exit;
    }
    $do_company = new Company();
}
$RecurrentInvoice = new RecurrentInvoice();
$id_rec = $RecurrentInvoice->checkIfInvoiceIsInRecurrent($_SESSION['do_invoice']->idinvoice);
// Check if recurrent
if ($id_rec) {
    $is_recurrent = $id_rec;
    $RecurrentInvoiceCC = new RecurrentInvoiceCC();
    $id_rec_cc = $RecurrentInvoiceCC->has_cc_info($id_rec);
    //Check if having CC in DB
    if (!$id_rec_cc) {
        $id_rec_cc = 0;
    } else {
        $id_rec_cc = 1;
    }
    //idrecurrentinvoice
} else {
    $is_recurrent = 0;
示例#3
0
</th>
                    <th class="invoice_list_12pct center_text"><?php 
echo _('Total Paid');
?>
</th>
                    <th class="invoice_list_12pct center_text"><?php 
echo _('Total Due');
?>
</th>
                    <th class="invoice_list_12pct center_text"><?php 
echo _('Status');
?>
</th>
                </tr>
                <?php 
$do_rec_inv = new RecurrentInvoice();
//echo $_SESSION['do_invoice_list']->getSqlQuery();
if (!$_SESSION['do_invoice_list']->filter_set) {
    $_SESSION['do_invoice_list']->getAllInvoice();
} else {
    $_SESSION['do_invoice_list']->query($_SESSION['do_invoice_list']->getSqlQuery());
}
if ($_SESSION['do_invoice_list']->getNumRows() > 0) {
    $do_contact = new Contact();
    while ($_SESSION['do_invoice_list']->next()) {
        $currentpage = $_SERVER['PHP_SELF'];
        $e_detail = new Event("mydb.gotoPage");
        $e_detail->addParam("goto", "invoice.php");
        $e_detail->addParam("idinvoice", $_SESSION['do_invoice_list']->idinvoice);
        $e_detail->addParam("tablename", "invoice");
        $e_detail->requestSave("eDetail_invoice", $currentpage);
示例#4
0
if ($_SESSION['do_invoice']->isInvoiceOwner($_SESSION['InvoiceEditSave']->idinvoice, $_SESSION['do_User']->iduser)) {
    $invoice_access = true;
}
$user_settings = $_SESSION['do_User']->getChildUserSettings();
if ($user_settings->getNumRows()) {
    while ($user_settings->next()) {
        if ($user_settings->setting_name == 'currency' && $user_settings->setting_value != '') {
            $currency = explode("-", $user_settings->setting_value);
            $_SESSION['InvoiceEditSave']->currency_iso_code = $currency[0];
            $_SESSION['InvoiceEditSave']->currency_sign = $currency[1];
            $_SESSION['InvoiceEditSave']->setCurrencyDisplay();
            $_SESSION['InvoiceEditSave']->getCurrencyPostion();
        }
    }
}
$RecInv = new RecurrentInvoice();
$RecInv->sessionPersistent("RecurrentInvoice", "index.php", OFUZ_TTL);
?>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
  reCalculateAmount();
});

function fnHighlight(area) {
	var div=$("#cw"+area);
        div.css("background-color", "#ffffdd");
}
function fnNoHighlight(area) {
	var div=$("#cw"+area);
        div.css("background-color", "#ffffff");
示例#5
0
 /**
  * Method to send the email
  * @param $idinvoice -- INT
  * @param $idcontact -- INT
  * @param $iduser -- INT
  * @param $recurrent -- Boolean
  */
 function sendInvoiceByEmail($idinvoice, $idcontact, $iduser, $recurrent = false)
 {
     $do_contact = new Contact();
     $do_user_rel = new UserRelations();
     $this->getId($idinvoice);
     if ($recurrent === true) {
         $this->sessionPersistent("do_invoice", "index.php", OFUZ_TTL);
     }
     $do_contact->getId($idcontact);
     $contact_name = $do_contact->firstname . ' ' . $do_contact->lastname;
     $do_contact_email = $do_contact->getChildContactEmail();
     $contact_email = $do_contact_email->getDefaultEmail();
     $do_user_detail = new User();
     $do_user_detail->getId($iduser);
     if ($contact_email) {
         $total_due = $this->amt_due;
         $total_due = $this->viewAmount($total_due);
         if ($recurrent) {
             $do_rec_invoice = new RecurrentInvoice();
             $idrec = $do_rec_invoice->checkIfInvoiceIsInRecurrent($idinvoice);
             if ($idrec) {
                 $email_template = new EmailTemplate("ofuz_send_recurrent_invoice");
                 $do_rec_invoice->getId($idrec);
                 $next_due_date = $do_rec_invoice->nextdate;
                 $recurrence = $do_rec_invoice->recurrence;
                 $recurrence_type = $do_rec_invoice->recurrence_type;
             } else {
                 $email_template = new EmailTemplate("ofuz_send_invoice");
             }
         } else {
             $email_template = new EmailTemplate("ofuz_send_invoice");
         }
         if ($this->status == 'Quote') {
             $email_template = new EmailTemplate("ofuz_send_quote");
         }
         $email_template->setSenderName($do_user_detail->getFullName());
         $email_template->setSenderEmail($do_user_detail->email);
         $signature = $do_user_detail->company . '<br />' . $do_user_detail->getFullName();
         $description = $this->description;
         $invoice_url = $GLOBALS['cfg_ofuz_site_https_base'] . 'inv/' . $do_user_rel->encrypt($idinvoice) . '/' . $do_user_rel->encrypt($idcontact);
         $email_data = array('name' => $contact_name, 'sender' => $do_user_detail->getFullName(), 'company' => $do_user_detail->company, 'description' => $description, 'invoice_url' => $invoice_url, 'num' => $this->num, 'signature' => $signature, 'amount' => $total_due, 'recurrence' => $recurrence, 'recurrence_type' => $recurrence_type, 'next_due_date' => $next_due_date);
         $emailer = new Radria_Emailer();
         $emailer->setEmailTemplate($email_template);
         $emailer->mergeArray($email_data);
         $emailer->addTo($contact_email);
         //attachment starts
         // Some bug in the PDF part it does not send the correct PDF as it says due amt is 0. Happens for the cron to send recurrent inv
         //echo '<br />Calling Method generatePDFInvoice().....<br />';
         // This is fixed
         $this->generatePDFInvoice($invoice_url);
         $fpdf_file_name = $this->getEncryptedFileName("pdf");
         $pdfFilePath = "invoice_pdf/{$fpdf_file_name}";
         $pdfFile = file_get_contents($pdfFilePath);
         $at = $emailer->createAttachment($pdfFile);
         $at->type = 'image/pdf';
         $at->disposition = Zend_Mime::DISPOSITION_INLINE;
         $at->encoding = Zend_Mime::ENCODING_BASE64;
         $at->filename = $fpdf_file_name;
         //attachment ends
         $emailer->send();
         if ($this->status == 'New') {
             $this->status = 'Sent';
             $this->update();
         }
         if ($recurrent) {
             $q = new sqlQuery($this->getDbCon());
             $q->query("update invoice set status = 'Sent' where idinvoice = " . $idinvoice . " Limit 1");
             $q->free();
         }
         $_SESSION['in_page_message'] = "client_invoice_sent";
         $_SESSION['in_page_message_data']['contact_email'] = $contact_email;
     } else {
         $_SESSION['in_page_message'] = "invoice_client_email_not_found";
     }
     $do_user_detail->free();
 }
 private function XMLExport($iduser)
 {
     $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n";
     $do_user = new User();
     $do_user->getId($iduser);
     $xml .= "<user>\n";
     $xml .= " <iduser><![CDATA[" . $do_user->iduser . "]]></iduser>\n";
     $xml .= " <firstname><![CDATA[" . $do_user->firstname . "]]></firstname>\n";
     $xml .= " <middlename><![CDATA[" . $do_user->middlename . "]]></middlename>\n";
     $xml .= " <lastname><![CDATA[" . $do_user->lastname . "]]></lastname>\n";
     $xml .= " <email><![CDATA[" . $do_user->email . "]]></email>\n";
     $xml .= " <phone><![CDATA[" . $do_user->phone . "]]></phone>\n";
     $xml .= " <company><![CDATA[" . $do_user->company . "]]></company>\n";
     $xml .= " <position><![CDATA[" . $do_user->position . "]]></position>\n";
     $xml .= " <address1><![CDATA[" . $do_user->address1 . "]]></address1>\n";
     $xml .= " <address2><![CDATA[" . $do_user->address2 . "]]></address2>\n";
     $xml .= " <city><![CDATA[" . $do_user->city . "]]></city>\n";
     $xml .= " <zip><![CDATA[" . $do_user->zip . "]]></zip>\n";
     $xml .= " <state><![CDATA[" . $do_user->state . "]]></state>\n";
     $xml .= " <country><![CDATA[" . $do_user->country . "]]></country>\n";
     $xml .= " <username><![CDATA[" . $do_user->username . "]]></username>\n";
     $xml .= " <password><![CDATA[" . $do_user->password . "]]></password>\n";
     $xml .= " <isadmin><![CDATA[" . $do_user->isadmin . "]]></isadmin>\n";
     $xml .= " <regdate><![CDATA[" . $do_user->regdate . "]]></regdate>\n";
     $xml .= " <openid><![CDATA[" . $do_user->openid . "]]></openid>\n";
     $xml .= " <last_login><![CDATA[" . $do_user->last_login . "]]></last_login>\n";
     $xml .= " <drop_box_code><![CDATA[" . $do_user->drop_box_code . "]]></drop_box_code>\n";
     $xml .= " <idcontact><![CDATA[" . $do_user->idcontact . "]]></idcontact>\n";
     $xml .= " <fb_user_id><![CDATA[" . $do_user->fb_user_id . "]]></fb_user_id>\n";
     $xml .= " <api_key><![CDATA[" . $do_user->api_key . "]]></api_key>\n";
     $xml .= " <plan><![CDATA[" . $do_user->plan . "]]></plan>\n";
     $xml .= " <status><![CDATA[" . $do_user->status . "]]></status>\n";
     $xml .= " <google_openid_identity><![CDATA[" . $do_user->google_openid_identity . "]]></google_openid_identity>\n";
     $xml .= "</user>\n";
     if (!$this->appendToFile($xml)) {
         return false;
     }
     $xml = ' ';
     $i = 1;
     $do_contact = new Contact();
     $do_contact->getUserContacts($iduser);
     $xml .= "<contacts>\n";
     while ($do_contact->next()) {
         set_time_limit(3600);
         //1 hr
         $xml .= " <contact>\n";
         $xml .= "  <idcontact><![CDATA[" . $do_contact->getData("idcontact") . "]]></idcontact>\n";
         $xml .= "  <firstname><![CDATA[" . $do_contact->getData("firstname") . "]]></firstname>\n";
         $xml .= "  <lastname><![CDATA[" . $do_contact->getData("lastname") . "]]></lastname>\n";
         $xml .= "  <position><![CDATA[" . $do_contact->getData("position") . "]]></position>\n";
         $xml .= "  <company><![CDATA[" . $do_contact->getData("company") . "]]></company>\n";
         $xml .= "  <idcompany><![CDATA[" . $do_contact->getData("idcompany") . "]]></idcompany>\n";
         $xml .= "  <iduser><![CDATA[" . $do_contact->getData("iduser") . "]]></iduser>\n";
         $xml .= "  <picture><![CDATA[" . $do_contact->getData("picture") . "]]></picture>\n";
         $xml .= "  <summary><![CDATA[" . $do_contact->getData("summary") . "]]></summary>\n";
         $xml .= "  <birthday><![CDATA[" . $do_contact->getData("birthday") . "]]></birthday>\n";
         $xml .= "  <portal_code><![CDATA[" . $do_contact->getData("portal_code") . "]]></portal_code>\n";
         $xml .= "  <fb_userid><![CDATA[" . $do_contact->getData("fb_userid") . "]]></fb_userid>\n";
         $xml .= "  <tw_user_id><![CDATA[" . $do_contact->getData("tw_user_id") . "]]></tw_user_id>\n";
         $xml .= "  <email_optout><![CDATA[" . $do_contact->getData("email_optout") . "]]></email_optout>\n\n";
         $contact_address = $do_contact->getChildContactAddress();
         while ($contact_address->next()) {
             $xml .= "  <contact_address>\n";
             $xml .= "   <idcontact_address><![CDATA[" . $contact_address->idcontact_address . "]]></idcontact_address>\n";
             $xml .= "   <city><![CDATA[" . $contact_address->city . "]]></city>\n";
             $xml .= "   <country><![CDATA[" . $contact_address->country . "]]></country>\n";
             $xml .= "   <state><![CDATA[" . $contact_address->state . "]]></state>\n";
             $xml .= "   <street><![CDATA[" . $contact_address->street . "]]></street>\n";
             $xml .= "   <zipcode><![CDATA[" . $contact_address->zipcode . "]]></zipcode>\n";
             $xml .= "   <idcontact><![CDATA[" . $contact_address->idcontact . "]]></idcontact>\n";
             $xml .= "   <address><![CDATA[" . $contact_address->address . "]]></address>\n";
             $xml .= "   <address_type><![CDATA[" . $contact_address->address_type . "]]></address_type>\n";
             $xml .= "  </contact_address>\n";
         }
         $contact_email = $do_contact->getChildContactEmail();
         while ($contact_email->next()) {
             $xml .= "  <contact_email>\n";
             $xml .= "   <idcontact_email><![CDATA[" . $contact_email->idcontact_email . "]]></idcontact_email>\n";
             $xml .= "   <idcontact><![CDATA[" . $contact_email->idcontact . "]]></idcontact>\n";
             $xml .= "   <email_address><![CDATA[" . $contact_email->email_address . "]]></email_address>\n";
             $xml .= "   <email_type><![CDATA[" . $contact_email->email_type . "]]></email_type>\n";
             $xml .= "   <email_isdefault><![CDATA[" . $contact_email->email_isdefault . "]]></email_isdefault>\n";
             $xml .= "  </contact_email>\n";
         }
         $contact_phone = $do_contact->getChildContactPhone();
         while ($contact_phone->next()) {
             $xml .= "  <contact_phone>\n";
             $xml .= "   <idcontact_phone><![CDATA[" . $contact_phone->idcontact_phone . "]]></idcontact_phone>\n";
             $xml .= "   <phone_number><![CDATA[" . $contact_phone->phone_number . "]]></phone_number>\n";
             $xml .= "   <phone_type><![CDATA[" . $contact_phone->phone_type . "]]></phone_type>\n";
             $xml .= "   <idcontact><![CDATA[" . $contact_phone->email_type . "]]></idcontact>\n";
             $xml .= "  </contact_phone>\n";
         }
         $contact_note = $do_contact->getChildContactNotes();
         while ($contact_note->next()) {
             $xml .= "  <contact_note>\n";
             $xml .= "   <idcontact_note><![CDATA[" . $contact_note->idcontact_note . "]]></idcontact_note>\n";
             $xml .= "   <idcontact><![CDATA[" . $contact_note->idcontact . "]]></idcontact>\n";
             $xml .= "   <note><![CDATA[" . $contact_note->note . "]]></note>\n";
             $xml .= "   <date_added><![CDATA[" . $contact_note->date_added . "]]></date_added>\n";
             $xml .= "   <document><![CDATA[" . $contact_note->document . "]]></document>\n";
             $xml .= "   <idcompany><![CDATA[" . $contact_note->idcompany . "]]></idcompany>\n";
             $xml .= "   <iduser><![CDATA[" . $contact_note->iduser . "]]></iduser>\n";
             $xml .= "   <priority><![CDATA[" . $contact_note->priority . "]]></priority>\n";
             $xml .= "   <send_email><![CDATA[" . $contact_note->send_email . "]]></send_email>\n";
             $xml .= "   <hours_work><![CDATA[" . $contact_note->hours_work . "]]></hours_work>\n";
             $xml .= "   <note_visibility><![CDATA[" . $contact_note->note_visibility . "]]></note_visibility>\n";
             $xml .= "  </contact_note>\n";
         }
         if (!$this->appendToFile($xml)) {
             return false;
         }
         $xml = ' ';
         if ($i == '1') {
             $do_task = new Task();
             $do_task->getTaskWithoutProject();
             while ($do_task->next()) {
                 $xml .= "  <contact_task>\n";
                 $xml .= "   <idtask><![CDATA[" . $do_task->getData("idtask") . "]]></idtask>\n";
                 $xml .= "   <task_description><![CDATA[" . $do_task->getData("task_description") . "]]></task_description>\n";
                 $xml .= "   <due_date><![CDATA[" . $do_task->getData("due_date") . "]]></due_date>\n";
                 $xml .= "   <category><![CDATA[" . $do_task->getData("category") . "]]></category>\n";
                 $xml .= "   <iduser><![CDATA[" . $do_task->getData("iduser") . "]]></iduser>\n";
                 $xml .= "   <due_date_dateformat><![CDATA[" . $do_task->getData("due_date_dateformat") . "]]></due_date_dateformat>\n";
                 $xml .= "   <status><![CDATA[" . $do_task->getData("status") . "]]></status>\n";
                 $xml .= "   <date_completed><![CDATA[" . $do_task->getData("date_completed") . "]]></date_completed>\n";
                 $xml .= "   <idcontact><![CDATA[" . $do_task->getData("idcontact") . "]]></idcontact>\n";
                 $xml .= "   <from_note><![CDATA[" . $do_task->getData("from_note") . "]]></from_note>\n";
                 $xml .= "   <is_sp_date_set><![CDATA[" . $do_task->getData("is_sp_date_set") . "]]></is_sp_date_set>\n";
                 $xml .= "   <task_category><![CDATA[" . $do_task->getData("task_category") . "]]></task_category>\n";
                 $xml .= "  </contact_task>\n";
                 if (!$this->appendToFile($xml)) {
                     return false;
                 }
                 $xml = ' ';
             }
             $do_task->free();
         }
         $do_task = new Task();
         $do_task->getContactTaskWithoutProject($do_contact->getData("idcontact"));
         while ($do_task->next()) {
             $xml .= "  <contact_task>\n";
             $xml .= "   <idtask><![CDATA[" . $do_task->getData("idtask") . "]]></idtask>\n";
             $xml .= "   <task_description><![CDATA[" . $do_task->getData("task_description") . "]]></task_description>\n";
             $xml .= "   <due_date><![CDATA[" . $do_task->getData("due_date") . "]]></due_date>\n";
             $xml .= "   <category><![CDATA[" . $do_task->getData("category") . "]]></category>\n";
             $xml .= "   <iduser><![CDATA[" . $do_task->getData("iduser") . "]]></iduser>\n";
             $xml .= "   <due_date_dateformat><![CDATA[" . $do_task->getData("due_date_dateformat") . "]]></due_date_dateformat>\n";
             $xml .= "   <status><![CDATA[" . $do_task->getData("status") . "]]></status>\n";
             $xml .= "   <date_completed><![CDATA[" . $do_task->getData("date_completed") . "]]></date_completed>\n";
             $xml .= "   <idcontact><![CDATA[" . $do_task->getData("idcontact") . "]]></idcontact>\n";
             $xml .= "   <from_note><![CDATA[" . $do_task->getData("from_note") . "]]></from_note>\n";
             $xml .= "   <is_sp_date_set><![CDATA[" . $do_task->getData("is_sp_date_set") . "]]></is_sp_date_set>\n";
             $xml .= "   <task_category><![CDATA[" . $do_task->getData("task_category") . "]]></task_category>\n";
             $xml .= "  </contact_task>\n";
         }
         $do_task->free();
         if (!$this->appendToFile($xml)) {
             return false;
         }
         $xml = ' ';
         /**
          * For all the contact tasks which are associated with Project.
          */
         $do_task = new Task();
         //$do_task->getContactTasksAssociatedWithProject($do_contact->getData("idcontact"));
         $do_task->getContactTasksAssociatedWithProject($do_contact->getData("idcontact"));
         while ($do_task->next()) {
             $do_project = new Project();
             $do_project->getId($do_task->idproject);
             $xml .= "  <contact_task_with_project>\n";
             $xml .= "   <idproject><![CDATA[" . $do_project->idproject . "]]></idproject>\n";
             $xml .= "   <iduser><![CDATA[" . $do_project->iduser . "]]></iduser>\n";
             $xml .= "   <name><![CDATA[" . $do_project->name . "]]></name>\n";
             $xml .= "   <end_date_dateformat><![CDATA[" . $do_project->end_date_dateformat . "]]></end_date_dateformat>\n";
             $xml .= "   <idcompany><![CDATA[" . $do_project->idcompany . "]]></idcompany>\n";
             $xml .= "   <status><![CDATA[" . $do_project->status . "]]></status>\n";
             $xml .= "   <effort_estimated_hrs><![CDATA[" . $do_project->effort_estimated_hrs . "]]></effort_estimated_hrs>\n";
             $xml .= "   <is_public><![CDATA[" . $do_project->is_public . "]]></is_public>\n\n";
             $xml .= "   <project_task>\n";
             $xml .= "    <idproject_task><![CDATA[" . $do_task->getData("idproject_task") . "]]></idproject_task>\n";
             $xml .= "    <idtask><![CDATA[" . $do_task->getData("idtask") . "]]></idtask>\n";
             $xml .= "    <idproject><![CDATA[" . $do_task->getData("idproject") . "]]></idproject>\n";
             $xml .= "    <progress><![CDATA[" . $do_task->getData("progress") . "]]></progress>\n";
             $xml .= "    <drop_box_code><![CDATA[" . $do_task->getData("drop_box_code") . "]]></drop_box_code>\n";
             $xml .= "    <priority><![CDATA[" . $do_task->getData("priority") . "]]></priority>\n";
             $xml .= "    <hrs_work_expected><![CDATA[" . $do_task->getData("hrs_work_expected") . "]]></hrs_work_expected>\n";
             $xml .= "    <task_description><![CDATA[" . $do_task->getData("task_description") . "]]></task_description>\n";
             $xml .= "    <due_date><![CDATA[" . $do_task->getData("due_date") . "]]></due_date>\n";
             $xml .= "    <category><![CDATA[" . $do_task->getData("category") . "]]></category>\n";
             $xml .= "    <iduser><![CDATA[" . $do_task->getData("iduser") . "]]></iduser>\n";
             $xml .= "    <due_date_dateformat><![CDATA[" . $do_task->getData("due_date_dateformat") . "]]></due_date_dateformat>\n";
             $xml .= "    <status><![CDATA[" . $do_task->getData("status") . "]]></status>\n";
             $xml .= "    <date_completed><![CDATA[" . $do_task->getData("date_completed") . "]]></date_completed>\n";
             $xml .= "    <idcontact><![CDATA[" . $do_task->getData("idcontact") . "]]></idcontact>\n";
             $xml .= "    <from_note><![CDATA[" . $do_task->getData("from_note") . "]]></from_note>\n";
             $xml .= "    <is_sp_date_set><![CDATA[" . $do_task->getData("is_sp_date_set") . "]]></is_sp_date_set>\n";
             $xml .= "    <task_category><![CDATA[" . $do_task->getData("task_category") . "]]></task_category>\n\n";
             if (!$this->appendToFile($xml)) {
                 return false;
             }
             $xml = ' ';
             $do_prj_discuss = new ProjectDiscuss();
             $do_prj_discuss->getProjectTaskDiscussions($do_task->getData("idproject_task"));
             while ($do_prj_discuss->next()) {
                 $xml .= "    <project_discuss>\n";
                 $xml .= "     <idproject_discuss><![CDATA[" . $do_prj_discuss->getData("idproject_discuss") . "]]></idproject_discuss>\n";
                 $xml .= "     <idproject_task><![CDATA[" . $do_prj_discuss->getData("idproject_task") . "]]></idproject_task>\n";
                 $xml .= "     <idtask><![CDATA[" . $do_prj_discuss->getData("idtask") . "]]></idtask>\n";
                 $xml .= "     <idproject><![CDATA[" . $do_prj_discuss->getData("idproject") . "]]></idproject>\n";
                 $xml .= "     <discuss><![CDATA[" . $do_prj_discuss->getData("discuss") . "]]></discuss>\n";
                 $xml .= "     <date_added><![CDATA[" . $do_prj_discuss->getData("date_added") . "]]></date_added>\n";
                 $xml .= "     <document><![CDATA[" . $do_prj_discuss->getData("document") . "]]></document>\n";
                 $xml .= "     <iduser><![CDATA[" . $do_prj_discuss->getData("iduser") . "]]></iduser>\n";
                 $xml .= "     <drop_box_sender><![CDATA[" . $do_prj_discuss->getData("drop_box_sender") . "]]></drop_box_sender>\n";
                 $xml .= "     <priority><![CDATA[" . $do_prj_discuss->getData("priority") . "]]></priority>\n";
                 $xml .= "     <hours_work><![CDATA[" . $do_prj_discuss->getData("hours_work") . "]]></hours_work>\n";
                 $xml .= "     <discuss_edit_access><![CDATA[" . $do_prj_discuss->getData("discuss_edit_access") . "]]></discuss_edit_access>\n";
                 $xml .= "    </project_discuss>\n";
                 if (!$this->appendToFile($xml)) {
                     return false;
                 }
                 $xml = ' ';
             }
             $do_prj_discuss->free();
             $xml .= "   </project_task>\n";
             $xml .= "  </contact_task_with_project>\n";
             $do_project->free();
         }
         $do_task->free();
         if (!$this->appendToFile($xml)) {
             return false;
         }
         $xml = '';
         if ($i == '1') {
             $do_task = new Task();
             $do_task->getTasksWithProject();
             while ($do_task->next()) {
                 $do_project = new Project();
                 $do_project->getId($do_task->idproject);
                 $xml .= "  <contact_task_with_project>\n";
                 $xml .= "   <idproject><![CDATA[" . $do_project->idproject . "]]></idproject>\n";
                 $xml .= "   <iduser><![CDATA[" . $do_project->iduser . "]]></iduser>\n";
                 $xml .= "   <name><![CDATA[" . $do_project->name . "]]></name>\n";
                 $xml .= "   <end_date_dateformat><![CDATA[" . $do_project->end_date_dateformat . "]]></end_date_dateformat>\n";
                 $xml .= "   <idcompany><![CDATA[" . $do_project->idcompany . "]]></idcompany>\n";
                 $xml .= "   <status><![CDATA[" . $do_project->status . "]]></status>\n";
                 $xml .= "   <effort_estimated_hrs><![CDATA[" . $do_project->effort_estimated_hrs . "]]></effort_estimated_hrs>\n";
                 $xml .= "   <is_public><![CDATA[" . $do_project->is_public . "]]></is_public>\n\n";
                 $xml .= "   <project_task>\n";
                 $xml .= "    <idproject_task><![CDATA[" . $do_task->getData("idproject_task") . "]]></idproject_task>\n";
                 $xml .= "    <idtask><![CDATA[" . $do_task->getData("idtask") . "]]></idtask>\n";
                 $xml .= "    <idproject><![CDATA[" . $do_task->getData("idproject") . "]]></idproject>\n";
                 $xml .= "    <progress><![CDATA[" . $do_task->getData("progress") . "]]></progress>\n";
                 $xml .= "    <drop_box_code><![CDATA[" . $do_task->getData("drop_box_code") . "]]></drop_box_code>\n";
                 $xml .= "    <priority><![CDATA[" . $do_task->getData("priority") . "]]></priority>\n";
                 $xml .= "    <hrs_work_expected><![CDATA[" . $do_task->getData("hrs_work_expected") . "]]></hrs_work_expected>\n";
                 $xml .= "    <task_description><![CDATA[" . $do_task->getData("task_description") . "]]></task_description>\n";
                 $xml .= "    <due_date><![CDATA[" . $do_task->getData("due_date") . "]]></due_date>\n";
                 $xml .= "    <category><![CDATA[" . $do_task->getData("category") . "]]></category>\n";
                 $xml .= "    <iduser><![CDATA[" . $do_task->getData("iduser") . "]]></iduser>\n";
                 $xml .= "    <due_date_dateformat><![CDATA[" . $do_task->getData("due_date_dateformat") . "]]></due_date_dateformat>\n";
                 $xml .= "    <status><![CDATA[" . $do_task->getData("status") . "]]></status>\n";
                 $xml .= "    <date_completed><![CDATA[" . $do_task->getData("date_completed") . "]]></date_completed>\n";
                 $xml .= "    <idcontact><![CDATA[" . $do_task->getData("idcontact") . "]]></idcontact>\n";
                 $xml .= "    <from_note><![CDATA[" . $do_task->getData("from_note") . "]]></from_note>\n";
                 $xml .= "    <is_sp_date_set><![CDATA[" . $do_task->getData("is_sp_date_set") . "]]></is_sp_date_set>\n";
                 $xml .= "    <task_category><![CDATA[" . $do_task->getData("task_category") . "]]></task_category>\n\n";
                 if (!$this->appendToFile($xml)) {
                     return false;
                 }
                 $xml = ' ';
                 $do_prj_discuss = new ProjectDiscuss();
                 $do_prj_discuss->getProjectTaskDiscussions($do_task->getData("idproject_task"));
                 while ($do_prj_discuss->next()) {
                     $xml .= "    <project_discuss>\n";
                     $xml .= "     <idproject_discuss><![CDATA[" . $do_prj_discuss->getData("idproject_discuss") . "]]></idproject_discuss>\n";
                     $xml .= "     <idproject_task><![CDATA[" . $do_prj_discuss->getData("idproject_task") . "]]></idproject_task>\n";
                     $xml .= "     <idtask><![CDATA[" . $do_prj_discuss->getData("idtask") . "]]></idtask>\n";
                     $xml .= "     <idproject><![CDATA[" . $do_prj_discuss->getData("idproject") . "]]></idproject>\n";
                     $xml .= "     <discuss><![CDATA[" . $do_prj_discuss->getData("discuss") . "]]></discuss>\n";
                     $xml .= "     <date_added><![CDATA[" . $do_prj_discuss->getData("date_added") . "]]></date_added>\n";
                     $xml .= "     <document><![CDATA[" . $do_prj_discuss->getData("document") . "]]></document>\n";
                     $xml .= "     <iduser><![CDATA[" . $do_prj_discuss->getData("iduser") . "]]></iduser>\n";
                     $xml .= "     <drop_box_sender><![CDATA[" . $do_prj_discuss->getData("drop_box_sender") . "]]></drop_box_sender>\n";
                     $xml .= "     <priority><![CDATA[" . $do_prj_discuss->getData("priority") . "]]></priority>\n";
                     $xml .= "     <hours_work><![CDATA[" . $do_prj_discuss->getData("hours_work") . "]]></hours_work>\n";
                     $xml .= "     <discuss_edit_access><![CDATA[" . $do_prj_discuss->getData("discuss_edit_access") . "]]></discuss_edit_access>\n";
                     $xml .= "    </project_discuss>\n";
                     if (!$this->appendToFile($xml)) {
                         return false;
                     }
                     $xml = ' ';
                 }
                 $do_prj_discuss->free();
                 $xml .= "   </project_task>\n";
                 $xml .= "  </contact_task_with_project>\n";
                 $do_project->free();
             }
             $do_task->free();
         }
         if (!$this->appendToFile($xml)) {
             return false;
         }
         $xml = ' ';
         $do_invoice = new Invoice();
         $do_invoice->getContactInvoiceDetailsWithUser($do_contact->getData("idcontact"), $do_user->iduser);
         while ($do_invoice->next()) {
             $xml .= "  <invoice>\n";
             $xml .= "   <idinvoice><![CDATA[" . $do_invoice->getData("idinvoice") . "]]></idinvoice>\n";
             $xml .= "   <num><![CDATA[" . $do_invoice->getData("num") . "]]></num>\n";
             $xml .= "   <iduser><![CDATA[" . $do_invoice->getData("iduser") . "]]></iduser>\n";
             $xml .= "   <description><![CDATA[" . $do_invoice->getData("description") . "]]></description>\n";
             $xml .= "   <amount><![CDATA[" . $do_invoice->getData("amount") . "]]></amount>\n";
             $xml .= "   <datepaid><![CDATA[" . $do_invoice->getData("datepaid") . "]]></datepaid>\n";
             $xml .= "   <datecreated><![CDATA[" . $do_invoice->getData("datecreated") . "]]></datecreated>\n";
             $xml .= "   <status><![CDATA[" . $do_invoice->getData("status") . "]]></status>\n";
             $xml .= "   <discount><![CDATA[" . $do_invoice->getData("discount") . "]]></discount>\n";
             $xml .= "   <idcontact><![CDATA[" . $do_invoice->getData("idcontact") . "]]></idcontact>\n";
             $xml .= "   <due_date><![CDATA[" . $do_invoice->getData("due_date") . "]]></due_date>\n";
             $xml .= "   <invoice_address><![CDATA[" . $do_invoice->getData("invoice_address") . "]]></invoice_address>\n";
             $xml .= "   <invoice_term><![CDATA[" . $do_invoice->getData("invoice_term") . "]]></invoice_term>\n";
             $xml .= "   <invoice_note><![CDATA[" . $do_invoice->getData("invoice_note") . "]]></invoice_note>\n";
             $xml .= "   <sub_total><![CDATA[" . $do_invoice->getData("sub_total") . "]]></sub_total>\n";
             $xml .= "   <net_total><![CDATA[" . $do_invoice->getData("net_total") . "]]></net_total>\n";
             $xml .= "   <amt_due><![CDATA[" . $do_invoice->getData("amt_due") . "]]></amt_due>\n";
             $xml .= "   <idcompany><![CDATA[" . $do_invoice->getData("idcompany") . "]]></idcompany>\n";
             $xml .= "   <tax><![CDATA[" . $do_invoice->getData("tax") . "]]></tax>\n";
             $xml .= "   <set_delete><![CDATA[" . $do_invoice->getData("set_delete") . "]]></set_delete>\n";
             $xml .= "   <total_discounted_amt><![CDATA[" . $do_invoice->getData("total_discounted_amt") . "]]></total_discounted_amt>\n";
             $xml .= "   <total_taxed_amount><![CDATA[" . $do_invoice->getData("total_taxed_amount") . "]]></total_taxed_amount>\n";
             $invoice_line = $do_invoice->getChildInvoiceLine();
             while ($invoice_line->next()) {
                 $xml .= "   <invoiceline>\n";
                 $xml .= "    <idinvoiceline><![CDATA[" . $invoice_line->idinvoiceline . "]]></idinvoiceline>\n";
                 $xml .= "    <idinvoice><![CDATA[" . $invoice_line->idinvoice . "]]></idinvoice>\n";
                 $xml .= "    <description><![CDATA[" . $invoice_line->description . "]]></description>\n";
                 $xml .= "    <price><![CDATA[" . $invoice_line->price . "]]></price>\n";
                 $xml .= "    <qty><![CDATA[" . $invoice_line->qty . "]]></qty>\n";
                 $xml .= "    <total><![CDATA[" . $invoice_line->total . "]]></total>\n";
                 $xml .= "    <item><![CDATA[" . $invoice_line->item . "]]></item>\n";
                 $xml .= "    <line_tax><![CDATA[" . $invoice_line->line_tax . "]]></line_tax>\n";
                 $xml .= "    <discounted_amount><![CDATA[" . $invoice_line->discounted_amount . "]]></discounted_amount>\n";
                 $xml .= "    <taxed_amount><![CDATA[" . $invoice_line->taxed_amount . "]]></taxed_amount>\n";
                 $xml .= "   </invoiceline>\n";
             }
             $invoice_line->free();
             if (!$this->appendToFile($xml)) {
                 return false;
             }
             $xml = ' ';
             $do_recurrent_invoice = new RecurrentInvoice();
             $do_recurrent_invoice->getRecurrentInvoiceDetail($do_invoice->getData("idinvoice"));
             while ($do_recurrent_invoice->next()) {
                 $xml .= "   <recurrentinvoice>\n";
                 $xml .= "    <idrecurrentinvoice><![CDATA[" . $do_recurrent_invoice->getData("idrecurrentinvoice") . "]]></idrecurrentinvoice>\n";
                 $xml .= "    <iduser><![CDATA[" . $do_recurrent_invoice->getData("iduser") . "]]></iduser>\n";
                 $xml .= "    <idinvoice><![CDATA[" . $do_recurrent_invoice->getData("idinvoice") . "]]></idinvoice>\n";
                 $xml .= "    <nextdate><![CDATA[" . $do_recurrent_invoice->getData("nextdate") . "]]></nextdate>\n";
                 $xml .= "    <recurrence><![CDATA[" . $do_recurrent_invoice->getData("recurrence") . "]]></recurrence>\n";
                 $xml .= "    <recurrencetype><![CDATA[" . $do_recurrent_invoice->getData("recurrencetype") . "]]></recurrencetype>\n";
                 $xml .= "   </recurrentinvoice>\n";
             }
             $do_recurrent_invoice->free();
             $do_paymentlog = new PaymentLog();
             $do_paymentlog->getPaymentLogDetails($do_invoice->getData("idinvoice"));
             while ($do_paymentlog->next()) {
                 $xml .= "   <paymentlog>\n";
                 $xml .= "    <idpaymentlog ><![CDATA[" . $do_paymentlog->getData("idpaymentlog") . "]]></idpaymentlog >\n";
                 $xml .= "    <timestamp><![CDATA[" . $do_paymentlog->getData("timestamp") . "]]></timestamp>\n";
                 $xml .= "    <idinvoice><![CDATA[" . $do_paymentlog->getData("idinvoice") . "]]></idinvoice>\n";
                 $xml .= "    <amount><![CDATA[" . $do_paymentlog->getData("amount") . "]]></amount>\n";
                 $xml .= "    <payment_type><![CDATA[" . $do_paymentlog->getData("payment_type") . "]]></payment_type>\n";
                 $xml .= "    <ref_num><![CDATA[" . $do_paymentlog->getData("ref_num") . "]]></ref_num>\n";
                 $xml .= "    <date_added><![CDATA[" . $do_paymentlog->getData("date_added") . "]]></date_added>\n";
                 $do_payment_invoice = new PaymentInvoice();
                 $do_payment_invoice->getInvDetails($do_paymentlog->getData("idpaymentlog"));
                 while ($do_payment_invoice->next()) {
                     $xml .= "    <payment_invoice>\n";
                     $xml .= "     <idpayment_invoice><![CDATA[" . $do_payment_invoice->getData("idpayment_invoice") . "]]></idpayment_invoice>\n";
                     $xml .= "     <idpayment><![CDATA[" . $do_payment_invoice->getData("idpayment") . "]]></idpayment>\n";
                     $xml .= "     <idinvoice><![CDATA[" . $do_payment_invoice->getData("idinvoice") . "]]></idinvoice>\n";
                     $xml .= "     <amount><![CDATA[" . $do_payment_invoice->getData("amount") . "]]></amount>\n";
                     $xml .= "    </payment_invoice>\n";
                 }
                 $do_payment_invoice->free();
                 $do_paymentlog_extra_amount = new PaymentLog();
                 $do_paymentlog_extra_amount->getPaymentLogExtraAmountDetails($do_paymentlog->getData("idpaymentlog"));
                 while ($do_paymentlog_extra_amount->next()) {
                     $xml .= "    <paymentlog_extra_amount>\n";
                     $xml .= "     <idpaymentlog_extra_amount><![CDATA[" . $do_paymentlog_extra_amount->getData("idpaymentlog_extra_amount") . "]]></idpaymentlog_extra_amount>\n";
                     $xml .= "     <idpaymentlog><![CDATA[" . $do_paymentlog_extra_amount->getData("idpaymentlog") . "]]></idpaymentlog>\n";
                     $xml .= "     <extra_amt><![CDATA[" . $do_paymentlog_extra_amount->getData("extra_amt") . "]]></extra_amt>\n";
                     $xml .= "     <iduser><![CDATA[" . $do_paymentlog_extra_amount->getData("iduser") . "]]></iduser>\n";
                     $xml .= "    </paymentlog_extra_amount>\n";
                 }
                 $do_paymentlog_extra_amount->free();
                 $xml .= "   </paymentlog>\n";
                 if (!$this->appendToFile($xml)) {
                     return false;
                 }
                 $xml = ' ';
             }
             $do_paymentlog->free();
             $xml .= "  </invoice>\n";
         }
         $do_invoice->free();
         $do_tag = new Tag();
         $do_tag->getUserContactTags($iduser, $do_contact->getData("idcontact"));
         while ($do_tag->next()) {
             $xml .= "  <tag>\n";
             $xml .= "   <idtag><![CDATA[" . $do_tag->idtag . "]]></idtag>\n";
             $xml .= "   <tag_name><![CDATA[" . $do_tag->tag_name . "]]></tag_name>\n";
             $xml .= "   <iduser><![CDATA[" . $do_tag->iduser . "]]></iduser>\n";
             $xml .= "   <reference_type><![CDATA[" . $do_tag->reference_type . "]]></reference_type>\n";
             $xml .= "   <idreference><![CDATA[" . $do_tag->idreference . "]]></idreference>\n";
             $xml .= "   <date_added><![CDATA[" . $do_tag->date_added . "]]></date_added>\n";
             $xml .= "  </tag>\n";
             if (!$this->appendToFile($xml)) {
                 return false;
             }
             $xml = ' ';
         }
         $do_tag->free();
         $xml .= " </contact>\n";
         $i++;
     }
     //end line
     $xml .= "</contacts>\n";
     if (!$this->appendToFile($xml)) {
         return false;
     } else {
         return true;
     }
 }
// Copyright 2008 - 2010 all rights reserved, SQLFusion LLC, info@sqlfusion.com
/** Ofuz Open Source version is released under the GNU Affero General Public License, please read the full license at: http://www.gnu.org/licenses/agpl-3.0.html **/
/**
 * Process the Stripe Payment for the recurrent invoices
 * on due date
 * Recurrent Invoices which are paid monthly online are porcessed via this script
 * Will check the user stripe details and will process the invoice payment if its the due date.
 * @see class/RecurrentInvoice.class.php
 * @see class/Stripe.class.php
 */
include_once 'config.php';
include_once 'class/Stripe.class.php';
include_once 'class/stripe-lib/Stripe.php';
set_time_limit(3600);
//echo '<pre>';print_r($_SESSION);echo '</pre>';
$do_recurrent = new RecurrentInvoice();
$do_invoice = new Invoice();
$do_inv_line = new InvoiceLine();
$do_contact = new Contact();
$do_recurrent->getRecInvoiceForStripeProcess();
if ($do_recurrent->getNumRows()) {
    while ($do_recurrent->next()) {
        $do_user_detail = new User();
        $do_invoice = new Invoice();
        $do_invoice->getId($do_recurrent->idinvoice);
        $do_invoice->sessionPersistent("do_invoice", "index.php", OFUZ_TTL);
        $do_user_detail->getId($_SESSION['do_invoice']->iduser);
        $user_settings = $do_user_detail->getChildUserSettings();
        if ($user_settings->getNumRows()) {
            // Get the setting data for the user who has created the invoice
            while ($user_settings->next()) {
示例#8
0
 /**
  * Back up Inactive users data from all the fields and Delete Inactive User's account.
  * This function is used to generate the xml back up file for the user information from the DB
  * This function is differnt from exportUserAccount as we have added more table to the backup
  * And we have function to delete the table once back up is done. And the function exportUserAccount  
  * was not disturbed as this was already in use. 
  * @param int : $iduser
  * @return void
  */
 public function exportUserAccountandDelete($iduser)
 {
     $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n";
     $do_user = new User();
     $do_user->getId($iduser);
     $xml .= "<document>\n";
     $xml .= "<user>\n";
     $xml .= " <iduser><![CDATA[" . $do_user->iduser . "]]></iduser>\n";
     $xml .= " <firstname><![CDATA[" . $do_user->firstname . "]]></firstname>\n";
     $xml .= " <middlename><![CDATA[" . $do_user->middlename . "]]></middlename>\n";
     $xml .= " <lastname><![CDATA[" . $do_user->lastname . "]]></lastname>\n";
     $xml .= " <email><![CDATA[" . $do_user->email . "]]></email>\n";
     $xml .= " <phone><![CDATA[" . $do_user->phone . "]]></phone>\n";
     $xml .= " <company><![CDATA[" . $do_user->company . "]]></company>\n";
     $xml .= " <position><![CDATA[" . $do_user->position . "]]></position>\n";
     $xml .= " <address1><![CDATA[" . $do_user->address1 . "]]></address1>\n";
     $xml .= " <address2><![CDATA[" . $do_user->address2 . "]]></address2>\n";
     $xml .= " <city><![CDATA[" . $do_user->city . "]]></city>\n";
     $xml .= " <zip><![CDATA[" . $do_user->zip . "]]></zip>\n";
     $xml .= " <state><![CDATA[" . $do_user->state . "]]></state>\n";
     $xml .= " <country><![CDATA[" . $do_user->country . "]]></country>\n";
     $xml .= " <username><![CDATA[" . $do_user->username . "]]></username>\n";
     $xml .= " <password><![CDATA[" . $do_user->password . "]]></password>\n";
     $xml .= " <isadmin><![CDATA[" . $do_user->isadmin . "]]></isadmin>\n";
     $xml .= " <regdate><![CDATA[" . $do_user->regdate . "]]></regdate>\n";
     $xml .= " <openid><![CDATA[" . $do_user->openid . "]]></openid>\n";
     $xml .= " <last_login><![CDATA[" . $do_user->last_login . "]]></last_login>\n";
     $xml .= " <drop_box_code><![CDATA[" . $do_user->drop_box_code . "]]></drop_box_code>\n";
     $xml .= " <idcontact><![CDATA[" . $do_user->idcontact . "]]></idcontact>\n";
     $xml .= " <fb_user_id><![CDATA[" . $do_user->fb_user_id . "]]></fb_user_id>\n";
     $xml .= " <api_key><![CDATA[" . $do_user->api_key . "]]></api_key>\n";
     $xml .= " <plan><![CDATA[" . $do_user->plan . "]]></plan>\n";
     $xml .= " <status><![CDATA[" . $do_user->status . "]]></status>\n";
     $xml .= " <google_openid_identity><![CDATA[" . $do_user->google_openid_identity . "]]></google_openid_identity>\n";
     $xml .= "</user>\n";
     $i = 1;
     //$tbl_name = "userid".$iduser."_contact";
     $do_contact = new Contact(NULL, NULL, $iduser);
     $do_contact->getUserContacts($iduser);
     $nums = $do_contact->GetNumRows();
     if ($nums >= 1) {
         $xml .= "<contacts>\n";
         while ($do_contact->next()) {
             $xml .= " <contact>\n";
             $xml .= "  <idcontact><![CDATA[" . $do_contact->getData("idcontact") . "]]></idcontact>\n";
             $xml .= "  <firstname><![CDATA[" . $do_contact->getData("firstname") . "]]></firstname>\n";
             $xml .= "  <lastname><![CDATA[" . $do_contact->getData("lastname") . "]]></lastname>\n";
             $xml .= "  <position><![CDATA[" . $do_contact->getData("position") . "]]></position>\n";
             $xml .= "  <company><![CDATA[" . $do_contact->getData("company") . "]]></company>\n";
             $xml .= "  <idcompany><![CDATA[" . $do_contact->getData("idcompany") . "]]></idcompany>\n";
             $xml .= "  <iduser><![CDATA[" . $do_contact->getData("iduser") . "]]></iduser>\n";
             $xml .= "  <picture><![CDATA[" . $do_contact->getData("picture") . "]]></picture>\n";
             $xml .= "  <summary><![CDATA[" . $do_contact->getData("summary") . "]]></summary>\n";
             $xml .= "  <birthday><![CDATA[" . $do_contact->getData("birthday") . "]]></birthday>\n";
             $xml .= "  <portal_code><![CDATA[" . $do_contact->getData("portal_code") . "]]></portal_code>\n";
             $xml .= "  <fb_userid><![CDATA[" . $do_contact->getData("fb_userid") . "]]></fb_userid>\n";
             $xml .= "  <tw_user_id><![CDATA[" . $do_contact->getData("tw_user_id") . "]]></tw_user_id>\n";
             $xml .= "  <email_optout><![CDATA[" . $do_contact->getData("email_optout") . "]]></email_optout>\n\n";
             $contact_address = $do_contact->getChildContactAddress();
             while ($contact_address->next()) {
                 $xml .= "  <contact_address>\n";
                 $xml .= "   <idcontact_address><![CDATA[" . $contact_address->idcontact_address . "]]></idcontact_address>\n";
                 $xml .= "   <city><![CDATA[" . $contact_address->city . "]]></city>\n";
                 $xml .= "   <country><![CDATA[" . $contact_address->country . "]]></country>\n";
                 $xml .= "   <state><![CDATA[" . $contact_address->state . "]]></state>\n";
                 $xml .= "   <street><![CDATA[" . $contact_address->street . "]]></street>\n";
                 $xml .= "   <zipcode><![CDATA[" . $contact_address->zipcode . "]]></zipcode>\n";
                 $xml .= "   <idcontact><![CDATA[" . $contact_address->idcontact . "]]></idcontact>\n";
                 $xml .= "   <address><![CDATA[" . $contact_address->address . "]]></address>\n";
                 $xml .= "   <address_type><![CDATA[" . $contact_address->address_type . "]]></address_type>\n";
                 $xml .= "  </contact_address>\n";
             }
             $contact_email = $do_contact->getChildContactEmail();
             while ($contact_email->next()) {
                 $xml .= "  <contact_email>\n";
                 $xml .= "   <idcontact_email><![CDATA[" . $contact_email->idcontact_email . "]]></idcontact_email>\n";
                 $xml .= "   <idcontact><![CDATA[" . $contact_email->idcontact . "]]></idcontact>\n";
                 $xml .= "   <email_address><![CDATA[" . $contact_email->email_address . "]]></email_address>\n";
                 $xml .= "   <email_type><![CDATA[" . $contact_email->email_type . "]]></email_type>\n";
                 $xml .= "   <email_isdefault><![CDATA[" . $contact_email->email_isdefault . "]]></email_isdefault>\n";
                 $xml .= "  </contact_email>\n";
             }
             $contact_phone = $do_contact->getChildContactPhone();
             while ($contact_phone->next()) {
                 $xml .= "  <contact_phone>\n";
                 $xml .= "   <idcontact_phone><![CDATA[" . $contact_phone->idcontact_phone . "]]></idcontact_phone>\n";
                 $xml .= "   <phone_number><![CDATA[" . $contact_phone->phone_number . "]]></phone_number>\n";
                 $xml .= "   <phone_type><![CDATA[" . $contact_phone->phone_type . "]]></phone_type>\n";
                 $xml .= "   <idcontact><![CDATA[" . $contact_phone->email_type . "]]></idcontact>\n";
                 $xml .= "  </contact_phone>\n";
             }
             $contact_note = $do_contact->getChildContactNotes();
             while ($contact_note->next()) {
                 $xml .= "  <contact_note>\n";
                 $xml .= "   <idcontact_note><![CDATA[" . $contact_note->idcontact_note . "]]></idcontact_note>\n";
                 $xml .= "   <idcontact><![CDATA[" . $contact_note->idcontact . "]]></idcontact>\n";
                 $xml .= "   <note><![CDATA[" . $contact_note->note . "]]></note>\n";
                 $xml .= "   <date_added><![CDATA[" . $contact_note->date_added . "]]></date_added>\n";
                 $xml .= "   <document><![CDATA[" . $contact_note->document . "]]></document>\n";
                 $xml .= "   <idcompany><![CDATA[" . $contact_note->idcompany . "]]></idcompany>\n";
                 $xml .= "   <iduser><![CDATA[" . $contact_note->iduser . "]]></iduser>\n";
                 $xml .= "   <priority><![CDATA[" . $contact_note->priority . "]]></priority>\n";
                 $xml .= "   <send_email><![CDATA[" . $contact_note->send_email . "]]></send_email>\n";
                 $xml .= "   <hours_work><![CDATA[" . $contact_note->hours_work . "]]></hours_work>\n";
                 $xml .= "   <note_visibility><![CDATA[" . $contact_note->note_visibility . "]]></note_visibility>\n";
                 $xml .= "  </contact_note>\n";
             }
             if ($i == '1') {
                 $do_task = new Task();
                 $do_task->getContactTaskWithoutProjectAndWithUser($iduser);
                 while ($do_task->next()) {
                     $xml .= "  <contact_task>\n";
                     $xml .= "   <idtask><![CDATA[" . $do_task->getData("idtask") . "]]></idtask>\n";
                     $xml .= "   <task_description><![CDATA[" . $do_task->getData("task_description") . "]]></task_description>\n";
                     $xml .= "   <due_date><![CDATA[" . $do_task->getData("due_date") . "]]></due_date>\n";
                     $xml .= "   <category><![CDATA[" . $do_task->getData("category") . "]]></category>\n";
                     $xml .= "   <iduser><![CDATA[" . $do_task->getData("iduser") . "]]></iduser>\n";
                     $xml .= "   <due_date_dateformat><![CDATA[" . $do_task->getData("due_date_dateformat") . "]]></due_date_dateformat>\n";
                     $xml .= "   <status><![CDATA[" . $do_task->getData("status") . "]]></status>\n";
                     $xml .= "   <date_completed><![CDATA[" . $do_task->getData("date_completed") . "]]></date_completed>\n";
                     $xml .= "   <idcontact><![CDATA[" . $do_task->getData("idcontact") . "]]></idcontact>\n";
                     $xml .= "   <from_note><![CDATA[" . $do_task->getData("from_note") . "]]></from_note>\n";
                     $xml .= "   <is_sp_date_set><![CDATA[" . $do_task->getData("is_sp_date_set") . "]]></is_sp_date_set>\n";
                     $xml .= "   <task_category><![CDATA[" . $do_task->getData("task_category") . "]]></task_category>\n";
                     $xml .= "  </contact_task>\n";
                 }
                 $do_task->free();
             }
             $do_task = new Task();
             $do_task->getContactTaskWithoutProjectAndWithContact($do_contact->getData("idcontact"));
             while ($do_task->next()) {
                 $xml .= "  <contact_task>\n";
                 $xml .= "   <idtask><![CDATA[" . $do_task->getData("idtask") . "]]></idtask>\n";
                 $xml .= "   <task_description><![CDATA[" . $do_task->getData("task_description") . "]]></task_description>\n";
                 $xml .= "   <due_date><![CDATA[" . $do_task->getData("due_date") . "]]></due_date>\n";
                 $xml .= "   <category><![CDATA[" . $do_task->getData("category") . "]]></category>\n";
                 $xml .= "   <iduser><![CDATA[" . $do_task->getData("iduser") . "]]></iduser>\n";
                 $xml .= "   <due_date_dateformat><![CDATA[" . $do_task->getData("due_date_dateformat") . "]]></due_date_dateformat>\n";
                 $xml .= "   <status><![CDATA[" . $do_task->getData("status") . "]]></status>\n";
                 $xml .= "   <date_completed><![CDATA[" . $do_task->getData("date_completed") . "]]></date_completed>\n";
                 $xml .= "   <idcontact><![CDATA[" . $do_task->getData("idcontact") . "]]></idcontact>\n";
                 $xml .= "   <from_note><![CDATA[" . $do_task->getData("from_note") . "]]></from_note>\n";
                 $xml .= "   <is_sp_date_set><![CDATA[" . $do_task->getData("is_sp_date_set") . "]]></is_sp_date_set>\n";
                 $xml .= "   <task_category><![CDATA[" . $do_task->getData("task_category") . "]]></task_category>\n";
                 $xml .= "  </contact_task>\n";
             }
             $do_task->free();
             /**
              * For all the contact tasks which are associated with Project.
              */
             $do_task = new Task();
             //$do_task->getContactTasksAssociatedWithProject($do_contact->getData("idcontact"));
             $do_task->getContactTasksAssociatedWithProjectWithContact($do_contact->getData("idcontact"));
             while ($do_task->next()) {
                 $do_project = new Project();
                 $do_project->getId($do_task->idproject);
                 $xml .= "  <contact_task_with_project>\n";
                 $xml .= "   <idproject><![CDATA[" . $do_project->idproject . "]]></idproject>\n";
                 $xml .= "   <iduser><![CDATA[" . $do_project->iduser . "]]></iduser>\n";
                 $xml .= "   <name><![CDATA[" . $do_project->name . "]]></name>\n";
                 $xml .= "   <end_date_dateformat><![CDATA[" . $do_project->end_date_dateformat . "]]></end_date_dateformat>\n";
                 $xml .= "   <idcompany><![CDATA[" . $do_project->idcompany . "]]></idcompany>\n";
                 $xml .= "   <status><![CDATA[" . $do_project->status . "]]></status>\n";
                 $xml .= "   <effort_estimated_hrs><![CDATA[" . $do_project->effort_estimated_hrs . "]]></effort_estimated_hrs>\n";
                 $xml .= "   <is_public><![CDATA[" . $do_project->is_public . "]]></is_public>\n\n";
                 $xml .= "   <project_task>\n";
                 $xml .= "    <idproject_task><![CDATA[" . $do_task->getData("idproject_task") . "]]></idproject_task>\n";
                 $xml .= "    <idtask><![CDATA[" . $do_task->getData("idtask") . "]]></idtask>\n";
                 $xml .= "    <idproject><![CDATA[" . $do_task->getData("idproject") . "]]></idproject>\n";
                 $xml .= "    <progress><![CDATA[" . $do_task->getData("progress") . "]]></progress>\n";
                 $xml .= "    <drop_box_code><![CDATA[" . $do_task->getData("drop_box_code") . "]]></drop_box_code>\n";
                 $xml .= "    <priority><![CDATA[" . $do_task->getData("priority") . "]]></priority>\n";
                 $xml .= "    <hrs_work_expected><![CDATA[" . $do_task->getData("hrs_work_expected") . "]]></hrs_work_expected>\n";
                 $xml .= "    <task_description><![CDATA[" . $do_task->getData("task_description") . "]]></task_description>\n";
                 $xml .= "    <due_date><![CDATA[" . $do_task->getData("due_date") . "]]></due_date>\n";
                 $xml .= "    <category><![CDATA[" . $do_task->getData("category") . "]]></category>\n";
                 $xml .= "    <iduser><![CDATA[" . $do_task->getData("iduser") . "]]></iduser>\n";
                 $xml .= "    <due_date_dateformat><![CDATA[" . $do_task->getData("due_date_dateformat") . "]]></due_date_dateformat>\n";
                 $xml .= "    <status><![CDATA[" . $do_task->getData("status") . "]]></status>\n";
                 $xml .= "    <date_completed><![CDATA[" . $do_task->getData("date_completed") . "]]></date_completed>\n";
                 $xml .= "    <idcontact><![CDATA[" . $do_task->getData("idcontact") . "]]></idcontact>\n";
                 $xml .= "    <from_note><![CDATA[" . $do_task->getData("from_note") . "]]></from_note>\n";
                 $xml .= "    <is_sp_date_set><![CDATA[" . $do_task->getData("is_sp_date_set") . "]]></is_sp_date_set>\n";
                 $xml .= "    <task_category><![CDATA[" . $do_task->getData("task_category") . "]]></task_category>\n\n";
                 $do_prj_discuss = new ProjectDiscuss();
                 $do_prj_discuss->getProjectTaskDiscussions($do_task->getData("idproject_task"));
                 while ($do_prj_discuss->next()) {
                     $xml .= "    <project_discuss>\n";
                     $xml .= "     <idproject_discuss><![CDATA[" . $do_prj_discuss->getData("idproject_discuss") . "]]></idproject_discuss>\n";
                     $xml .= "     <idproject_task><![CDATA[" . $do_prj_discuss->getData("idproject_task") . "]]></idproject_task>\n";
                     $xml .= "     <idtask><![CDATA[" . $do_prj_discuss->getData("idtask") . "]]></idtask>\n";
                     $xml .= "     <idproject><![CDATA[" . $do_prj_discuss->getData("idproject") . "]]></idproject>\n";
                     $xml .= "     <discuss><![CDATA[" . $do_prj_discuss->getData("discuss") . "]]></discuss>\n";
                     $xml .= "     <date_added><![CDATA[" . $do_prj_discuss->getData("date_added") . "]]></date_added>\n";
                     $xml .= "     <document><![CDATA[" . $do_prj_discuss->getData("document") . "]]></document>\n";
                     $xml .= "     <iduser><![CDATA[" . $do_prj_discuss->getData("iduser") . "]]></iduser>\n";
                     $xml .= "     <drop_box_sender><![CDATA[" . $do_prj_discuss->getData("drop_box_sender") . "]]></drop_box_sender>\n";
                     $xml .= "     <priority><![CDATA[" . $do_prj_discuss->getData("priority") . "]]></priority>\n";
                     $xml .= "     <hours_work><![CDATA[" . $do_prj_discuss->getData("hours_work") . "]]></hours_work>\n";
                     $xml .= "     <discuss_edit_access><![CDATA[" . $do_prj_discuss->getData("discuss_edit_access") . "]]></discuss_edit_access>\n";
                     $xml .= "    </project_discuss>\n";
                 }
                 $do_prj_discuss->free();
                 $xml .= "   </project_task>\n";
                 $xml .= "  </contact_task_with_project>\n";
                 $do_project->free();
             }
             $do_task->free();
             if ($i == '1') {
                 $do_task = new Task();
                 $do_task->getContactTasksAssociatedWithProjectWithUser($iduser);
                 while ($do_task->next()) {
                     $do_project = new Project();
                     $do_project->getId($do_task->idproject);
                     $xml .= "  <contact_task_with_project>\n";
                     $xml .= "   <idproject><![CDATA[" . $do_project->idproject . "]]></idproject>\n";
                     $xml .= "   <iduser><![CDATA[" . $do_project->iduser . "]]></iduser>\n";
                     $xml .= "   <name><![CDATA[" . $do_project->name . "]]></name>\n";
                     $xml .= "   <end_date_dateformat><![CDATA[" . $do_project->end_date_dateformat . "]]></end_date_dateformat>\n";
                     $xml .= "   <idcompany><![CDATA[" . $do_project->idcompany . "]]></idcompany>\n";
                     $xml .= "   <status><![CDATA[" . $do_project->status . "]]></status>\n";
                     $xml .= "   <effort_estimated_hrs><![CDATA[" . $do_project->effort_estimated_hrs . "]]></effort_estimated_hrs>\n";
                     $xml .= "   <is_public><![CDATA[" . $do_project->is_public . "]]></is_public>\n\n";
                     $xml .= "   <project_task>\n";
                     $xml .= "    <idproject_task><![CDATA[" . $do_task->getData("idproject_task") . "]]></idproject_task>\n";
                     $xml .= "    <idtask><![CDATA[" . $do_task->getData("idtask") . "]]></idtask>\n";
                     $xml .= "    <idproject><![CDATA[" . $do_task->getData("idproject") . "]]></idproject>\n";
                     $xml .= "    <progress><![CDATA[" . $do_task->getData("progress") . "]]></progress>\n";
                     $xml .= "    <drop_box_code><![CDATA[" . $do_task->getData("drop_box_code") . "]]></drop_box_code>\n";
                     $xml .= "    <priority><![CDATA[" . $do_task->getData("priority") . "]]></priority>\n";
                     $xml .= "    <hrs_work_expected><![CDATA[" . $do_task->getData("hrs_work_expected") . "]]></hrs_work_expected>\n";
                     $xml .= "    <task_description><![CDATA[" . $do_task->getData("task_description") . "]]></task_description>\n";
                     $xml .= "    <due_date><![CDATA[" . $do_task->getData("due_date") . "]]></due_date>\n";
                     $xml .= "    <category><![CDATA[" . $do_task->getData("category") . "]]></category>\n";
                     $xml .= "    <iduser><![CDATA[" . $do_task->getData("iduser") . "]]></iduser>\n";
                     $xml .= "    <due_date_dateformat><![CDATA[" . $do_task->getData("due_date_dateformat") . "]]></due_date_dateformat>\n";
                     $xml .= "    <status><![CDATA[" . $do_task->getData("status") . "]]></status>\n";
                     $xml .= "    <date_completed><![CDATA[" . $do_task->getData("date_completed") . "]]></date_completed>\n";
                     $xml .= "    <idcontact><![CDATA[" . $do_task->getData("idcontact") . "]]></idcontact>\n";
                     $xml .= "    <from_note><![CDATA[" . $do_task->getData("from_note") . "]]></from_note>\n";
                     $xml .= "    <is_sp_date_set><![CDATA[" . $do_task->getData("is_sp_date_set") . "]]></is_sp_date_set>\n";
                     $xml .= "    <task_category><![CDATA[" . $do_task->getData("task_category") . "]]></task_category>\n\n";
                     $do_prj_discuss = new ProjectDiscuss();
                     $do_prj_discuss->getProjectTaskDiscussions($do_task->getData("idproject_task"));
                     while ($do_prj_discuss->next()) {
                         $xml .= "    <project_discuss>\n";
                         $xml .= "     <idproject_discuss><![CDATA[" . $do_prj_discuss->getData("idproject_discuss") . "]]></idproject_discuss>\n";
                         $xml .= "     <idproject_task><![CDATA[" . $do_prj_discuss->getData("idproject_task") . "]]></idproject_task>\n";
                         $xml .= "     <idtask><![CDATA[" . $do_prj_discuss->getData("idtask") . "]]></idtask>\n";
                         $xml .= "     <idproject><![CDATA[" . $do_prj_discuss->getData("idproject") . "]]></idproject>\n";
                         $xml .= "     <discuss><![CDATA[" . $do_prj_discuss->getData("discuss") . "]]></discuss>\n";
                         $xml .= "     <date_added><![CDATA[" . $do_prj_discuss->getData("date_added") . "]]></date_added>\n";
                         $xml .= "     <document><![CDATA[" . $do_prj_discuss->getData("document") . "]]></document>\n";
                         $xml .= "     <iduser><![CDATA[" . $do_prj_discuss->getData("iduser") . "]]></iduser>\n";
                         $xml .= "     <drop_box_sender><![CDATA[" . $do_prj_discuss->getData("drop_box_sender") . "]]></drop_box_sender>\n";
                         $xml .= "     <priority><![CDATA[" . $do_prj_discuss->getData("priority") . "]]></priority>\n";
                         $xml .= "     <hours_work><![CDATA[" . $do_prj_discuss->getData("hours_work") . "]]></hours_work>\n";
                         $xml .= "     <discuss_edit_access><![CDATA[" . $do_prj_discuss->getData("discuss_edit_access") . "]]></discuss_edit_access>\n";
                         $xml .= "    </project_discuss>\n";
                     }
                     $do_prj_discuss->free();
                     $xml .= "   </project_task>\n";
                     $xml .= "  </contact_task_with_project>\n";
                     $do_project->free();
                 }
                 $do_task->free();
             }
             $do_invoice = new Invoice();
             $do_invoice->getContactInvoiceDetailsWithUser($do_contact->getData("idcontact"), $do_user->iduser);
             while ($do_invoice->next()) {
                 $xml .= "  <invoice>\n";
                 $xml .= "   <idinvoice><![CDATA[" . $do_invoice->getData("idinvoice") . "]]></idinvoice>\n";
                 $xml .= "   <num><![CDATA[" . $do_invoice->getData("num") . "]]></num>\n";
                 $xml .= "   <iduser><![CDATA[" . $do_invoice->getData("iduser") . "]]></iduser>\n";
                 $xml .= "   <description><![CDATA[" . $do_invoice->getData("description") . "]]></description>\n";
                 $xml .= "   <amount><![CDATA[" . $do_invoice->getData("amount") . "]]></amount>\n";
                 $xml .= "   <datepaid><![CDATA[" . $do_invoice->getData("datepaid") . "]]></datepaid>\n";
                 $xml .= "   <datecreated><![CDATA[" . $do_invoice->getData("datecreated") . "]]></datecreated>\n";
                 $xml .= "   <status><![CDATA[" . $do_invoice->getData("status") . "]]></status>\n";
                 $xml .= "   <discount><![CDATA[" . $do_invoice->getData("discount") . "]]></discount>\n";
                 $xml .= "   <idcontact><![CDATA[" . $do_invoice->getData("idcontact") . "]]></idcontact>\n";
                 $xml .= "   <due_date><![CDATA[" . $do_invoice->getData("due_date") . "]]></due_date>\n";
                 $xml .= "   <invoice_address><![CDATA[" . $do_invoice->getData("invoice_address") . "]]></invoice_address>\n";
                 $xml .= "   <invoice_term><![CDATA[" . $do_invoice->getData("invoice_term") . "]]></invoice_term>\n";
                 $xml .= "   <invoice_note><![CDATA[" . $do_invoice->getData("invoice_note") . "]]></invoice_note>\n";
                 $xml .= "   <sub_total><![CDATA[" . $do_invoice->getData("sub_total") . "]]></sub_total>\n";
                 $xml .= "   <net_total><![CDATA[" . $do_invoice->getData("net_total") . "]]></net_total>\n";
                 $xml .= "   <amt_due><![CDATA[" . $do_invoice->getData("amt_due") . "]]></amt_due>\n";
                 $xml .= "   <idcompany><![CDATA[" . $do_invoice->getData("idcompany") . "]]></idcompany>\n";
                 $xml .= "   <tax><![CDATA[" . $do_invoice->getData("tax") . "]]></tax>\n";
                 $xml .= "   <set_delete><![CDATA[" . $do_invoice->getData("set_delete") . "]]></set_delete>\n";
                 $xml .= "   <total_discounted_amt><![CDATA[" . $do_invoice->getData("total_discounted_amt") . "]]></total_discounted_amt>\n";
                 $xml .= "   <total_taxed_amount><![CDATA[" . $do_invoice->getData("total_taxed_amount") . "]]></total_taxed_amount>\n";
                 $invoice_line = $do_invoice->getChildInvoiceLine();
                 while ($invoice_line->next()) {
                     $xml .= "   <invoiceline>\n";
                     $xml .= "    <idinvoiceline><![CDATA[" . $invoice_line->idinvoiceline . "]]></idinvoiceline>\n";
                     $xml .= "    <idinvoice><![CDATA[" . $invoice_line->idinvoice . "]]></idinvoice>\n";
                     $xml .= "    <description><![CDATA[" . $invoice_line->description . "]]></description>\n";
                     $xml .= "    <price><![CDATA[" . $invoice_line->price . "]]></price>\n";
                     $xml .= "    <qty><![CDATA[" . $invoice_line->qty . "]]></qty>\n";
                     $xml .= "    <total><![CDATA[" . $invoice_line->total . "]]></total>\n";
                     $xml .= "    <item><![CDATA[" . $invoice_line->item . "]]></item>\n";
                     $xml .= "    <line_tax><![CDATA[" . $invoice_line->line_tax . "]]></line_tax>\n";
                     $xml .= "    <discounted_amount><![CDATA[" . $invoice_line->discounted_amount . "]]></discounted_amount>\n";
                     $xml .= "    <taxed_amount><![CDATA[" . $invoice_line->taxed_amount . "]]></taxed_amount>\n";
                     $xml .= "   </invoiceline>\n";
                 }
                 $invoice_line->free();
                 $do_recurrent_invoice = new RecurrentInvoice();
                 $do_recurrent_invoice->getRecurrentInvoiceDetail($do_invoice->getData("idinvoice"));
                 while ($do_recurrent_invoice->next()) {
                     $xml .= "   <recurrentinvoice>\n";
                     $xml .= "    <idrecurrentinvoice><![CDATA[" . $do_recurrent_invoice->getData("idrecurrentinvoice") . "]]></idrecurrentinvoice>\n";
                     $xml .= "    <iduser><![CDATA[" . $do_recurrent_invoice->getData("iduser") . "]]></iduser>\n";
                     $xml .= "    <idinvoice><![CDATA[" . $do_recurrent_invoice->getData("idinvoice") . "]]></idinvoice>\n";
                     $xml .= "    <nextdate><![CDATA[" . $do_recurrent_invoice->getData("nextdate") . "]]></nextdate>\n";
                     $xml .= "    <recurrence><![CDATA[" . $do_recurrent_invoice->getData("recurrence") . "]]></recurrence>\n";
                     $xml .= "    <recurrencetype><![CDATA[" . $do_recurrent_invoice->getData("recurrencetype") . "]]></recurrencetype>\n";
                     $xml .= "   </recurrentinvoice>\n";
                 }
                 $do_recurrent_invoice->free();
                 $do_paymentlog = new PaymentLog();
                 $do_paymentlog->getPaymentLogDetails($do_invoice->getData("idinvoice"));
                 while ($do_paymentlog->next()) {
                     $xml .= "   <paymentlog>\n";
                     $xml .= "    <idpaymentlog ><![CDATA[" . $do_paymentlog->getData("idpaymentlog") . "]]></idpaymentlog >\n";
                     $xml .= "    <timestamp><![CDATA[" . $do_paymentlog->getData("timestamp") . "]]></timestamp>\n";
                     $xml .= "    <idinvoice><![CDATA[" . $do_paymentlog->getData("idinvoice") . "]]></idinvoice>\n";
                     $xml .= "    <amount><![CDATA[" . $do_paymentlog->getData("amount") . "]]></amount>\n";
                     $xml .= "    <payment_type><![CDATA[" . $do_paymentlog->getData("payment_type") . "]]></payment_type>\n";
                     $xml .= "    <ref_num><![CDATA[" . $do_paymentlog->getData("ref_num") . "]]></ref_num>\n";
                     $xml .= "    <date_added><![CDATA[" . $do_paymentlog->getData("date_added") . "]]></date_added>\n";
                     $do_payment_invoice = new PaymentInvoice();
                     $do_payment_invoice->getInvDetails($do_paymentlog->getData("idpaymentlog"));
                     while ($do_payment_invoice->next()) {
                         $xml .= "    <payment_invoice>\n";
                         $xml .= "     <idpayment_invoice><![CDATA[" . $do_payment_invoice->getData("idpayment_invoice") . "]]></idpayment_invoice>\n";
                         $xml .= "     <idpayment><![CDATA[" . $do_payment_invoice->getData("idpayment") . "]]></idpayment>\n";
                         $xml .= "     <idinvoice><![CDATA[" . $do_payment_invoice->getData("idinvoice") . "]]></idinvoice>\n";
                         $xml .= "     <amount><![CDATA[" . $do_payment_invoice->getData("amount") . "]]></amount>\n";
                         $xml .= "    </payment_invoice>\n";
                     }
                     $do_payment_invoice->free();
                     $do_paymentlog_extra_amount = new PaymentLog();
                     $do_paymentlog_extra_amount->getPaymentLogExtraAmountDetails($do_paymentlog->getData("idpaymentlog"));
                     while ($do_paymentlog_extra_amount->next()) {
                         $xml .= "    <paymentlog_extra_amount>\n";
                         $xml .= "     <idpaymentlog_extra_amount><![CDATA[" . $do_paymentlog_extra_amount->getData("idpaymentlog_extra_amount") . "]]></idpaymentlog_extra_amount>\n";
                         $xml .= "     <idpaymentlog><![CDATA[" . $do_paymentlog_extra_amount->getData("idpaymentlog") . "]]></idpaymentlog>\n";
                         $xml .= "     <extra_amt><![CDATA[" . $do_paymentlog_extra_amount->getData("extra_amt") . "]]></extra_amt>\n";
                         $xml .= "     <iduser><![CDATA[" . $do_paymentlog_extra_amount->getData("iduser") . "]]></iduser>\n";
                         $xml .= "    </paymentlog_extra_amount>\n";
                     }
                     $do_paymentlog_extra_amount->free();
                     $xml .= "   </paymentlog>\n";
                 }
                 $do_paymentlog->free();
                 $xml .= "  </invoice>\n";
             }
             $do_invoice->free();
             $do_tag = new Tag();
             $do_tag->getUserContactTags($iduser, $do_contact->getData("idcontact"));
             while ($do_tag->next()) {
                 $xml .= "  <tag>\n";
                 $xml .= "   <idtag><![CDATA[" . $do_tag->idtag . "]]></idtag>\n";
                 $xml .= "   <tag_name><![CDATA[" . $do_tag->tag_name . "]]></tag_name>\n";
                 $xml .= "   <iduser><![CDATA[" . $do_tag->iduser . "]]></iduser>\n";
                 $xml .= "   <reference_type><![CDATA[" . $do_tag->reference_type . "]]></reference_type>\n";
                 $xml .= "   <idreference><![CDATA[" . $do_tag->idreference . "]]></idreference>\n";
                 $xml .= "   <date_added><![CDATA[" . $do_tag->date_added . "]]></date_added>\n";
                 $xml .= "  </tag>\n";
             }
             $do_tag->free();
             $xml .= " </contact>\n";
             $i++;
         }
         //end line
         $xml .= "</contacts>\n";
     } else {
         // if no contact
         $do_task = new Task();
         $do_task->getContactTasksAssociatedWithProjectWithUser($iduser);
         while ($do_task->next()) {
             $do_project = new Project();
             $do_project->getId($do_task->idproject);
             $xml .= "  <project>\n";
             $xml .= "   <idproject><![CDATA[" . $do_project->idproject . "]]></idproject>\n";
             $xml .= "   <iduser><![CDATA[" . $do_project->iduser . "]]></iduser>\n";
             $xml .= "   <name><![CDATA[" . $do_project->name . "]]></name>\n";
             $xml .= "   <end_date_dateformat><![CDATA[" . $do_project->end_date_dateformat . "]]></end_date_dateformat>\n";
             $xml .= "   <idcompany><![CDATA[" . $do_project->idcompany . "]]></idcompany>\n";
             $xml .= "   <status><![CDATA[" . $do_project->status . "]]></status>\n";
             $xml .= "   <effort_estimated_hrs><![CDATA[" . $do_project->effort_estimated_hrs . "]]></effort_estimated_hrs>\n";
             $xml .= "   <is_public><![CDATA[" . $do_project->is_public . "]]></is_public>\n\n";
             $xml .= "   <project_task>\n";
             $xml .= "    <idproject_task><![CDATA[" . $do_task->getData("idproject_task") . "]]></idproject_task>\n";
             $xml .= "    <idtask><![CDATA[" . $do_task->getData("idtask") . "]]></idtask>\n";
             $xml .= "    <idproject><![CDATA[" . $do_task->getData("idproject") . "]]></idproject>\n";
             $xml .= "    <progress><![CDATA[" . $do_task->getData("progress") . "]]></progress>\n";
             $xml .= "    <drop_box_code><![CDATA[" . $do_task->getData("drop_box_code") . "]]></drop_box_code>\n";
             $xml .= "    <priority><![CDATA[" . $do_task->getData("priority") . "]]></priority>\n";
             $xml .= "    <hrs_work_expected><![CDATA[" . $do_task->getData("hrs_work_expected") . "]]></hrs_work_expected>\n";
             $xml .= "    <task_description><![CDATA[" . $do_task->getData("task_description") . "]]></task_description>\n";
             $xml .= "    <due_date><![CDATA[" . $do_task->getData("due_date") . "]]></due_date>\n";
             $xml .= "    <category><![CDATA[" . $do_task->getData("category") . "]]></category>\n";
             $xml .= "    <iduser><![CDATA[" . $do_task->getData("iduser") . "]]></iduser>\n";
             $xml .= "    <due_date_dateformat><![CDATA[" . $do_task->getData("due_date_dateformat") . "]]></due_date_dateformat>\n";
             $xml .= "    <status><![CDATA[" . $do_task->getData("status") . "]]></status>\n";
             $xml .= "    <date_completed><![CDATA[" . $do_task->getData("date_completed") . "]]></date_completed>\n";
             $xml .= "    <idcontact><![CDATA[" . $do_task->getData("idcontact") . "]]></idcontact>\n";
             $xml .= "    <from_note><![CDATA[" . $do_task->getData("from_note") . "]]></from_note>\n";
             $xml .= "    <is_sp_date_set><![CDATA[" . $do_task->getData("is_sp_date_set") . "]]></is_sp_date_set>\n";
             $xml .= "    <task_category><![CDATA[" . $do_task->getData("task_category") . "]]></task_category>\n\n";
             $do_prj_discuss = new ProjectDiscuss();
             $do_prj_discuss->getProjectTaskDiscussions($do_task->getData("idproject_task"));
             while ($do_prj_discuss->next()) {
                 $xml .= "    <project_discuss>\n";
                 $xml .= "     <idproject_discuss><![CDATA[" . $do_prj_discuss->getData("idproject_discuss") . "]]></idproject_discuss>\n";
                 $xml .= "     <idproject_task><![CDATA[" . $do_prj_discuss->getData("idproject_task") . "]]></idproject_task>\n";
                 $xml .= "     <idtask><![CDATA[" . $do_prj_discuss->getData("idtask") . "]]></idtask>\n";
                 $xml .= "     <idproject><![CDATA[" . $do_prj_discuss->getData("idproject") . "]]></idproject>\n";
                 $xml .= "     <discuss><![CDATA[" . $do_prj_discuss->getData("discuss") . "]]></discuss>\n";
                 $xml .= "     <date_added><![CDATA[" . $do_prj_discuss->getData("date_added") . "]]></date_added>\n";
                 $xml .= "     <document><![CDATA[" . $do_prj_discuss->getData("document") . "]]></document>\n";
                 $xml .= "     <iduser><![CDATA[" . $do_prj_discuss->getData("iduser") . "]]></iduser>\n";
                 $xml .= "     <drop_box_sender><![CDATA[" . $do_prj_discuss->getData("drop_box_sender") . "]]></drop_box_sender>\n";
                 $xml .= "     <priority><![CDATA[" . $do_prj_discuss->getData("priority") . "]]></priority>\n";
                 $xml .= "     <hours_work><![CDATA[" . $do_prj_discuss->getData("hours_work") . "]]></hours_work>\n";
                 $xml .= "     <discuss_edit_access><![CDATA[" . $do_prj_discuss->getData("discuss_edit_access") . "]]></discuss_edit_access>\n";
                 $xml .= "    </project_discuss>\n";
             }
             $do_prj_discuss->free();
             $xml .= "   </project_task>\n";
             $xml .= "  </project>\n";
             $do_project->free();
         }
         $do_task->free();
         $do_task = new Task();
         $do_task->getProjectsWithNoTask($iduser);
         while ($do_task->next()) {
             $do_project = new Project();
             $do_project->getId($do_task->idproject);
             $xml .= "  <project>\n";
             $xml .= "   <idproject><![CDATA[" . $do_project->idproject . "]]></idproject>\n";
             $xml .= "   <iduser><![CDATA[" . $do_project->iduser . "]]></iduser>\n";
             $xml .= "   <name><![CDATA[" . $do_project->name . "]]></name>\n";
             $xml .= "   <end_date_dateformat><![CDATA[" . $do_project->end_date_dateformat . "]]></end_date_dateformat>\n";
             $xml .= "   <idcompany><![CDATA[" . $do_project->idcompany . "]]></idcompany>\n";
             $xml .= "   <status><![CDATA[" . $do_project->status . "]]></status>\n";
             $xml .= "   <effort_estimated_hrs><![CDATA[" . $do_project->effort_estimated_hrs . "]]></effort_estimated_hrs>\n";
             $xml .= "   <is_public><![CDATA[" . $do_project->is_public . "]]></is_public>\n";
             $xml .= "  </project>\n";
         }
         $do_task->free();
     }
     $do_login_audit = new LoginAudit();
     $do_login_audit->getLoginAuditDetails($iduser);
     while ($do_login_audit->next()) {
         $xml .= "  <login_audit>\n";
         $xml .= "   <idlogin_audit><![CDATA[" . $do_login_audit->idlogin_audit . "]]></idlogin_audit>\n";
         $xml .= "   <iduser><![CDATA[" . $do_login_audit->iduser . "]]></iduser>\n";
         $xml .= "   <last_login><![CDATA[" . $do_login_audit->last_login . "]]></last_login>\n";
         $xml .= "   <ip_address><![CDATA[" . $do_login_audit->ip_address . "]]></ip_address>\n";
         $xml .= "   <login_type><![CDATA[" . $do_login_audit->login_type . "]]></login_type>\n";
         $xml .= "  </login_audit>\n";
         $xml .= "  </document>\n";
     }
     $do_login_audit->free();
     if (!is_dir(XML_EXPORT)) {
         mkdir(XML_EXPORT);
     }
     $xml_file = XML_EXPORT . "adm_" . $iduser . "_inactiveuser_bkp.xml";
     $handle_xml = fopen($xml_file, "w+");
     if (fwrite($handle_xml, $xml) === FALSE) {
         //$_SESSION['in_page_message'] = "ofuz_export_xml_failure";
         echo 'could not write';
         exit;
     } else {
         $_SESSION['in_page_message'] = "ofuz_export_xml_success";
     }
     fclose($handle_xml);
     //Below method deletes user information
     $deleteuser = new OfuzCancelAccount();
     $deleteuser->deleteUserAccount($iduser);
     $do_login_audit = new LoginAudit();
     $id = $do_login_audit->getLastLogin($iduser);
     $do_login_audit->getId($id);
     $do_login_audit->delete();
     $do_login_audit->free();
 }
示例#9
0
 /**
  * Event Method for Stripe Payment Process
  * test with credit card 4242424242424242
  * @param object $evtcl 
  */
 function eventProcessStripePayment(Eventcontroler $evtcl)
 {
     $flag = true;
     if ($evtcl->tot_amt > $_SESSION['do_invoice']->amt_due) {
         $_SESSION['in_page_message'] = _("The Total Amount entered is greater than the invoice amount. Please re-enter.");
         $flag = false;
     }
     if ($flag) {
         include_once 'class/Stripe.class.php';
         include_once "stripe-lib/Stripe.php";
         $token = $evtcl->stripeToken;
         $name = $evtcl->name;
         //$email = $evtcl->email;
         $description = $name;
         $srtipecustomer_id = $evtcl->stripecustomer_id;
         if ($evtcl->tot_amt > 0) {
             $total = $evtcl->tot_amt;
         } else {
             $total = $_SESSION['do_invoice']->amt_due;
         }
         //Amount need to conver to cents
         $total = $total * 100;
         $idinvoice = $_SESSION['do_invoice']->idinvoice;
         $idcontact = $_SESSION['do_invoice']->idcontact;
         $goto = $evtcl->goto;
         $error_page = $evtcl->error_page;
         $updateStripecustomer = $evtcl->updateStripecustomer;
         $do_contact = new Contact();
         $arr_user_info = $do_contact->getContactInfo_For_Invoice($idcontact);
         $inv_info_arr = array();
         $inv_info_arr['description'] = $_SESSION['do_invoice']->description;
         $inv_info_arr['inv_num'] = $_SESSION['do_invoice']->num;
         $stripe_api_key = $evtcl->stripe_api_key;
         $payment = new StripeGateWay(false, $stripe_api_key);
         if (empty($srtipecustomer_id)) {
             $result = $payment->CreateCustomer($token, $name, $total, $email = "", $description);
         } else {
             if ($updateStripecustomer === 'Yes') {
                 $result = $payment->UpdateExistingCustomer($srtipecustomer_id, $token, $name, $total, $email = "", $description = "");
                 if ($result['update'] == 1) {
                     $payment = new StripeGateWay(false, $stripe_api_key);
                     $result = $payment->CreateCustomer($token, $name, $total, $email = "", $description);
                 }
             } else {
                 $result = $payment->ChargeExsistingCustomer($srtipecustomer_id, $total);
             }
         }
         if ($result['success'] == '1') {
             //set the amout back to $ value
             $total = $total / 100;
             //echo $result['customer_id'];die();
             //Add the customer id in to stripe details class
             if (isset($result['customer_id'])) {
                 $this->saveStripeCustomerId($_SESSION['do_invoice']->iduser, $_SESSION['do_invoice']->idcontact, $result['customer_id']);
             }
             // Display a printable receipt
             $_SESSION['in_page_message'] = _("This transaction has been approved. Thank you for your payment");
             $do_pay_log = new PaymentLog();
             $do_pay_log->addPaymentLog($result['response']['id'], "Stripe", $_SESSION['do_invoice']->idinvoice, $total);
             $idpayment_log = $do_pay_log->getPrimaryKeyValue();
             $do_payment_inv = new PaymentInvoice();
             $do_payment_inv->addPaymentInvoice($idpayment_log, $_SESSION['do_invoice']->idinvoice, $total);
             $this->updatePayment($total);
             //$this->sendPaymentApprovedEmail($total,"Stripe.com",$transactionID);// Sending to customer
             //$this->sendPaymentApprovedEmail($total,"Stripe.com",$transactionID,true); // Sending to user
             if (isset($_SESSION["upgrade"])) {
                 $do_user = new User();
                 $date = date('Y-m-d');
                 $do_user->query("update user set plan='paid', regdate = '{$date}' where iduser="******"Y-m-d"), $_SESSION['do_User']->iduser);
                 $do_ccdetails = new CcDetails();
                 $do_ccdetails->iduser = $_SESSION['do_User']->iduser;
                 $do_ccdetails->token = $result['customer_id'];
                 $do_ccdetails->type = 'Stripe';
                 $do_ccdetails->add();
                 $goto = 'index.php';
                 unset($_SESSION['upgrade']);
             } else {
                 /*
                   Lets check if the invoice has an call back URL and process that
                 */
                 $do_inv_callback = new InvoiceCallback();
                 $do_User = $_SESSION['do_invoice']->getParentUser();
                 $do_inv_callback->processCallBack($this->idinvoice, $this->num, $total, $do_User->iduser, "ok", "Stripe", $transactionID);
                 /*
                 Check if there is a next URL if so then set goto variable to that URL. Userful if we want the user to go to someother page
                 Than in the goto page. This is triggered only when full payment is done.
                 */
                 $next_url = $do_inv_callback->isNextUrl($this->idinvoice);
             }
             //$goto = $next_url;
             $_SESSION['autologin_paid'] = True;
         } else {
             $rr = json_decode($result, true);
             //echo'<pre>';print_r($rr);echo'</pre>';die();
             $r = $rr['error']['message'];
             $error_code = $rr['error']['code'];
             $error_type = $rr['error']['type'];
             if ($error_code == 'invalid_expiry_month' || $error_code == 'invalid_expiry_year' || $error_code == 'expired_card' || $error_code == 'missing') {
                 $goto = $error_page;
                 $_SESSION['updatecustomer'] = 'Yes';
             } elseif ($error_type == 'invalid_request_error') {
                 $goto = $error_page;
                 $_SESSION['updatecustomer'] = 'Yes';
             }
             $_SESSION['in_page_message'] = $r;
         }
     }
     $disp_next = new Display($goto);
     if (isset($_SESSION['upgrade'])) {
         $msg = "Thank You . Your payment has been apporved and now you are paid user.";
         $disp_next->addParam("message", $msg);
     }
     $evtcl->setDisplayNext($disp_next);
 }
示例#10
0
 /**
  * Delete recurence form an invoice
  */
 function stop_recurrent()
 {
     $do_api_invoice = new Invoice();
     $do_api_rec_invoice = new RecurrentInvoice();
     if (!$do_api_invoice->isInvoiceOwner($this->idinvoice, $this->iduser)) {
         $this->setMessage("711", "Invoice does not belong to you");
         return false;
     } elseif ($do_api_rec_invoice->checkIfInvoiceIsInRecurrent($this->idinvoice)) {
         if ($do_api_rec_invoice->deleteRecurrentInvoice($this->idinvoice)) {
             $this->setMessage("750", "Recurence for invoice " . $this->idinvoice . " as been removed", "ok");
             return True;
         } else {
             $this->setMessage("733", "Invoice:" . $this->idinvoice . " Doesn't has any recurrence", "fail");
             return false;
         }
     } else {
         $this->setMessage("733", "Invoice:" . $this->idinvoice . " Doesn't has any recurrence", "fail");
         return false;
     }
 }
            $do_inv_line->description = $inv_line->description;
            $do_inv_line->price = $inv_line->price;
            $do_inv_line->qty = $inv_line->qty;
            $do_inv_line->total = $inv_line->total;
            $do_inv_line->item = $inv_line->item;
            $do_inv_line->add();
        }
        $do_invoice->setInvoiceCalculations($idinvoice);
        // Call this method for other calculations
        //update callback
        $do_inv_callbak = new InvoiceCallback();
        $do_inv_callbak->updateCallBack($do_recurrent->idcontact, $idinvoice);
        // Process RegistrationInvoiceLog will update only if the invoice is from registration Part of Ofuz.com
        $do_RegistrationInvoiceLog = new RegistrationInvoiceLog();
        // @params old invoiceid,new invoice id and the iduser
        $do_RegistrationInvoiceLog->process_reg_invoice_log($do_recurrent->idinvoice, $idinvoice, $do_recurrent->iduser);
        // Update Recurrent
        $do_recurrent_update = new RecurrentInvoice();
        $next_date = $do_recurrent_update->getNextDate($do_recurrent->recurrence, $do_recurrent->recurrencetype, $do_recurrent->nextdate);
        $do_recurrent_update->getId($do_recurrent->idrecurrentinvoice);
        $do_recurrent_update->nextdate = $next_date;
        $do_recurrent_update->idinvoice = $idinvoice;
        $do_recurrent_update->update();
        $do_recurrent_update->free();
        //Sending Email to the customer
        //echo 'Calling method sendInvoiceByEmail()..........<br />';
        $do_inv_add->sendInvoiceByEmail($idinvoice, $do_inv_add->idcontact, $do_inv_add->iduser, true);
        $do_inv_add->free();
        //}
    }
}
示例#12
0
 function eventImportAccount(EventControler $evtcl)
 {
     $msg = "";
     $uploaded_file = $_FILES['fields']['name']['import_account'];
     $target_path = 'files/' . $uploaded_file;
     if (!move_uploaded_file($_FILES['fields']['tmp_name']['import_account'], $target_path)) {
         $msg = "There was an error uploading the file, please try again!";
     } else {
         chmod($target_path, 0755);
         if (file_exists($target_path)) {
             //$xml = simplexml_load_file($_SERVER['DOCUMENT_ROOT']."/".$target_path);
             $str_xml = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/" . $target_path);
             $str_xml = preg_replace('/[^(\\x20-\\x7F)]*/', '', $str_xml);
             $xml = simplexml_load_string($str_xml);
             echo '<pre>';
             print_r($xml);
             echo '</pre>';
             die;
             if ($xml !== FALSE) {
                 $c_cnt = count($xml->contact);
                 if ($c_cnt) {
                     for ($i = 0; $i < $c_cnt; $i++) {
                         $do_contact = new Contact();
                         $contact = $xml->contact[$i];
                         $do_contact->firstname = $contact->firstname;
                         $do_contact->lastname = $contact->lastname;
                         $do_contact->position = $contact->position;
                         $do_contact->company = $contact->company;
                         $do_contact->idcompany = $contact->idcompany;
                         $do_contact->iduser = $_SESSION['do_User']->iduser;
                         $do_contact->picture = $contact->picture;
                         $do_contact->summary = $contact->summary;
                         $do_contact->birthday = $contact->birthday;
                         $do_contact->portal_code = $contact->portal_code;
                         $do_contact->fb_userid = $contact->fb_userid;
                         $do_contact->tw_user_id = $contact->tw_user_id;
                         $do_contact->email_optout = $contact->email_optout;
                         $do_contact->add();
                         $lastInsertedContId = $do_contact->getPrimaryKeyValue();
                         /**
                          *Contact Address	
                          */
                         $ca_cnt = count($contact->contact_address);
                         if ($ca_cnt) {
                             for ($ca_cnt_i = 0; $ca_cnt_i < $ca_cnt; $ca_cnt_i++) {
                                 $do_contact_address = new ContactAddress();
                                 $contact_address = $contact->contact_address[$ca_cnt_i];
                                 $do_contact_address->city = $contact_address->city;
                                 $do_contact_address->country = $contact_address->country;
                                 $do_contact_address->state = $contact_address->state;
                                 $do_contact_address->street = $contact_address->street;
                                 $do_contact_address->zipcode = $contact_address->zipcode;
                                 $do_contact_address->idcontact = $lastInsertedContId;
                                 $do_contact_address->address = $contact_address->address;
                                 $do_contact_address->address_type = $contact_address->address_type;
                                 $do_contact_address->add();
                                 $do_contact_address->free();
                             }
                         }
                         /**
                          *Contact Email	
                          */
                         $ce_cnt = count($contact->contact_email);
                         if ($ce_cnt) {
                             for ($ce_cnt_i = 0; $ce_cnt_i < $ce_cnt; $ce_cnt_i++) {
                                 $do_contact_email = new ContactEmail();
                                 $contact_email = $contact->contact_email[$ce_cnt_i];
                                 $do_contact_email->idcontact = $lastInsertedContId;
                                 $do_contact_email->email_address = $contact_email->email_address;
                                 $do_contact_email->email_type = $contact_email->email_type;
                                 $do_contact_email->email_isdefault = $contact_email->email_isdefault;
                                 $do_contact_email->add();
                                 $do_contact_email->free();
                             }
                         }
                         /**
                          *Contact Phone 
                          */
                         $cp_cnt = count($contact->contact_phone);
                         if ($cp_cnt) {
                             for ($cp_cnt_i = 0; $cp_cnt_i < $cp_cnt; $cp_cnt_i++) {
                                 $do_contact_phone = new ContactPhone();
                                 $contact_phone = $contact->contact_phone[$cp_cnt_i];
                                 $do_contact_phone->phone_number = $contact_phone->phone_number;
                                 $do_contact_phone->phone_type = $contact_phone->phone_type;
                                 $do_contact_phone->idcontact = $lastInsertedContId;
                                 $do_contact_phone->add();
                                 $do_contact_phone->free();
                             }
                         }
                         /**
                          *Contact Note	
                          */
                         $cn_cnt = count($contact->contact_note);
                         if ($cn_cnt) {
                             for ($cn_cnt_i = 0; $cn_cnt_i < $cn_cnt; $cn_cnt_i++) {
                                 $do_contact_note = new ContactNotes();
                                 $contact_note = $contact->contact_note[$cn_cnt_i];
                                 $do_contact_note->idcontact = $lastInsertedContId;
                                 $do_contact_note->note = $contact_note->note;
                                 $do_contact_note->date_added = $contact_note->date_added;
                                 $do_contact_note->document = $contact_note->document;
                                 $do_contact_note->idcompany = $contact_note->idcompany;
                                 $do_contact_note->iduser = $_SESSION['do_User']->iduser;
                                 $do_contact_note->priority = $contact_note->priority;
                                 $do_contact_note->send_email = $contact_note->send_email;
                                 $do_contact_note->hours_work = $contact_note->hours_work;
                                 $do_contact_note->note_visibility = $contact_note->note_visibility;
                                 $do_contact_note->type = $contact_note->type;
                                 $do_contact_note->add();
                                 $do_contact_note->free();
                             }
                         }
                         /**
                          *Contact Tag	
                          */
                         $ctag_cnt = count($contact->contact_tag);
                         if ($ctag_cnt) {
                             for ($ctag_cnt_i = 0; $ctag_cnt_i < $ctag_cnt; $ctag_cnt_i++) {
                                 $do_tag = new Tag();
                                 $contact_tag = $contact->contact_tag[$ctag_cnt_i];
                                 $do_tag->tag_name = $contact_tag->tag_name;
                                 $do_tag->iduser = $_SESSION['do_User']->iduser;
                                 $do_tag->reference_type = $contact_tag->reference_type;
                                 $do_tag->idreference = $lastInsertedContId;
                                 $do_tag->date_added = $contact_tag->date_added;
                                 $do_tag->add();
                                 $do_tag->free();
                             }
                         }
                         /**
                          *Contact tasks which are not associated with Project	
                          */
                         //Contact tasks which are not associated with Project
                         $ctwop_cnt = count($contact->contact_task_without_project);
                         if ($ctwop_cnt) {
                             for ($ctwop_cnt_i = 0; $ctwop_cnt_i < $ctwop_cnt; $ctwop_cnt_i++) {
                                 $do_task = new Task();
                                 $contact_task_wo_p = $contact->contact_task_without_project[$ctwop_cnt_i];
                                 $do_task->task_description = $contact_task_wo_p->task_description;
                                 $do_task->due_date = $contact_task_wo_p->due_date;
                                 $do_task->category = $contact_task_wo_p->category;
                                 $do_task->iduser = $_SESSION['do_User']->iduser;
                                 $do_task->due_date_dateformat = $contact_task_wo_p->due_date_dateformat;
                                 $do_task->status = $contact_task_wo_p->status;
                                 $do_task->date_completed = $contact_task_wo_p->date_completed;
                                 $do_task->idcontact = $lastInsertedContId;
                                 $do_task->from_note = $contact_task_wo_p->from_note;
                                 $do_task->is_sp_date_set = $contact_task_wo_p->is_sp_date_set;
                                 $do_task->task_category = $contact_task_wo_p->task_category;
                                 $do_task->add();
                                 $do_task->free();
                             }
                         }
                         /**
                          *Contact tasks which are associated with Project	
                          */
                         $arr_prj = array();
                         $cont_task_with_prj_cnt = count($contact->contact_task_with_project);
                         if ($cont_task_with_prj_cnt) {
                             for ($i = 0; $i < $cont_task_with_prj_cnt; $i++) {
                                 $do_project = new Project();
                                 $project = $contact->contact_task_with_project[$i];
                                 $do_project->iduser = $_SESSION['do_User']->iduser;
                                 $do_project->name = $project->name;
                                 $do_project->end_date_dateformat = $project->end_date_dateformat;
                                 $do_project->idcompany = $project->idcompany;
                                 $do_project->status = $project->status;
                                 $do_project->effort_estimated_hrs = $project->effort_estimated_hrs;
                                 $do_project->is_public = $project->is_public;
                                 $do_project->add();
                                 $lastInsertedPrjId = $do_project->getPrimaryKeyValue();
                                 //$arr_prj[$lastInsertedPrjId] = $project->idproject;
                                 $pt_cnt = count($project->project_task);
                                 if ($pt_cnt) {
                                     for ($pt_cnt_i = 0; $pt_cnt_i < $pt_cnt; $pt_cnt_i++) {
                                         $do_task = new Task();
                                         $project_task = $project->project_task[$pt_cnt_i];
                                         $do_task->task_description = $project_task->task_description;
                                         $do_task->due_date = $project_task->due_date;
                                         $do_task->category = $project_task->category;
                                         $do_task->iduser = $_SESSION['do_User']->iduser;
                                         $do_task->due_date_dateformat = $project_task->due_date_dateformat;
                                         $do_task->status = $project_task->status;
                                         $do_task->date_completed = $project_task->date_completed;
                                         $do_task->idcontact = $lastInsertedContId;
                                         $do_task->from_note = $project_task->from_note;
                                         $do_task->is_sp_date_set = $project_task->is_sp_date_set;
                                         $do_task->task_category = $project_task->task_category;
                                         $do_task->add();
                                         $lastInsertedTaskId = $do_task->getPrimaryKeyValue();
                                         $do_project_task = new ProjectTask();
                                         $do_project_task->idtask = $lastInsertedTaskId;
                                         $do_project_task->idproject = $lastInsertedPrjId;
                                         $do_project_task->progress = $project_task->progress;
                                         $do_project_task->drop_box_code = $project_task->drop_box_code;
                                         $do_project_task->priority = $project_task->priority;
                                         $do_project_task->hrs_work_expected = $project_task->hrs_work_expected;
                                         $do_project_task->add();
                                         $lastInsertedPrjTaskId = $do_project_task->getPrimaryKeyValue();
                                         $pd_cnt = count($project_task->project_discuss);
                                         if ($pd_cnt) {
                                             for ($i = 0; $i < $pd_cnt; $i++) {
                                                 $do_project_discuss = new ProjectDiscuss();
                                                 $project_discuss = $project_task->project_discuss[$i];
                                                 $do_project_discuss->idproject_task = $lastInsertedPrjTaskId;
                                                 $do_project_discuss->idtask = $lastInsertedTaskId;
                                                 $do_project_discuss->idproject = $lastInsertedPrjId;
                                                 $do_project_discuss->discuss = $project_discuss->discuss;
                                                 $do_project_discuss->date_added = $project_discuss->date_added;
                                                 $do_project_discuss->document = $project_discuss->document;
                                                 $do_project_discuss->iduser = $_SESSION['do_User']->iduser;
                                                 $do_project_discuss->drop_box_sender = $project_discuss->drop_box_sender;
                                                 $do_project_discuss->priority = $project_discuss->priority;
                                                 $do_project_discuss->hours_work = $project_discuss->hours_work;
                                                 $do_project_discuss->discuss_edit_access = $project_discuss->discuss_edit_access;
                                                 $do_project_discuss->type = $project_discuss->type;
                                                 $do_project_discuss->add();
                                                 $do_project_discuss->free();
                                             }
                                         }
                                         $do_project_task->free();
                                         $do_task->free();
                                     }
                                 }
                                 $do_project->free();
                             }
                         }
                         /**
                          *Invoice import
                          */
                         $msg_inv = "";
                         $inv_cnt = count($contact->invoice);
                         if ($inv_cnt) {
                             for ($inv_cnt_i = 0; $inv_cnt_i < $inv_cnt; $inv_cnt_i++) {
                                 $do_invoice = new Invoice();
                                 $invoice = $contact->invoice[$inv_cnt_i];
                                 $do_invoice->num = $invoice->num;
                                 $do_invoice->iduser = $_SESSION['do_User']->iduser;
                                 $do_invoice->description = $invoice->description;
                                 $do_invoice->amount = $invoice->amount;
                                 $do_invoice->datepaid = $invoice->datepaid;
                                 $do_invoice->datecreated = $invoice->datecreated;
                                 $do_invoice->status = $invoice->status;
                                 $do_invoice->discount = $invoice->discount;
                                 $do_invoice->idcontact = $lastInsertedContId;
                                 $do_invoice->due_date = $invoice->due_date;
                                 $do_invoice->invoice_address = $invoice->invoice_address;
                                 $do_invoice->invoice_term = $invoice->invoice_term;
                                 $do_invoice->invoice_note = $invoice->invoice_note;
                                 $do_invoice->sub_total = $invoice->sub_total;
                                 $do_invoice->net_total = $invoice->net_total;
                                 $do_invoice->amt_due = $invoice->amt_due;
                                 $do_invoice->idcompany = $invoice->idcompany;
                                 $do_invoice->tax = $invoice->tax;
                                 $do_invoice->set_delete = $invoice->set_delete;
                                 $do_invoice->total_discounted_amt = $invoice->total_discounted_amt;
                                 $do_invoice->total_taxed_amount = $invoice->total_taxed_amount;
                                 $do_invoice->add();
                                 $lastInsertedInvoiceId = $do_invoice->getPrimaryKeyValue();
                                 $invline_cnt = count($invoice->invoiceline);
                                 if ($invline_cnt) {
                                     for ($invline_cnt_i = 0; $invline_cnt_i < $invline_cnt; $invline_cnt_i++) {
                                         $do_invoiceline = new InvoiceLine();
                                         $invoiceline = $invoice->invoiceline[$invline_cnt_i];
                                         $do_invoiceline->idinvoice = $lastInsertedInvoiceId;
                                         $do_invoiceline->description = $invoiceline->description;
                                         $do_invoiceline->price = $invoiceline->price;
                                         $do_invoiceline->qty = $invoiceline->qty;
                                         $do_invoiceline->total = $invoiceline->total;
                                         $do_invoiceline->item = $invoiceline->item;
                                         $do_invoiceline->line_tax = $invoiceline->line_tax;
                                         $do_invoiceline->discounted_amount = $invoiceline->discounted_amount;
                                         $do_invoiceline->taxed_amount = $invoiceline->taxed_amount;
                                         $do_invoiceline->add();
                                         $do_invoiceline->free();
                                     }
                                 }
                                 //invoiceline import ends
                                 // recurrentinvoice
                                 $recinv_cnt = count($invoice->recurrentinvoice);
                                 if ($recinv_cnt) {
                                     for ($recinv_cnt_i = 0; $recinv_cnt_i < $recinv_cnt; $recinv_cnt_i++) {
                                         $do_recurrentinvoice = new RecurrentInvoice();
                                         $recurrentinvoice = $invoice->recurrentinvoice[$recinv_cnt_i];
                                         $do_recurrentinvoice->iduser = $_SESSION['do_User']->iduser;
                                         $do_recurrentinvoice->idinvoice = $lastInsertedInvoiceId;
                                         $do_recurrentinvoice->nextdate = $recurrentinvoice->nextdate;
                                         $do_recurrentinvoice->recurrence = $recurrentinvoice->recurrence;
                                         $do_recurrentinvoice->recurrencetype = $recurrentinvoice->recurrencetype;
                                         $do_recurrentinvoice->add();
                                         $do_recurrentinvoice->free();
                                     }
                                 }
                                 //recurrentinvoice import ends
                                 // Payment Log import
                                 $paymentlog_cnt = count($invoice->paymentlog);
                                 if ($paymentlog_cnt) {
                                     for ($paymentlog_cnt_i = 0; $paymentlog_cnt_i < $paymentlog_cnt; $paymentlog_cnt_i++) {
                                         $do_paymentlog = new PaymentLog();
                                         $paymentlog = $invoice->paymentlog[$paymentlog_cnt_i];
                                         $do_paymentlog->timestamp = $paymentlog->timestamp;
                                         $do_paymentlog->idinvoice = $lastInsertedInvoiceId;
                                         $do_paymentlog->amount = $paymentlog->amount;
                                         $do_paymentlog->payment_type = $paymentlog->payment_type;
                                         $do_paymentlog->ref_num = $paymentlog->ref_num;
                                         $do_paymentlog->date_added = $paymentlog->date_added;
                                         $do_paymentlog->add();
                                         $lastInsertedPaymentLogId = $do_paymentlog->getPrimaryKeyValue();
                                         //payment_invoice : Payment Invoice import
                                         $paymentinv_cnt = count($paymentlog->payment_invoice);
                                         if ($paymentinv_cnt) {
                                             for ($paymentinv_cnt_i = 0; $paymentinv_cnt_i < $paymentinv_cnt; $paymentinv_cnt_i++) {
                                                 $do_payment_invoice = new PaymentInvoice();
                                                 $paymentinvoice = $paymentlog->payment_invoice[$paymentinv_cnt_i];
                                                 $do_payment_invoice->idpayment = $lastInsertedPaymentLogId;
                                                 $do_payment_invoice->idinvoice = $lastInsertedInvoiceId;
                                                 $do_payment_invoice->amount = $paymentinvoice->amount;
                                                 $do_payment_invoice->add();
                                                 $do_payment_invoice->free();
                                             }
                                         }
                                         // payment_invoice import ends
                                         //paymentlog_extra_amount import
                                         $paymentlog_ext_amt_cnt = count($paymentlog->paymentlog_extra_amount);
                                         if ($paymentlog_ext_amt_cnt) {
                                             for ($paymentlog_ext_amt_cnt_i = 0; $paymentlog_ext_amt_cnt_i < $paymentlog_ext_amt_cnt; $paymentlog_ext_amt_cnt_i++) {
                                                 $paymentlog_extra_amount = $paymentlog->paymentlog_extra_amount[$paymentlog_ext_amt_cnt_i];
                                                 $q = new sqlQuery($GLOBALS['conx']);
                                                 $query = "INSERT INTO paymentlog_extra_amount (`idpaymentlog`,`extra_amt`,`iduser`)\n            VALUES (" . $lastInsertedPaymentLogId . "," . $paymentlog_extra_amount->extra_amt . "," . $_SESSION['do_User']->iduser . ")\n            ";
                                                 $q->query($query);
                                                 $q->free();
                                             }
                                         }
                                         // paymentlog_extra_amount import ends
                                         $do_paymentlog->free();
                                     }
                                 }
                                 //Payment Log import ends
                                 $msg_inv = ", Invoices";
                                 $do_invoice->free();
                             }
                         }
                         // Invoice import ends
                         /************************************************************************************************************************/
                         $do_contact->free();
                     }
                     $msg = "Your Contacts" . $msg_inv;
                 }
                 /**
                  *Company insert
                  */
                 $compani_id = array();
                 $lastInsertedCompani_id = array();
                 $companies_cnt = count($xml->companies);
                 if ($companies_cnt) {
                     for ($i = 0; $i < $companies_cnt; $i++) {
                         $do_company = new Company();
                         $company = $xml->companies[$i];
                         array_push($compani_id, "{$company->idcompany}");
                         // $do_company->idcompany=$company->idcompany;
                         $do_company->name = $company->name;
                         $do_company->iduser = $_SESSION['do_User']->iduser;
                         $do_company->add();
                         array_push($lastInsertedCompani_id, $do_company->getPrimaryKeyValue());
                         $do_company->free();
                     }
                 }
                 //tasks which are neither associated with Contact nor with project
                 $task_wop_cnt = count($xml->task_without_project);
                 if ($task_wop_cnt) {
                     for ($i = 0; $i < $task_wop_cnt; $i++) {
                         $do_task = new Task();
                         $task_wop = $xml->task_without_project[$i];
                         $do_task->task_description = $task_wop->task_description;
                         $do_task->due_date = $task_wop->due_date;
                         $do_task->category = $task_wop->category;
                         $do_task->iduser = $_SESSION['do_User']->iduser;
                         $do_task->due_date_dateformat = $task_wop->due_date_dateformat;
                         $do_task->status = $task_wop->status;
                         $do_task->date_completed = $task_wop->date_completed;
                         $do_task->idcontact = $task_wop->idcontact;
                         //it would be 0 since not associated with contact.
                         $do_task->from_note = $task_wop->from_note;
                         $do_task->is_sp_date_set = $task_wop->is_sp_date_set;
                         $do_task->task_category = $task_wop->task_category;
                         $do_task->add();
                         $do_task->free();
                     }
                     $msg .= ", Tasks";
                 }
                 //tasks which are associated with Project
                 $prj_cnt = count($xml->project);
                 if ($prj_cnt) {
                     for ($i = 0; $i < $prj_cnt; $i++) {
                         $do_project = new Project();
                         $project = $xml->project[$i];
                         $do_project->iduser = $_SESSION['do_User']->iduser;
                         $do_project->name = $project->name;
                         $do_project->end_date_dateformat = $project->end_date_dateformat;
                         $do_project->idcompany = $project->idcompany;
                         $do_project->status = $project->status;
                         $do_project->effort_estimated_hrs = $project->effort_estimated_hrs;
                         $do_project->is_public = $project->is_public;
                         $do_project->add();
                         $lastInsertedPrjId = $do_project->getPrimaryKeyValue();
                         $pt_cnt = count($project->project_task);
                         if ($pt_cnt) {
                             for ($pt_cnt_i = 0; $pt_cnt_i < $pt_cnt; $pt_cnt_i++) {
                                 $do_task = new Task();
                                 $project_task = $project->project_task[$pt_cnt_i];
                                 $do_task->task_description = $project_task->task_description;
                                 $do_task->due_date = $project_task->due_date;
                                 $do_task->category = $project_task->category;
                                 $do_task->iduser = $_SESSION['do_User']->iduser;
                                 $do_task->due_date_dateformat = $project_task->due_date_dateformat;
                                 $do_task->status = $project_task->status;
                                 $do_task->date_completed = $project_task->date_completed;
                                 $do_task->idcontact = $project_task->idcontact;
                                 $do_task->from_note = $project_task->from_note;
                                 $do_task->is_sp_date_set = $project_task->is_sp_date_set;
                                 $do_task->task_category = $project_task->task_category;
                                 $do_task->add();
                                 $lastInsertedTskId = $do_task->getPrimaryKeyValue();
                                 $q = new sqlQuery($GLOBALS['conx']);
                                 if ($project_task->progress == '') {
                                     $project_task_progress = 0;
                                 } else {
                                     $project_task_progress = $project_task->progress;
                                 }
                                 $sql = "INSERT INTO \n\t\t\tproject_task (idtask, idproject, progress,drop_box_code,priority,hrs_work_expected) \n\t\t\tVALUES ({$lastInsertedTskId},{$lastInsertedPrjId},{$project_task_progress},{$project_task->drop_box_code},{$project_task->priority},{$project_task->hrs_work_expected})";
                                 echo $sql;
                                 echo "<br>";
                                 $q->query($sql);
                                 $lastInsertedPrjTaskId = $q->getInsertId('project_task', 'idproject_task');
                                 $pd_cnt = count($project_task->project_discuss);
                                 if ($pd_cnt) {
                                     for ($pd_cnt_i = 0; $pd_cnt_i < $pd_cnt; $pd_cnt_i++) {
                                         $do_project_discuss = new ProjectDiscuss();
                                         $project_discuss = $project_task->project_discuss[$pd_cnt_i];
                                         $do_project_discuss->idproject_task = $lastInsertedPrjTaskId;
                                         $do_project_discuss->idtask = $lastInsertedTskId;
                                         $do_project_discuss->idproject = $lastInsertedPrjId;
                                         $do_project_discuss->discuss = $project_discuss->discuss;
                                         $do_project_discuss->date_added = $project_discuss->date_added;
                                         $do_project_discuss->document = $project_discuss->document;
                                         $do_project_discuss->iduser = $_SESSION['do_User']->iduser;
                                         $do_project_discuss->drop_box_sender = $project_discuss->drop_box_sender;
                                         $do_project_discuss->priority = $project_discuss->priority;
                                         $do_project_discuss->hours_work = $project_discuss->hours_work;
                                         $do_project_discuss->discuss_edit_access = $project_discuss->discuss_edit_access;
                                         $do_project_discuss->type = $project_discuss->type;
                                         $do_project_discuss->add();
                                         $do_project_discuss->free();
                                     }
                                 }
                                 // $do_project_task->free();
                                 $do_task->free();
                             }
                         }
                         $do_project->free();
                     }
                     $compani_id_cnt = count($compani_id);
                     if ($compani_id_cnt) {
                         $j = 0;
                         foreach ($compani_id as $cmp_id) {
                             $q = new sqlQuery($GLOBALS['conx']);
                             $sql = "UPDATE  contact SET idcompany ={$lastInsertedCompani_id[$j]}  WHERE  iduser={$_SESSION['do_User']->iduser} AND idcompany ={$cmp_id}";
                             $q->query($sql);
                             $sql1 = "UPDATE  invoice SET idcompany ={$lastInsertedCompani_id[$j]}  WHERE  iduser={$_SESSION['do_User']->iduser} AND idcompany ={$cmp_id}";
                             $q->query($sql1);
                             $sql2 = "UPDATE  project SET idcompany ={$lastInsertedCompani_id[$j]}  WHERE  iduser={$_SESSION['do_User']->iduser} AND idcompany ={$cmp_id}";
                             $q->query($sql2);
                             $q->free();
                             $j++;
                         }
                     }
                     $do_create_usrtbl = new ContactView();
                     $do_create_usrtbl->rebuildContactUserTable($_SESSION['do_User']->iduser);
                     $msg .= " and Projects have been imported successfully.";
                 }
             } else {
                 $msg = "Sorry! The data could not be imported.";
             }
         } else {
             $msg = "Sorry! Could not find the uploaded file.";
         }
     }
     $_SESSION['in_page_message'] = $msg;
 }
示例#13
0
         //$emailer->send();
     }
     //Email for admin
     $doemail_template_adm = new EmailTemplate("ofuz_inv_payment_confirmation_adm");
     $doemail_template_adm->setSenderName('Admin');
     $doemail_template_adm->setSenderEmail($admin_email);
     $emailer2 = new Radria_Emailer();
     $emailer2->setEmailTemplate($doemail_template_adm);
     $emailer2->mergeArray($email_data);
     $emailer2->addTo($admin_email);
     print_r($emailer);
     //$emailer->send();
     $do_user = new User();
     $date = date('Y-m-d');
     $do_user->query("update user set plan='paid' where iduser="******"Y-m-d"), $iduser);
     echo "Paid";
 } else {
     $do_user = new User();
     $do_user->query("update user set status='suspend'  where iduser="******"Not paid declined";
 }
 $do_pay_log->free();
 $do_payment_inv->free();
 $do_invoice1->free();
 $do_invoice->free();
 $do_user->free();
 $do_recurrentInvoice->free();
 $payment->free();
 $read_qry2->free();