PageRenderTime 63ms CodeModel.GetById 37ms RepoModel.GetById 0ms app.codeStats 0ms

/adminpanel/vendor.php

https://bitbucket.org/priyadarshan_salkar/thinkshaddi
PHP | 312 lines | 280 code | 25 blank | 7 comment | 82 complexity | a0bcf51823d4d1f0d40833ed1e473dba MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, AGPL-1.0
  1. <?php
  2. session_start();
  3. include('config.php');
  4. include_once 'email.php';
  5. if(!isset($_SESSION['uname']))
  6. {
  7. header('Location:login.php');
  8. }
  9. $orderBy= '';
  10. $page =1;
  11. $search = null;
  12. $dateError = 0;
  13. include_once 'classes/class.DatabaseI_System.php';
  14. include_once 'classes/class.user.php';
  15. include_once 'classes/class.Pagination.php';
  16. $mailCount = 0;
  17. $objUser = new User();
  18. if(isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete'){
  19. if(isset($_REQUEST['id']) && !empty($_REQUEST['id'])){
  20. $id = $_REQUEST['id'];
  21. $objUser->deleteVendor($id);
  22. }
  23. }
  24. if(isset($_POST['submit'])){
  25. //print_r($_POST['user-checkbox']);
  26. include_once 'phpmailer/class.phpmailer.php';
  27. $count = count($_POST['user-checkbox']);
  28. $subject = "Mail For Vendors";
  29. for($i=0;$i<$count;$i++){
  30. $mail = new PHPMailer(true);
  31. $email = $_POST['user-checkbox'][$i];
  32. $random = substr(number_format(time() * rand(),0,'',''),0,10);
  33. $url = "http://".$_SERVER['HTTP_HOST']."/vendor/register/".$random;
  34. $message = "You're one of the first vendors to be listed on Think Shaadi. We are still putting the final touches on the website and would love to hear your feedback.".chr(10).chr(13);
  35. $message .= "As a vendor on Think Shaadi you can list your images and videos and update your profile page at any time.".chr(10).chr(13);
  36. $message .= "Get started now ( ".$url." ) .".chr(10).chr(13);
  37. $message .= "Happy posting!".chr(10).chr(13);
  38. $message .= "XX".chr(10).chr(13);
  39. $message .= "The Think Shaadi team ".chr(10).chr(13);
  40. $mail->ContentType = 'text/plain';
  41. $mail->IsHTML(false);
  42. $mail->IsSMTP();
  43. $address = $_POST['user-checkbox'][$i];
  44. $mail->AddAddress($address);
  45. $mail->SetFrom('noreply@thinkshaadi.com','Think Shaadi');
  46. //$mail->AddReplyTo('');
  47. $mail->Subject = "You're in! ";
  48. //$mail->From = ;
  49. $mail->Body = $message;
  50. if($mail->Send()){
  51. $objUser->updateVendor($email,$random);
  52. $mailCount++;
  53. }
  54. }
  55. }
  56. if(isset($_REQUEST['search'])){
  57. if(isset($_REQUEST['dtfrm']) && !empty($_REQUEST['dtfrm']) && $_REQUEST['dtfrm'] != 'From Date'){
  58. $date = trim($_REQUEST['dtfrm']);
  59. $dateEx = explode('-',$date);
  60. if(count($dateEx) == 3){
  61. if((strlen($dateEx[1]) == 2 || strlen($dateEx[1]) == 1) && (strlen($dateEx[0]) == 2 || strlen($dateEx[0]) == 1) && strlen($dateEx[2]) == 4){
  62. if(checkdate($dateEx[1],$dateEx[0],$dateEx[2])){
  63. $from_date = $dateEx[2]."-".$dateEx[1]."-".$dateEx[0];
  64. $from = strtotime($from_date);
  65. }else{
  66. $dateError =1;
  67. }
  68. }else{
  69. $dateError =1;
  70. }
  71. }else{
  72. $dateError =1;
  73. }
  74. }
  75. if(isset($_REQUEST['dttill']) && !empty($_REQUEST['dttill']) && $_REQUEST['dttill'] != 'Till Date'){
  76. $date = trim($_REQUEST['dttill']);
  77. $dateEx = explode('-',$date);
  78. if(count($dateEx) == 3){
  79. if((strlen($dateEx[1]) == 2 || strlen($dateEx[1]) == 1) && (strlen($dateEx[0]) == 2 || strlen($dateEx[0]) == 1) && strlen($dateEx[2]) == 4){
  80. if(checkdate($dateEx[1],$dateEx[0],$dateEx[2])){
  81. $till_date = $dateEx[2]."-".$dateEx[1]."-".$dateEx[0];
  82. $till = strtotime($till_date);
  83. }else{
  84. $dateError =1;
  85. }
  86. }else{
  87. $dateError =1;
  88. }
  89. }else{
  90. $dateError =1;
  91. }
  92. }
  93. if($dateError == 0){
  94. if(isset($till) && isset($from) && $till >= $from){
  95. $search['date']['from'] = strip_tags(trim($from_date));
  96. $search['date']['till'] = strip_tags(trim($till_date));
  97. }elseif(isset($till)){
  98. $search['date']['from'] = '201-02-28';
  99. $search['date']['till'] = strip_tags(trim($till_date));
  100. }elseif(isset($from)){
  101. $search['date']['from'] = strip_tags(trim($from_date));
  102. $search['date']['till'] = date('Y-m-d');
  103. }
  104. }
  105. }
  106. $objUser = new User();
  107. $countRes = $objUser->get_vendor_form_count($search=NULL);
  108. if($countRes){
  109. $totalrows = $countRes->getNext();
  110. }else{
  111. $totalrows['total'] = 0;
  112. }
  113. $Pagination = new Pagination();
  114. $limit = $CONFIG->perpage ;
  115. if(isset($_GET['page']) && is_numeric(trim($_GET['page']))){$page = trim($_GET['page']);}else{$page = 1;}
  116. $startrow = $Pagination->getStartRow($page,$limit);
  117. //create page links
  118. if($CONFIG->showpagenumbers == true){
  119. $pagination_links = $Pagination->showPageNumbers($totalrows['total'],$page,$limit);
  120. }else{$pagination_links=null;}
  121. if($CONFIG->showprevnext == true){
  122. $prev_link = $Pagination->showPrev($totalrows['total'],$page,$limit);
  123. $next_link = $Pagination->showNext($totalrows['total'],$page,$limit);
  124. }else{$prev_link=null;$next_link=null;}
  125. if(isset($_GET['orderby']) && !empty($_GET['orderby'])){
  126. $orderBy = strip_tags(trim($_GET['orderby']));
  127. }else{
  128. $orderBy = '';
  129. }
  130. if(isset($_GET['sort']) && (trim($_GET['sort']) == "ASC" || trim($_GET['sort']) == "DESC")){
  131. $sort = strip_tags(trim($_GET['sort']));
  132. }else{
  133. $sort = "ASC";
  134. }
  135. if($totalrows['total'] > 0){
  136. $sampleRes = $objUser->get_vendor_form_details($limit,$startrow,$orderBy,$sort,$search);
  137. if($sampleRes === false){
  138. $sampleData = false;
  139. }else{
  140. $sampleData = $sampleRes->getResultToArray();
  141. }
  142. }else{
  143. $sampleData = false;
  144. }
  145. /*
  146. * To change this template, choose Tools | Templates
  147. * and open the template in the editor.
  148. */
  149. ?>
  150. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  151. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  152. <head>
  153. <title>Thinkshaadi</title>
  154. <script type="text/javascript" src="js/jquery-1.4.3.min.js"></script>
  155. <link rel="stylesheet" type="text/css" href="css/reset.css" />
  156. <link rel="stylesheet" type="text/css" href="css/style.css" />
  157. <script type="text/javascript" src="js/datetimepicker.js"></script>
  158. <script>
  159. $(document).ready(function(){
  160. $("a.delete").click(function(e){
  161. var r=confirm("Are you sure you want to delete this entry??")
  162. if(r == false){
  163. e.preventDefault();
  164. }
  165. });
  166. });
  167. </script>
  168. <!--[if IE 6]><link rel="stylesheet" type="text/css" href="assets/css/ie/ie6.css" /><![endif]-->
  169. </head>
  170. <body>
  171. <div id="wrapper">
  172. <div id="container">
  173. <h1>
  174. <img src="images/logo.png" title="XENON XT" />
  175. <span class="hiddenText">Tata-Xenon</span>
  176. </h1>
  177. <?php
  178. include_once "header.php";
  179. ?>
  180. <h2>
  181. Vendor Form
  182. </h2>
  183. <!--<form method="get">
  184. <ul class="searchContainer">
  185. <li><input type="text" name="dtfrm" id="dtfrm" value="<?php if(isset($_REQUEST['dtfrm'])){ echo $_REQUEST['dtfrm'];}else{ echo "From Date"; } ?>" /><a href="javascript:NewCal('dtfrm','ddmmyyyy')"><img class="calender" src="images/cal.gif" width="22" height="23" border="0" alt="Pick a Date"></a></li>
  186. <li><input type="text" name="dttill" id="dttill" value="<?php if(isset($_REQUEST['dttill'])){ echo $_REQUEST['dttill'];}else{ echo "To Date"; } ?>" /><a href="javascript:NewCal('dttill','ddmmyyyy')"><img class="calender" src="images/cal.gif" width="22" height="23" border="0" alt="Pick a Date"></a></li>
  187. <li class="btnSearch"><input title="Search" name="search" type="submit" value="Search" /></li>
  188. <li class="btnSearch"><input title="Reset" name="reset" type="button" value="Reset" onClick="location.href='index.php'" /></li>
  189. </ul>
  190. </form>-->
  191. <div class="eventWrapper">
  192. <div>
  193. <?php
  194. if(isset($_POST['submit']) && $mailCount > 0){
  195. echo "<p>Mail Sent to ".$mailCount." Vendor(s)</p>" ;
  196. }
  197. ?>
  198. </div>
  199. <div class="info">
  200. Please click on Business Name,Email Id to sort the content in ascending or descending order respectively.
  201. </div>
  202. <div>
  203. <form method="post" >
  204. <table class="eventDetails" id="eventTableSorter" cellpadding="0" cellspacing="0" border="1" width="100%">
  205. <thead>
  206. <tr>
  207. <th width="10" scope="col"><input type="checkbox" name="ucheckbox" id="user-checkbox" /></th>
  208. <th width="142" scope="col"><?php echo $Pagination->columnSortArrows('businessname','Business Name',$orderBy,$sort); ?></th>
  209. <th width="67" scope="col"><?php echo $Pagination->columnSortArrows('email','Email Id',$orderBy,$sort); ?></th>
  210. <th width="78" scope="col">Website</th>
  211. <th width="78" scope="col"><?php echo $Pagination->columnSortArrows('insertdatetime','Contact Date',$orderBy,$sort); ?></th>
  212. <th width="78" scope="col"><?php echo $Pagination->columnSortArrows('mailSentDateTime','Mail Sent Date',$orderBy,$sort); ?></th>
  213. <th width="78" scope="col">Delete</th>
  214. </tr>
  215. </thead>
  216. <tbody>
  217. <?php
  218. $recordsFound = false;
  219. if($sampleData) {
  220. $j=1;
  221. $recordsFound = true;
  222. for($i=0;$i<count($sampleData);$i++) {
  223. ?>
  224. <tr>
  225. <td><input type="checkbox" name="user-checkbox[]" value="<?php echo $sampleData[$i]['email']; ?>" /></td>
  226. <td><?php echo $sampleData[$i]['businessname']; ?></td>
  227. <td><?php echo $sampleData[$i]['email']; ?></td>
  228. <td><?php echo $sampleData[$i]['website']; ?></td>
  229. <td><?php echo $sampleData[$i]['datetime']; ?></td>
  230. <td><?php if(!empty($sampleData[$i]['randomNo']) && !is_null($sampleData[$i]['randomNo'])){ echo $sampleData[$i]['mailSentDateTime'] ;}else{ echo "-"; } ?></td>
  231. <td>
  232. <?php if(empty($sampleData[$i]['uid'])): ?>
  233. <a href="vendor.php?action=delete&id=<?php echo $sampleData[$i]['id']; ?>" class="delete">Delete</a>
  234. <?php endif; ?>
  235. </td>
  236. </tr>
  237. <?php $j++;}
  238. ?>
  239. <tr>
  240. <td align="left" valign="top" colspan="7">
  241. <input type="submit" name="submit" value="Send Mail" />
  242. </td>
  243. </tr>
  244. <?php
  245. } else { $recordsFound = false; ?>
  246. <tr>
  247. <td align="left" valign="top" colspan="7"><?php echo "No Record Found."; ?></td>
  248. </tr>
  249. <?php } ?>
  250. </tbody>
  251. </table>
  252. </form>
  253. </div>
  254. <?php
  255. if(!($prev_link==null && $next_link==null && $pagination_links==null)){
  256. echo '<div class="pagination">'."\n";
  257. echo $prev_link;
  258. echo $pagination_links;
  259. echo $next_link;
  260. echo '<div style="clear:both;"></div>'."\n";
  261. echo "</div>\n";
  262. }
  263. ?>
  264. <?php
  265. if($recordsFound){
  266. $query_string ='';
  267. if(!empty($_SERVER['QUERY_STRING'])){
  268. $query_string = eregi_replace("page=[0-9]{0,10}","",$_SERVER['QUERY_STRING']);
  269. }
  270. ?>
  271. <a href="export.php?type=vendor&<?php echo $query_string; ?>" title="Export to Excel file" class="btn_expExl">
  272. <img src="images/btn_exportToExl.gif" alt="Export to Excel file" />
  273. <span class="hiddenText">Export to Excel file</span>
  274. </a>
  275. <?php
  276. }
  277. ?>
  278. </div>
  279. </div>
  280. </div>
  281. </body>
  282. </html>