public function testExtractIncomingParams() { $connect = new ContactData(); $fname = "Prakash"; $femail = "*****@*****.**"; $fsendmail = "hi"; $fenquiry = "job"; $fphone = "8097375414"; $fcountry = "Spain"; $this->assertTrue($connect->extractIncomingParams($fname, $femail, $fenquiry, $fcountry, $fphone, $fsendmail) !== false); }
/** * Adds a contact data to a person * * @param string $type The type of contact data to add * @param array $data The contact data array * @param string $comment Any additional comment (optional) * @return \DeskPRO\Person */ public function addContactData(ContactData $contactData) { @($this->_dataArray['contact_data'] = $contactData->getDataArray()); return $this; }
<div class="col-md-12"> <div class="btn-group pull-right"> <a href="index.php?view=newcontact" class="btn btn-default"><i class='fa fa-male'></i> Nuevo Contacto</a> <!--<div class="btn-group pull-right"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-download"></i> Descargar <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li><a href="report/medicss-word.php">Word 2007 (.docx)</a></li> </ul> </div> --> </div> <h1>Contactos</h1> <br> <?php $users = ContactData::getAll(); if (count($users) > 0) { // si hay usuarios ?> <table class="table table-bordered table-hover"> <thead> <th>Nombre completo</th> <th>Direccion</th> <th>Email</th> <th>Telefono</th> <th></th> </thead> <?php foreach ($users as $user) { ?>
<?php if (count($_POST) > 0) { $user = new ContactData(); $user->name = $_POST["name"]; $user->category_id = $category_id; $user->lastname = $_POST["lastname"]; $user->address = $_POST["address"]; $user->email = $_POST["email"]; $user->phone = $_POST["phone"]; $user->add(); print "<script>window.location='index.php?view=contacts';</script>"; }
<div class="col-md-12"> <div class="btn-group pull-right"> <a href="index.php?view=newcontact" class="btn btn-default"><i class='fa fa-male'></i> Nuevo Contacto</a> <!--<div class="btn-group pull-right"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <i class="fa fa-download"></i> Descargar <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li><a href="report/medicss-word.php">Word 2007 (.docx)</a></li> </ul> </div> --> </div> <h1>Contactos</h1> <br> <?php $users = ContactData::getAllActive(); if (count($users) > 0) { ?> <table class="table table-bordered table-hover"> <thead> <th>Nombre completo</th> <th>Direccion</th> <th>Email</th> <th>Telefono</th> <th>Opcion</th> </thead> <?php foreach ($users as $user) { ?> <tr>
function releaseLive($smarty, $msi, $user_id) { //echo '<pre>'.print_r($_POST,true)."</pre>"; /* First, get the data for the fields selected for release. Only consider fields that have been changed. User fields have data_id = 'u' Contact fields have data_id=address_id, phone_id, or e-mail_id for existing items, and -hold_id for adds. */ $contact_id = $_POST['contact_id']; $user_data = new UserData($msi, $smarty, $user_id, $contact_id); $contact_data = new ContactData($msi, $smarty, $user_id, $contact_id); $err_msg = ''; //echo '<pre>'.print_r($contact_data,true).'</pre>'; //echo '<pre>'.print_r($user_data,true).'</pre>'; $data_keys = array(); foreach ($_POST as $key => $px) { if (substr($key, 0, 1) == 's') { $data_type = substr($key, 1, 1); // a, p, e, u $field_name = substr($key, strpos($key, '_', 3) + 1); /*echo '<br />data type, field name: '.$data_type.' '. $field_name;*/ if ($data_type == 'u') { $data_id = 'u'; $trans_type = $user_data->getTransType($field_name); if ($trans_type != '') { $val = $user_data->getVal($field_name); $data_keys[] = array('data_type' => $data_type, 'data_id' => $data_id, 'trans_type' => $trans_type, 'field_name' => $field_name, 'val' => $val); } } else { $data_id = substr($key, 3, strpos($key, '_', 3) - 3); $trans_type = $contact_data->getTransType($data_type, $data_id, $field_name); //echo '<br />data id, trans type: '.$data_id.' '.$trans_type; if ($trans_type != '') { $val = $contact_data->getVal($data_type, $data_id, $field_name); $data_keys[] = array('data_type' => $data_type, 'data_id' => $data_id, 'trans_type' => $trans_type, 'field_name' => $field_name, 'val' => $val); } } } } //echo '<pre>'.print_r($data_keys,true).'</pre>'; sort($data_keys); //echo '<pre>data keys: '.print_r($data_keys,true).'</pre>'; $data_id = ''; $data_type = ''; foreach ($data_keys as $px) { if ($data_id != $px['data_id'] || $data_type != $px['data_type']) { if ($data_id != '') { // update db setQuery($msi, $user_id, $data_type, $data_id, $contact_id, $trans_type, $userq, $addfields, $addvals, $changeq, $changew, $err_msg); } // (re-) set variables $data_id = $px['data_id']; $data_type = $px['data_type']; $c_count = false; $userq = ''; $addfields = ''; $addvals = ''; $changeq = ''; $changew = ''; // where clause } $trans_type = $px['trans_type']; $field_name = $px['field_name']; $val = $px['val']; /*echo "<br />data_id, data_type, trans_type, field_name, val: ". "$data_id, $data_type, $trans_type, $field_name, $val";*/ if ($data_type == 'u') { // user data if ($c_count) { // if there is already something in the list $userq .= ','; } if ($field_name == 'birth_date') { $userq .= $field_name . "=str_to_date('{$val}','%m/%d/%Y')"; } else { $userq .= $field_name . "='" . $val . "'"; } } else { // address, phone, or e-mail switch ($trans_type) { case 'add': if ($val != '') { if ($data_type == 'p' && $field_name == 'number') { $val = str_replace(array('(', ')', ' ', '-'), "", $val); } if ($c_count) { $addfields .= ','; $addvals .= ','; } else { if ($data_type == 'p') { $addfields = 'owner_id,formatted,'; $addvals = $contact_id . ',0,'; } else { $addfields = 'owner_id,'; $addvals = $contact_id . ','; } } $addfields .= $field_name; $addvals .= "'" . $val . "'"; } break; case 'change': if ($data_type == 'p' && $field_name == 'number') { $val = str_replace(array('(', ')', ' ', '-'), '', $val); } if ($c_count) { $changeq .= ','; } else { if ($data_type == 'p') { $changeq = 'formatted=0,'; } else { $changeq = ''; } $changew = " where " . tableName($data_type) . "_id=" . $data_id; } $changeq .= $field_name . "='" . $val . "'"; break; //case 'del': /* delete query only uses $data_type, $data_id, and $contact_id, set elsewhere */ // break; } } $c_count = true; } setQuery($msi, $user_id, $data_type, $data_id, $contact_id, $trans_type, $userq, $addfields, $addvals, $changeq, $changew, $err_msg); unset($user_data, $contact_data); return $err_msg; }
<?php if (count($_POST) > 0) { $user = ContactData::getById($_POST["id"]); $user->name = $_POST["name"]; $user->lastname = $_POST["lastname"]; $user->address = $_POST["address"]; $user->email = $_POST["email"]; $user->phone = $_POST["phone"]; $user->update(); print "<script>window.location='index.php?view=contacts';</script>"; }
} } // --- Step 3: Process Request // Switch based on incoming method if (isset($_POST['method'])) { if (strcasecmp($_POST['method'], 'sendmail') == 0) { $response['code'] = 1; $response['status'] = $api_response_code[$response['code']]['HTTP Response']; $contact = new ContactData(); $contact->mapIncomingParams($_POST['name'], $_POST['email'], $_POST['enquiry'], $_POST['country'], $_POST['phone'], $_POST['message']); $response['contactSaved'] = $contact->processContactForm(); deliver_response($_POST['format'], $response, true); } if (strcasecmp($_POST['method'], 'deletecontact') == 0) { $response['code'] = 1; $response['status'] = $api_response_code[$response['code']]['HTTP Response']; $delete = new ContactData(); $response['contactDelete'] = $delete->deleteContacts($_POST[email]); deliver_response($_GET['format'], $response, false); } } else { if (isset($_GET['method'])) { if (strcasecmp($_GET['method'], 'getContacts') == 0) { $response['code'] = 1; $response['status'] = $api_response_code[$response['code']]['HTTP Response']; $fetch = new ContactData(); $response['contactShow'] = $fetch->getAllContacts(); deliver_response($_GET['format'], $response, false); } } }
<?php $user = ContactData::getById($_GET["id"]); ?> <div class="row"> <div class="col-md-12"> <h1>Editar Contacto</h1> <br> <form class="form-horizontal" method="post" id="addproduct" action="index.php?view=updatecontact" role="form"> <div class="form-group"> <label for="inputEmail1" class="col-lg-2 control-label">Nombre*</label> <div class="col-md-6"> <input type="text" name="name" value="<?php echo $user->name; ?> " class="form-control" id="name" placeholder="Nombre"> </div> </div> <div class="form-group"> <label for="inputEmail1" class="col-lg-2 control-label">Apellido*</label> <div class="col-md-6"> <input type="text" name="lastname" value="<?php echo $user->lastname; ?> " required class="form-control" id="lastname" placeholder="Apellido"> </div> </div> <div class="form-group"> <label for="inputEmail1" class="col-lg-2 control-label">Direccion*</label> <div class="col-md-6">
<?php $client = ContactData::getById($_GET["id"]); $client->del(); Core::redir("./index.php?view=contacts");