add_action('silex_action','the_contacts'); function contacts_title(){ echo "Contact List"; } function contacts_css() { ?> post('/contacts/add-contact', function (Request $request) { global $db; $friend_id = $request->get('id'); $user_id = $_SESSION['user_id']; $db->bind("friend_id", $friend_id); $db->bind("user_id", $user_id); // Bind the data $userReg = $db->query("INSERT INTO user_friend(friend_id,user_id) VALUES (:friend_id,:user_id)"); $db->bind("user_id", $friend_id); $db->bind("friend_id", $user_id); // Bind the data $userReg = $db->query("INSERT INTO user_friend(friend_id,user_id) VALUES (:friend_id,:user_id)"); if ($userReg) { return new Response("SUCCESS", 200); } else { return new Response('FAILED', 200); } }); $app->post('/contacts/get-detail', function (Request $request) { global $db; $id = $request->get('id'); // Bind the data $html = getModalContact($id); return $html; }); $app->post('/companies/addmarking', function (Request $request) { global $db; $friend_id = $request->get('friend_id'); $company_id = $request->get('company_id'); $marking_no = $request->get('marking_no'); $db->bind("friend_id", $friend_id); $db->bind("company_id", $company_id); $db->bind("marking_no", json_encode($marking_no)); // Bind the data $marking_no_upd = $db->query("UPDATE company_friend SET status = 1, marking_no = :marking_no WHERE company_id = :company_id and friend_id = :friend_id"); $db->bind("friend_id", $company_id); $db->bind("company_id", $friend_id); $db->bind("marking_no", json_encode($marking_no)); // Bind the data $marking_no_upd2 = $db->query("UPDATE company_friend SET status = 1, marking_no = :marking_no WHERE company_id = :company_id and friend_id = :friend_id"); if ($marking_no_upd && $marking_no_upd2) { return new Response("SUCCESS", 200); } else { return new Response('FAILED', 200); } }); $app->post('/companies/edit-approve-user', function (Request $request) { global $db; $id = $request->get('id'); // Bind the data $html = getModalEditApproveUser($id); return $html; }); $app->post('/companies/approve-user', function (Request $request) { global $db; $id = $request->get('id'); // Bind the data $html = getModalApproveUser($id); return $html; }); $app->post('/contacts/list', function(Request $request) { $curpage = $request->get('page'); include 'contact.list.php'; return ''; }); $app->get('/contacts/user-list', function(Request $request) { include 'user.list.php'; return ''; }); $app->get('/contacts', function() { global $hooks; $hooks->add_action('the_title',"contacts_title"); $hooks->add_action('global_css', "contacts_css"); $hooks->add_action('global_js', "contacts_js"); the_head(); include 'contact.tpl.php'; the_footer(); typeAhead(); return ""; }); $app->post('/companies/add-company', function (Request $request) { global $db; $friend_id = $request->get('id'); $company_id = getCompany($_SESSION['user_id']); $db->bind("friend_id", $friend_id); $db->bind("company_id", $company_id); // Bind the data $userReg = $db->query("INSERT INTO company_friend(friend_id,company_id) VALUES (:friend_id,:company_id)"); $db->bind("friend_id", $friend_id); $db->bind("company_id", $company_id); // Bind the data $userReg = $db->query("INSERT INTO company_friend(friend_id,company_id) VALUES (:company_id,:friend_id)"); if ($userReg) { return new Response("SUCCESS", 200); } else { return new Response('FAILED', 200); } }); $app->post('/companies/get-detail', function (Request $request) { global $db; $id = $request->get('id'); // Bind the data $html = getModalCompanies($id); return $html; }); $app->post('/companies/list', function(Request $request) { $curpage = $request->get('page'); include 'companies.list.php'; return ''; }); $app->get('/companies/company-list', function(Request $request) { include 'company.list.php'; return ''; }); $app->get('/companies', function() { global $hooks; $hooks->add_action('the_title',"contacts_title"); $hooks->add_action('global_css', "companies_css"); $hooks->add_action('global_js', "companies_js"); the_head(); include 'companies.tpl.php'; the_footer(); typeAhead(); return ""; }); }