/** * Custom add method to add an invoice. Needs a contact for each invocie else * do not add the invoice * @param $evtcl -- Object */ function addInvoice(EventControler $evtcl) { $_SESSION['in_page_message'] = ''; $rec_value = $evtcl->recurrent; $add_invoice = false; $do_contact = new Contact(); $concat_name_in_address = ''; if ($evtcl->fields["due_date"] == '') { $this->due_date = date('Y-m-d'); } else { $this->due_date = $evtcl->fields["due_date"]; } if ($evtcl->idcontact) { $idcontact = $evtcl->idcontact; $add_invoice = true; $do_contact->getId($idcontact); } else { $cont_name = $evtcl->contact; if ($cont_name != '') { $do_Contact_View = new ContactView(); $do_contact->addNew(); $do_contact->firstname = $cont_name; $do_contact->iduser = $_SESSION['do_User']->iduser; $do_contact->add(); $idcontact = $do_contact->getPrimaryKeyValue(); $do_Contact_View->setUser($_SESSION['do_User']->iduser); $do_contact->getId($idcontact); $concat_name_in_address = $do_contact->firstname; $do_Contact_View->addFromContact($do_contact); $do_Contact_View->updateFromContact($do_contact); if ($idcontact) { $add_invoice = true; $do_cont_addr = new ContactAddress(); $do_cont_addr->addNew(); $do_cont_addr->idcontact = $idcontact; $do_cont_addr->address = $evtcl->fields["invoice_address"]; $do_cont_addr->address_type = 'Work'; if (strlen($evtcl->fields["invoice_address"]) > 0) { $do_cont_addr->add(); } } } } if ($add_invoice) { // Keep the idcontact in case there is an idcompany if ($do_contact->idcompany != '' && !empty($do_contact->idcompany)) { $this->idcompany = $do_contact->idcompany; } //$this->num = $this->getUniqueInvoiceNum(); $this->num = time(); $this->iduser = $_SESSION['do_User']->iduser; $this->idterms = $evtcl->fields["idterms"]; $this->description = $evtcl->fields["description"]; $this->discount = $evtcl->fields["discount"]; $this->tax = $evtcl->fields["tax"]; $this->datecreated = date("Y-m-d"); $this->idcontact = $idcontact; $this->status = 'Quote'; $this->invoice_note = $evtcl->fields["invoice_note"]; $this->invoice_term = $evtcl->fields["invoice_term"]; if ($concat_name_in_address == '') { $this->invoice_address = $evtcl->fields["invoice_address"]; } else { $this->invoice_address = $concat_name_in_address . '<br />' . $evtcl->fields["invoice_address"]; } $this->add(); $this->idinvoice = $this->getPrimaryKeyValue(); // If the user set to have the ivoice added as recurrent Invoice then add if ($evtcl->setRec == 'Yes') { if (!empty($rec_value) && preg_match('/^[0-9]+$/', $rec_value) && $rec_value != 0) { // Add to recurrent $_SESSION['RecurrentInvoice']->addRecurrentInvoice($this->getPrimaryKeyValue(), $evtcl->recurrent, $evtcl->frequency, date("Y-m-d")); } else { $_SESSION['in_page_message'] = _("Recurrent Value is not correct.To set as Recurrent edit the invoice and enter numeric value"); } } } else { $_SESSION['in_page_message'] = _("Invoice could be created. Possible reason Contact Missing."); $evtcl->setDisplayNext(new Display('invoices.php')); } }
echo $msg->getMessage('my profile instruction'); //echo '<br /><br />'; //echo _('Your Profile Page is : '). $GLOBALS['cfg_ofuz_site_http_base'].'profile/'.$_SESSION['do_User']->username; ?> </div>--> </div><br /> <?php $do_contact = new Contact(); $do_np_contact = new Contact(); if (!empty($_SESSION['do_User']->idcontact) && $_SESSION['do_User']->idcontact != 0) { $idcontact = $_SESSION['do_User']->idcontact; $do_contact->getId($_SESSION['do_User']->idcontact); } else { // Add a new contact and update the idcontact to the user table for the user $do_contact->addNew(); $do_contact->firstname = $_SESSION['do_User']->firstname; $do_contact->lastname = $_SESSION['do_User']->lastname; $do_contact->iduser = $_SESSION['do_User']->iduser; $do_contact->add(); $idcontact_inserted = $do_contact->getPrimaryKeyValue(); $do_contact_view = new ContactView(); $_SESSION['do_User']->idcontact = $idcontact_inserted; $do_contact->getId($idcontact_inserted); } $_SESSION['edit_from_page'] = 'settings_myinfo.php'; $do_contact->sessionPersistent("ContactEditSave", "contact.php", OFUZ_TTL); //$do_contact->sessionPersistent("ContactEditSave", "index.php", 120); //$do_np_contact->sessionPersistent("ContactPictureSave", "index.php", 120); $do_np_contact->sessionPersistent("ContactPictureSave", "index.php", OFUZ_TTL); $_SESSION['ContactPictureSave']->getId($idcontact);
function add_contact() { $do_api_contact = new Contact(); $do_Contact_View = new ContactView(); $do_api_contact->addNew(); $do_api_contact->firstname = $this->firstname; $do_api_contact->lastname = $this->lastname; $do_api_contact->position = $this->position; $do_api_contact->iduser = $this->iduser; if ($this->tags != '') { $tags = explode(",", $this->tags); } if ($this->firstname == "" && $this->lastname == "") { $this->setMessage("610", "First Name OR Last Name is Required"); return false; } elseif (!$this->iduser) { $this->setMessage("502", "The User Session is expired"); return false; } elseif ($idcontact = $do_api_contact->duplicateContact($this->iduser, $this->email_work, $this->email_home, $this->email_other)) { $this->setMessage("613", "The Contact is duplicated. Contact ID: " . $idcontact); return false; } else { if ($this->company != "") { $do_api_contact->company = $this->company; $do_api_company = new Company(); $idcompany = $do_api_company->isDuplicateCompany($this->company, $this->iduser); if (!$idcompany) { $do_api_company->addNew(); $do_api_company->iduser = $this->iduser; $do_api_company->name = trim($this->company); $do_api_company->add(); $this->idcompany = $do_api_company->getPrimaryKeyValue(); } else { $this->idcompany = $idcompany; } $do_api_contact->idcompany = $this->idcompany; } $do_api_contact->add(); $this->idcontact = $do_api_contact->getPrimaryKeyValue(); $do_api_contact->idcontact = $this->idcontact; //child data starts here // Phones if ($this->phone_work != "") { $do_api_contact->addPhone($this->phone_work, "Work"); } if ($this->phone_home != "") { $do_api_contact->addPhone($this->phone_home, "Home"); } if ($this->mobile_number != "") { $do_api_contact->addPhone($this->mobile_number, "Mobile"); } if ($this->fax_number != "") { $do_api_contact->addPhone($this->fax_number, "Fax"); } if ($this->phone_other != "") { $do_api_contact->addPhone($this->phone_other, "Other"); } //emails if ($this->email_work != "") { $do_api_contact->addEmail($this->email_work, "Work"); } if ($this->email_home != "") { $do_api_contact->addEmail($this->email_home, "Home"); } if ($this->email_other != "") { $do_api_contact->addEmail($this->email_other, "Other"); } //Website if ($this->company_website != "") { $do_api_contact->addWebsite($this->company_website, "Company"); } if ($this->personal_website != "") { $do_api_contact->addWebsite($this->personal_website, "Personal"); } if ($this->blog_url != "") { $do_api_contact->addWebsite($this->blog_url, "Blog"); } if ($this->twitter_profile_url != "") { $do_api_contact->addWebsite($this->twitter_profile_url, "Twitter"); } if ($this->linkedin_profile_url != "") { $do_api_contact->addWebsite($this->linkedin_profile_url, "LinkedIn"); } if ($this->facebook_profile_url != "") { $do_api_contact->addWebsite($this->facebook_profile_url, "Facebook"); } // API V.02 will have IM and Address //Add tags if any if (is_array($tags)) { $do_api_tags = new Tag(); foreach ($tags as $tag) { $do_api_tags->addNew(); $do_api_tags->addTagAssociation($this->idcontact, $tag, "contact", $this->iduser); } } // Ok here the last thing that needs to be done so that the contact should also on the table $do_Contact_View = new ContactView(); $do_Contact_View->setUser($this->iduser); $do_api_contact->getId($this->idcontact); $do_Contact_View->addFromContact($do_api_contact); $do_Contact_View->updateFromContact($do_api_contact); if ($this->tags != '') { $do_Contact_View->addTag($this->tags, $this->idcontact); } $this->setValues(array("msg" => "Contact Added", "stat" => "ok", "code" => "600", "idcontact" => $this->idcontact)); return true; } }
/** * saveWebForm() * this will check if contact exists with firname, lastname, name and email * If exist add to it, if doesn't exists create a new one. */ function eventAddContact(EventControler $event_controler) { //$fields = $_REQUEST['fields']; $fields = $event_controler->fields; $this->setLog("\n eventAddContact, creating new contact from form, using " . count($fields) . " fields. (" . date("Y/m/d H:i:s") . ")"); //$dropcode = $_POST['dropcode']; if (isset($this->iduser)) { $do_contact = new Contact(); $do_contact->iduser = $this->iduser; $do_contact->add(); $this->setLog("\n new contact:" . $do_contact->idcontact . " for user:"******"\n new contact:" . $do_contact->idcontact . " for user:"******"\n Processing field:" . $field_name . " with value:" . $field_value); if (isset($this->idwebformuser)) { $do_webform_fields = new WebFormUserField(); $do_webform_fields->query("SELECT wfu.name, wff.class as class_name, wff.variable, wff.variable_type, wfu.required \n\t\t FROM webformfields as wff, webformuserfield as wfu \n WHERE wff.name=wfu.name\n AND wfu.name = '" . $field_name . "'\n AND wfu.idwebformuser= "******"SELECT wfu.name, wff.class as class_name, wff.variable, wff.variable_type, wfu.required \n FROM webformfields as wff, webformuserfield as wfu \n WHERE wff.name=wfu.name\n AND wfu.name = '" . $field_name . "'\n AND wfu.idwebformuser= "******"\n Field information class:" . $do_webform_fields->class_name . " Variable:" . $do_webform_fields->variable); $this->setLog("\n rows:" . $do_webform_fields->getNumRows()); if ($do_webform_fields->getNumRows() == 1) { if ($do_webform_fields->class_name == "Contact") { $this->setLog("\n Updating contact"); $do_contact->{$do_webform_fields->variable} = $field_value; $do_contact->update(); } else { $update = false; if (is_object(${'sub_' . $do_webform_fields->class_name})) { if (${'sub_' . $do_webform_fields->class_name}->getType() == $do_webform_fields->variable_type) { $update = true; } } if ($update) { $this->setLog("\n Updating class:" . $do_webform_fields->class_name); $obj = ${'sub_' . $do_webform_fields->class_name}; $obj->{$do_webform_fields->variable} = $field_value; $obj->update(); } else { $class_name = $do_webform_fields->class_name; ${'sub_' . $class_name} = new $class_name(); $obj = ${'sub_' . $class_name}; $obj->{$do_webform_fields->variable} = $field_value; if (method_exists($obj, "setType") && strlen($do_webform_fields->variable_type) > 0) { $obj->setType($do_webform_fields->variable_type); } $obj->idcontact = $do_contact->getPrimaryKeyValue(); $obj->iduser = $event_controler->uid; $obj->add(); } } } } if (isset($this->iduser)) { $contact_view = new ContactView(); $contact_view->setUser($this->iduser); $contact_view->addFromContact($do_contact); } else { $contact_view = new ContactView(); $contact_view->setUser($event_controler->uid); $contact_view->addFromContact($do_contact); } if (isset($this->tags)) { $tags = explode(",", $this->tags); foreach ($tags as $tag) { $tag = trim($tag); $do_tag = new Tag(); $do_tag->addNew(); $do_tag->addTagAssociation($do_contact->getPrimaryKeyValue(), $tag, "contact", $this->iduser); $contact_view->addTag($tag); } if (strlen($this->urlnext) > 0) { $event_controler->setUrlNext($this->urlnext); } else { $event_controler->setUrlNext($GLOBALS['cfg_ofuz_site_http_base'] . 'web_form_thankyou.php'); } $event_controler->addParam("do_contact", $do_contact); } else { $sql = "SELECT * FROM {$this->table} WHERE idwebformuser={$event_controler->fid}"; $this->query($sql); while ($this->fetch()) { $tags = $this->getData("tags"); $urlnext = $this->getData("urlnext"); } $tags = explode(",", $tags); foreach ($tags as $tag) { $tag = trim($tag); $do_tag = new Tag(); $do_tag->addNew(); $do_tag->addTagAssociation($do_contact->getPrimaryKeyValue(), $tag, "contact", $this->iduser); $contact_view->addTag($tag); } if (strlen($urlnext) > 0) { $event_controler->setUrlNext($urlnext); } else { $url = $GLOBALS['cfg_ofuz_site_http_base'] . 'web_form_thankyou.php'; //$event_controler->setUrlNext($url); //header("location:$url"); $err_disp = new Display($url); $event_controler->setDisplayNext($err_disp); $event_controler->doForward(); } //$event_controler->addParam("do_contact", $do_contact); } }
//$disp->addParam("entry", $_SERVER['REQUEST_URI']); $_SESSION['entry'] = $_SERVER['REQUEST_URI']; header("Location: /" . $disp->getUrl()); } } catch (Exception $e) { $disp = new Display("user_login.php"); $disp->addParam("message", "Error with your user record, please sign-in again"); //$disp->addParam("entry", $_SERVER['REQUEST_URI']); $_SESSION['entry'] = $_SERVER['REQUEST_URI']; header("Location: /" . $disp->getUrl()); } } } if ($_SESSION['hcard_idcontact'] != '') { $do_add_cont = new Contact(); $do_add_cont->addNew(); $do_add_cont->firstname = $_SESSION['do_contact']->firstname; $do_add_cont->lastname = $_SESSION['do_contact']->lastname; $do_add_cont->iduser = $_SESSION['do_User']->iduser; $do_add_cont->add(); $idcontact_inserted = $do_add_cont->getPrimaryKeyValue(); $ContactPhone = $_SESSION['do_contact']->getChildContactPhone(); $ContactPhoneAdd = new ContactPhone(); if ($ContactPhone->getNumRows()) { while ($ContactPhone->next()) { $ContactPhoneAdd->addNew(); $ContactPhoneAdd->idcontact = $idcontact_inserted; $ContactPhoneAdd->phone_type = $ContactPhone->phone_type; $ContactPhoneAdd->phone_number = $ContactPhone->phone_number; $ContactPhoneAdd->add(); }