PageRenderTime 61ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/admin/module_newsletter.php

https://github.com/tisoft/xtcmodified
PHP | 556 lines | 494 code | 8 blank | 54 comment | 41 complexity | 8a1db7aa17ad0af15dd0273bb0880ced MD5 | raw file
Possible License(s): AGPL-1.0, LGPL-2.1, GPL-2.0
  1. <?php
  2. /* --------------------------------------------------------------
  3. $Id$
  4. xtcModified - community made shopping
  5. http://www.xtc-modified.org
  6. Copyright (c) 2010 xtcModified
  7. --------------------------------------------------------------
  8. based on:
  9. (c) 2000-2001 The Exchange Project (earlier name of osCommerce)
  10. (c) 2002-2003 osCommercecoding standards www.oscommerce.com
  11. (c) 2003 nextcommerce (templates_boxes.php,v 1.14 2003/08/18); www.nextcommerce.org
  12. (c) 2006 xt:Commerce
  13. Released under the GNU General Public License
  14. --------------------------------------------------------------*/
  15. require('includes/application_top.php');
  16. require_once(DIR_FS_CATALOG.DIR_WS_CLASSES.'class.phpmailer.php');
  17. require_once(DIR_FS_INC . 'xtc_php_mail.inc.php');
  18. require_once(DIR_FS_INC . 'xtc_wysiwyg.inc.php');
  19. $action = (isset($_GET['action']) ? $_GET['action'] : '');
  20. if (xtc_not_null($action)) {
  21. switch ($action) { // actions for datahandling
  22. case 'save': // save newsletter
  23. $id=xtc_db_prepare_input((int)$_POST['ID']);
  24. $status_all=xtc_db_prepare_input($_POST['status_all']);
  25. $newsletter_title = xtc_db_prepare_input($_POST['title']); //DokuMan - 2010-11-13 - set newsletter_title properly
  26. if ($newsletter_title=='')
  27. $newsletter_title='no title';
  28. $customers_status=xtc_get_customers_statuses();
  29. $rzp='';
  30. for ($i=0,$n=sizeof($customers_status);$i<$n; $i++) {
  31. if (xtc_db_prepare_input($_POST['status'][$i])=='yes') {
  32. if ($rzp!='')
  33. $rzp.=',';
  34. $rzp.=$customers_status[$i]['id'];
  35. }
  36. }
  37. if (xtc_db_prepare_input($_POST['status_all'])=='yes')
  38. $rzp.=',all';
  39. $error=false; // reset error flag
  40. if ($error == false) {
  41. $sql_data_array = array('title'=> $newsletter_title,
  42. 'status' => '0',
  43. 'bc'=>$rzp,
  44. 'cc'=>xtc_db_prepare_input($_POST['cc']),
  45. 'date' => 'now()',
  46. 'body' => xtc_db_prepare_input($_POST['newsletter_body']));
  47. if ($id!='') {
  48. xtc_db_perform(TABLE_MODULE_NEWSLETTER, $sql_data_array, 'update', "newsletter_id = '" . $id . "'");
  49. // create temp table
  50. xtc_db_query("DROP TABLE IF EXISTS module_newsletter_temp_".$id);
  51. xtc_db_query("CREATE TABLE module_newsletter_temp_".$id."
  52. (
  53. id int(11) NOT NULL auto_increment,
  54. customers_id int(11) NOT NULL default '0',
  55. customers_status int(11) NOT NULL default '0',
  56. customers_firstname varchar(64) NOT NULL default '',
  57. customers_lastname varchar(64) NOT NULL default '',
  58. customers_email_address text NOT NULL,
  59. mail_key varchar(32) NOT NULL,
  60. date datetime NOT NULL default '0000-00-00 00:00:00',
  61. comment varchar(64) NOT NULL default '',
  62. PRIMARY KEY (id)
  63. )");
  64. } else {
  65. xtc_db_perform(TABLE_MODULE_NEWSLETTER, $sql_data_array);
  66. // create temp table
  67. $id=xtc_db_insert_id();
  68. xtc_db_query("DROP TABLE IF EXISTS module_newsletter_temp_".$id);
  69. xtc_db_query("CREATE TABLE module_newsletter_temp_".$id."
  70. (
  71. id int(11) NOT NULL auto_increment,
  72. customers_id int(11) NOT NULL default '0',
  73. customers_status int(11) NOT NULL default '0',
  74. customers_firstname varchar(64) NOT NULL default '',
  75. customers_lastname varchar(64) NOT NULL default '',
  76. customers_email_address text NOT NULL,
  77. mail_key varchar(32) NOT NULL,
  78. date datetime NOT NULL default '0000-00-00 00:00:00',
  79. comment varchar(64) NOT NULL default '',
  80. PRIMARY KEY (id)
  81. )");
  82. }
  83. // filling temp table with data!
  84. $flag='';
  85. if (!strpos($rzp,'all'))
  86. $flag='true';
  87. $rzp=str_replace(',all','',$rzp);
  88. $groups=explode(',',$rzp);
  89. $sql_data_array='';
  90. for ($i=0,$n=sizeof($groups);$i<$n;$i++) {
  91. // check if customer wants newsletter
  92. if (xtc_db_prepare_input($_POST['status_all'])=='yes') {
  93. $customers_query=xtc_db_query("SELECT
  94. customers_id,
  95. customers_firstname,
  96. customers_lastname,
  97. customers_email_address
  98. FROM ".TABLE_CUSTOMERS."
  99. WHERE customers_status='".$groups[$i]."'");
  100. } else {
  101. $customers_query=xtc_db_query("SELECT
  102. customers_email_address,
  103. customers_id,
  104. customers_firstname,
  105. customers_lastname,
  106. mail_key
  107. FROM ".TABLE_NEWSLETTER_RECIPIENTS."
  108. WHERE customers_status='".$groups[$i]."'
  109. AND mail_status='1'");
  110. }
  111. while ($customers_data=xtc_db_fetch_array($customers_query)){
  112. $sql_data_array=array(
  113. 'customers_id'=>$customers_data['customers_id'],
  114. 'customers_status'=>$groups[$i],
  115. 'customers_firstname'=>$customers_data['customers_firstname'],
  116. 'customers_lastname'=>$customers_data['customers_lastname'],
  117. 'customers_email_address'=>$customers_data['customers_email_address'],
  118. 'mail_key'=>$customers_data['mail_key'],
  119. 'date'=>'now()');
  120. xtc_db_perform('module_newsletter_temp_'.$id, $sql_data_array);
  121. }
  122. }
  123. xtc_redirect(xtc_href_link(FILENAME_MODULE_NEWSLETTER));
  124. }
  125. break;
  126. case 'delete':
  127. xtc_db_query("DELETE FROM ".TABLE_MODULE_NEWSLETTER." WHERE newsletter_id='".(int)$_GET['ID']."'");
  128. xtc_redirect(xtc_href_link(FILENAME_MODULE_NEWSLETTER));
  129. break;
  130. case 'send':
  131. // max email package -> should be in admin area!
  132. $package_size='30';
  133. xtc_redirect(xtc_href_link(FILENAME_MODULE_NEWSLETTER,'send=0,'.$package_size.'&ID='.(int)$_GET['ID']));
  134. }
  135. }
  136. // action for sending mails!
  137. if (isset($_GET['send'])) {
  138. $limits=explode(',',$_GET['send']);
  139. $limit_low = $limits['0'];
  140. $limit_up = $limits['1'];
  141. $limit_query=xtc_db_query("SELECT count(*) as count
  142. FROM module_newsletter_temp_".(int)$_GET['ID']."
  143. ");
  144. $limit_data=xtc_db_fetch_array($limit_query);
  145. // select emailrange from db
  146. $email_query=xtc_db_query("SELECT
  147. customers_firstname,
  148. customers_lastname,
  149. customers_email_address,
  150. mail_key ,
  151. id
  152. FROM module_newsletter_temp_".(int)$_GET['ID']."
  153. LIMIT ".$limit_low.",".$limit_up);
  154. $email_data=array();
  155. while ($email_query_data=xtc_db_fetch_array($email_query)) {
  156. $email_data[]=array('id' => $email_query_data['id'],
  157. 'firstname'=>$email_query_data['customers_firstname'],
  158. 'lastname'=>$email_query_data['customers_lastname'],
  159. 'email'=>$email_query_data['customers_email_address'],
  160. 'key'=>$email_query_data['mail_key']);
  161. }
  162. // ok lets send the mails in package of 30 mails, to prevent php timeout
  163. $package_size='30';
  164. $break='0';
  165. if ($limit_data['count']<$limit_up) {
  166. $limit_up=$limit_data['count'];
  167. $break='1';
  168. }
  169. $max_runtime=$limit_up-$limit_low;
  170. $newsletters_query=xtc_db_query("SELECT
  171. title,
  172. body,
  173. bc,
  174. cc
  175. FROM ".TABLE_MODULE_NEWSLETTER."
  176. WHERE newsletter_id='".(int)$_GET['ID']."'");
  177. $newsletters_data=xtc_db_fetch_array($newsletters_query);
  178. // if ($newsletters_data['cc']!='') {
  179. // xtc_php_mail(EMAIL_SUPPORT_ADDRESS,
  180. // EMAIL_SUPPORT_NAME,
  181. // $newsletters_data['cc'],
  182. // '' ,
  183. // '',
  184. // EMAIL_SUPPORT_REPLY_ADDRESS,
  185. // EMAIL_SUPPORT_REPLY_ADDRESS_NAME,
  186. // '',
  187. // '',
  188. // $newsletters_data['title'],
  189. // $newsletters_data['body'],
  190. // $newsletters_data['body']);
  191. // }
  192. for ($i=1;$i<=$max_runtime;$i++) {
  193. // mail
  194. $link1 = chr(13).chr(10).chr(13).chr(10).TEXT_NEWSLETTER_REMOVE.chr(13).chr(10).chr(13).chr(10).HTTP_CATALOG_SERVER.DIR_WS_CATALOG.FILENAME_CATALOG_NEWSLETTER.'?action=remove&email='.$email_data[$i-1]['email'].'&key='.$email_data[$i-1]['key'];
  195. $link2 = $link2 = '<br /><br /><hr>'.TEXT_NEWSLETTER_REMOVE.'<br /><a href="'.HTTP_CATALOG_SERVER.DIR_WS_CATALOG.FILENAME_CATALOG_NEWSLETTER.'?action=remove&email='.$email_data[$i-1]['email'].'&key='.$email_data[$i-1]['key'].'">' . TEXT_REMOVE_LINK . '</a>';
  196. xtc_php_mail(EMAIL_SUPPORT_ADDRESS,
  197. EMAIL_SUPPORT_NAME,
  198. $email_data[$i-1]['email'] ,
  199. $email_data[$i-1]['lastname'] . ' ' . $email_data[$i-1]['firstname'] ,
  200. '',
  201. EMAIL_SUPPORT_REPLY_ADDRESS,
  202. EMAIL_SUPPORT_REPLY_ADDRESS_NAME,
  203. '',
  204. '',
  205. $newsletters_data['title'],
  206. $newsletters_data['body'].$link2,
  207. $newsletters_data['body'].$link1);
  208. xtc_db_query("UPDATE module_newsletter_temp_".(int)$_GET['ID']." SET comment='send' WHERE id='".$email_data[$i-1]['id']."'");
  209. }
  210. if ($break=='1') {
  211. // finished
  212. $limit1_query=xtc_db_query("SELECT count(*) as count
  213. FROM module_newsletter_temp_".(int)$_GET['ID']."
  214. WHERE comment='send'");
  215. $limit1_data=xtc_db_fetch_array($limit1_query);
  216. if ($limit1_data['count']-$limit_data['count']<=0) {
  217. xtc_db_query("UPDATE ".TABLE_MODULE_NEWSLETTER." SET status='1' WHERE newsletter_id='".(int)$_GET['ID']."'");
  218. xtc_redirect(xtc_href_link(FILENAME_MODULE_NEWSLETTER));
  219. } else {
  220. echo '<b>'.$limit1_data['count'].'<b> emails send<br />';
  221. echo '<b>'.$limit1_data['count']-$limit_data['count'].'<b> emails left';
  222. }
  223. } else {
  224. $limit_low=$limit_up+1;
  225. $limit_up=$limit_low+$package_size;
  226. xtc_redirect(xtc_href_link(FILENAME_MODULE_NEWSLETTER,'send='.$limit_low.','.$limit_up.'&ID='.(int)$_GET['ID']));
  227. }
  228. }
  229. ?>
  230. <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
  231. <html <?php echo HTML_PARAMS; ?>>
  232. <head>
  233. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $_SESSION['language_charset']; ?>" />
  234. <title><?php echo TITLE; ?></title>
  235. <link rel="stylesheet" type="text/css" href="includes/stylesheet.css" />
  236. <?php
  237. if (USE_WYSIWYG=='true') {
  238. $query=xtc_db_query("SELECT code FROM ". TABLE_LANGUAGES ." WHERE languages_id='".$_SESSION['languages_id']."'");
  239. $data=xtc_db_fetch_array($query);
  240. if ($action !='')
  241. echo xtc_wysiwyg('newsletter',$data['code']);
  242. }
  243. ?>
  244. </head>
  245. <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
  246. <!-- header //-->
  247. <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
  248. <!-- header_eof //-->
  249. <!-- body //-->
  250. <table border="0" width="100%" cellspacing="2" cellpadding="2">
  251. <tr>
  252. <td class="columnLeft2" width="<?php echo BOX_WIDTH; ?>" valign="top">
  253. <table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
  254. <!-- left_navigation //-->
  255. <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
  256. <!-- left_navigation_eof //-->
  257. </table>
  258. </td>
  259. <!-- body_text //-->
  260. <td width="100%" valign="top">
  261. <table border="0" width="100%" cellspacing="0" cellpadding="0">
  262. <tr>
  263. <td>
  264. <table border="0" width="100%" cellspacing="0" cellpadding="0">
  265. <tr>
  266. <td width="80" rowspan="2"><?php echo xtc_image(DIR_WS_ICONS.'heading_news.gif'); ?></td>
  267. <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
  268. </tr>
  269. <tr>
  270. <td class="main" valign="top">XTC Tools</td>
  271. </tr>
  272. </table>
  273. </td>
  274. </tr>
  275. <?php
  276. if (isset($_GET['send'])) {
  277. //DokuMan - set undefined index
  278. ?>
  279. <tr>
  280. <td>Sending</td>
  281. </tr>
  282. <?php
  283. }
  284. ?>
  285. <tr>
  286. <td>
  287. <table width="100%" border="0">
  288. <tr>
  289. <td>
  290. <?php
  291. // Default seite
  292. switch ($action) {
  293. default:
  294. // Get Customers Groups
  295. $customer_group_query=xtc_db_query("SELECT
  296. customers_status_name,
  297. customers_status_id,
  298. customers_status_image
  299. FROM ".TABLE_CUSTOMERS_STATUS."
  300. WHERE language_id='".$_SESSION['languages_id']."'");
  301. $customer_group=array();
  302. while ($customer_group_data=xtc_db_fetch_array($customer_group_query)) {
  303. // get single users
  304. $group_query=xtc_db_query("SELECT count(*) as count
  305. FROM ".TABLE_NEWSLETTER_RECIPIENTS."
  306. WHERE mail_status='1' and
  307. customers_status='".$customer_group_data['customers_status_id']."'");
  308. $group_data=xtc_db_fetch_array($group_query);
  309. $customer_group[]=array('ID'=>$customer_group_data['customers_status_id'],
  310. 'NAME'=>$customer_group_data['customers_status_name'],
  311. 'IMAGE'=>$customer_group_data['customers_status_image'],
  312. 'USERS'=>$group_data['count']);
  313. }
  314. ?>
  315. <br />
  316. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  317. <tr>
  318. <td>
  319. <table border="0" width="100%" cellspacing="0" cellpadding="2">
  320. <tr class="dataTableHeadingRow">
  321. <td class="dataTableHeadingContent" width="150" ><?php echo TITLE_CUSTOMERS; ?></td>
  322. <td class="dataTableHeadingContent" ><?php echo TITLE_STK; ?></td>
  323. </tr>
  324. <?php
  325. for ($i=0,$n=sizeof($customer_group); $i<$n; $i++) {
  326. ?>
  327. <tr>
  328. <td class="dataTableContent" style="border-bottom: 1px solid; border-color: #f1f1f1;" valign="middle" align="left"><?php echo xtc_image(DIR_WS_ICONS . $customer_group[$i]['IMAGE'], ''); ?><?php echo $customer_group[$i]['NAME']; ?></td>
  329. <td class="dataTableContent" style="border-bottom: 1px solid; border-color: #f1f1f1;" align="left"><?php echo $customer_group[$i]['USERS']; ?></td>
  330. </tr>
  331. <?php
  332. }
  333. ?>
  334. </table>
  335. </td>
  336. <td width="30%" align="right" valign="top"">
  337. <?php
  338. echo '<a class="button" href="'.xtc_href_link(FILENAME_MODULE_NEWSLETTER,'action=new').'">'.BUTTON_NEW_NEWSLETTER.'</a>';
  339. ?>
  340. </td>
  341. </tr>
  342. </table>
  343. <br />
  344. <?php
  345. // get data for newsletter overwiev
  346. $newsletters_query=xtc_db_query("SELECT
  347. newsletter_id,date,title
  348. FROM ".TABLE_MODULE_NEWSLETTER."
  349. WHERE status='0'");
  350. $news_data=array();
  351. while ($newsletters_data=xtc_db_fetch_array($newsletters_query)) {
  352. $news_data[]=array('id' =>$newsletters_data['newsletter_id'],
  353. 'date'=>$newsletters_data['date'],
  354. 'title'=>$newsletters_data['title']);
  355. }
  356. ?>
  357. <table border="0" width="100%" cellspacing="0" cellpadding="2">
  358. <tr class="dataTableHeadingRow">
  359. <td class="dataTableHeadingContent" width="30" ><?php echo TITLE_DATE; ?></td>
  360. <td class="dataTableHeadingContent" width="80%" ><?php echo TITLE_NOT_SEND; ?></td>
  361. <td class="dataTableHeadingContent">&nbsp;</td>
  362. </tr>
  363. <?php
  364. for ($i=0,$n=sizeof($news_data); $i<$n; $i++) {
  365. if ($news_data[$i]['id']!='') {
  366. ?>
  367. <tr>
  368. <td class="dataTableContent" style="border-bottom: 1px solid; border-color: #f1f1f1;" align="left"><?php echo $news_data[$i]['date']; ?></td>
  369. <td class="dataTableContent" style="border-bottom: 1px solid; border-color: #f1f1f1;" valign="middle" align="left"><?php echo xtc_image(DIR_WS_CATALOG.'images/icons/arrow.gif'); ?><a href="<?php echo xtc_href_link(FILENAME_MODULE_NEWSLETTER,'ID='.$news_data[$i]['id']); ?>"><b><?php echo $news_data[$i]['title']; ?></b></a></td>
  370. <td class="dataTableContent" style="border-bottom: 1px solid; border-color: #f1f1f1;" align="left"></td>
  371. </tr>
  372. <?php
  373. if (isset($_GET['ID']) && $_GET['ID']!='' && $_GET['ID']==$news_data[$i]['id']) {
  374. $total_query=xtc_db_query("SELECT
  375. count(*) as count
  376. FROM module_newsletter_temp_".(int)$_GET['ID']."");
  377. $total_data=xtc_db_fetch_array($total_query);
  378. ?>
  379. <tr>
  380. <td class="dataTableContent_products" style="border-bottom: 1px solid; border-color: #f1f1f1;" align="left"></td>
  381. <td colspan="2" class="dataTableContent_products" style="border-bottom: 1px solid; border-color: #f1f1f1;" align="left"><?php echo TEXT_SEND_TO.$total_data['count']; ?></td>
  382. </tr>
  383. <tr>
  384. <td class="dataTableContent" valign="top" style="border-bottom: 1px solid; border-color: #999999;" align="left">
  385. <a class="button" href="<?php echo xtc_href_link(FILENAME_MODULE_NEWSLETTER,'action=delete&ID='.$news_data[$i]['id']); ?>" onclick="return confirm('<?php echo CONFIRM_DELETE; ?>')"><?php echo BUTTON_DELETE.'</a><br />'; ?>
  386. <a class="button" href="<?php echo xtc_href_link(FILENAME_MODULE_NEWSLETTER,'action=edit&ID='.$news_data[$i]['id']); ?>"><?php echo BUTTON_EDIT.'</a>'; ?>
  387. <br /><br /><div style="height: 1px; background: Black; margin: 3px 0;"></div>
  388. <a class="button" href="<?php echo xtc_href_link(FILENAME_MODULE_NEWSLETTER,'action=send&ID='.$news_data[$i]['id']); ?>"><?php echo BUTTON_SEND.'</a>'; ?>
  389. </td>
  390. <td colspan="2" class="dataTableContent" style="border-bottom: 1px solid; border-color: #999999; text-align: left;">
  391. <?php
  392. // get data
  393. $newsletters_query=xtc_db_query("SELECT
  394. title,body,cc,bc
  395. FROM ".TABLE_MODULE_NEWSLETTER."
  396. WHERE newsletter_id='".(int)$_GET['ID']."'");
  397. $newsletters_data=xtc_db_fetch_array($newsletters_query);
  398. echo TEXT_TITLE.$newsletters_data['title'].'<br />';
  399. $customers_status=xtc_get_customers_statuses();
  400. for ($i=0,$n=sizeof($customers_status);$i<$n; $i++) {
  401. $newsletters_data['bc']=str_replace($customers_status[$i]['id'],$customers_status[$i]['text'],$newsletters_data['bc']);
  402. }
  403. echo TEXT_TO.$newsletters_data['bc'].'<br />';
  404. echo TEXT_CC.$newsletters_data['cc'].'<br /><br />'.TEXT_PREVIEW;
  405. echo '<table style="border-color: #cccccc; border: 1px solid;" width="100%"><tr><td>'.$newsletters_data['body'].'</td></tr></table>';
  406. ?>
  407. </td>
  408. </tr>
  409. <?php
  410. }
  411. }
  412. }
  413. ?>
  414. </table>
  415. <br /><br />
  416. <?php
  417. $newsletters_query=xtc_db_query("SELECT
  418. newsletter_id,date,title
  419. FROM ".TABLE_MODULE_NEWSLETTER."
  420. WHERE status='1'");
  421. $news_data=array();
  422. while ($newsletters_data=xtc_db_fetch_array($newsletters_query)) {
  423. $news_data[]=array('id' => $newsletters_data['newsletter_id'],
  424. 'date'=>$newsletters_data['date'],
  425. 'title'=>$newsletters_data['title']);
  426. }
  427. ?>
  428. <table border="0" width="100%" cellspacing="0" cellpadding="2">
  429. <tr class="dataTableHeadingRow">
  430. <td class="dataTableHeadingContent" width="80%" ><?php echo TITLE_SEND; ?></td>
  431. <td class="dataTableHeadingContent"><?php echo TITLE_ACTION; ?></td>
  432. </tr>
  433. <?php
  434. for ($i=0,$n=sizeof($news_data); $i<$n; $i++) {
  435. if ($news_data[$i]['id']!='') {
  436. ?>
  437. <tr>
  438. <td class="dataTableContent" style="border-bottom: 1px solid; border-color: #f1f1f1;" valign="middle" align="left"><?php echo $news_data[$i]['date'].' '; ?><b><?php echo $news_data[$i]['title']; ?></b></td>
  439. <td class="dataTableContent" style="border-bottom: 1px solid; border-color: #f1f1f1;" align="left">
  440. <?php /*BOF - Tomcraft - 2009-06-10 - added some missing alternative text on admin icons/*
  441. /*
  442. <a href="<?php echo xtc_href_link(FILENAME_MODULE_NEWSLETTER,'action=delete&ID='.$news_data[$i]['id']); ?>" onclick="return confirm('<?php echo CONFIRM_DELETE; ?>')">
  443. <?php
  444. echo xtc_image(DIR_WS_ICONS.'delete.gif','Delete','','','style="cursor:pointer" onclick="return confirm(\''.DELETE_ENTRY.'\')"').' '.TEXT_DELETE.'</a>&nbsp;&nbsp;';
  445. ?>
  446. <a href="<?php echo xtc_href_link(FILENAME_MODULE_NEWSLETTER,'action=edit&ID='.$news_data[$i]['id']); ?>">
  447. <?php echo xtc_image(DIR_WS_ICONS.'icon_edit.gif','Edit','','').' '.TEXT_EDIT.'</a>'; ?>
  448. */
  449. ?>
  450. <a href="<?php echo xtc_href_link(FILENAME_MODULE_NEWSLETTER,'action=edit&ID='.$news_data[$i]['id']); ?>">
  451. <?php
  452. echo xtc_image(DIR_WS_ICONS.'icon_edit.gif', ICON_EDIT,'','').' '.TEXT_EDIT;
  453. echo '</a>';
  454. ?>
  455. <a href="<?php echo xtc_href_link(FILENAME_MODULE_NEWSLETTER,'action=delete&ID='.$news_data[$i]['id']); ?>" onclick="return confirm('<?php echo CONFIRM_DELETE; ?>')">
  456. <?php
  457. echo xtc_image(DIR_WS_ICONS.'delete.gif', ICON_DELETE,'','','style="cursor:pointer" onclick="return confirm(\''.DELETE_ENTRY.'\')"').' '.TEXT_DELETE;
  458. echo '</a>&nbsp;&nbsp;';
  459. ?>
  460. <?php /*EOF - Tomcraft - 2009-06-10 - added some missing alternative text on admin icons*/ ?>
  461. </td>
  462. </tr>
  463. <?php
  464. }
  465. }
  466. ?>
  467. </table>
  468. <?php
  469. break; // end default page
  470. case 'edit':
  471. $newsletters_query=xtc_db_query("SELECT title,body,cc,bc FROM ".TABLE_MODULE_NEWSLETTER." WHERE newsletter_id='".(int)$_GET['ID']."'");
  472. $newsletters_data=xtc_db_fetch_array($newsletters_query);
  473. case 'safe':
  474. case 'new': // action for NEW newsletter!
  475. $customers_status=xtc_get_customers_statuses();
  476. echo xtc_draw_form('edit_newsletter',FILENAME_MODULE_NEWSLETTER,'action=save','post','enctype="multipart/form-data"').xtc_draw_hidden_field('ID',$_GET['ID']);
  477. ?>
  478. <br /><br />
  479. <table class="main" width="100%" border="0">
  480. <tr>
  481. <td width="10%"><?php echo TEXT_TITLE; ?></td>
  482. <td width="90%"><?php echo xtc_draw_input_field('title',isset($newsletters_data['title']) ? $newsletters_data['title'] : '','size=100'); ?></td>
  483. </tr>
  484. <tr>
  485. <td width="10%"><?php echo TEXT_TO; ?></td>
  486. <td width="90%">
  487. <?php
  488. for ($i=0,$n=sizeof($customers_status);$i<$n; $i++) {
  489. $group_query=xtc_db_query("SELECT count(*) as count
  490. FROM ".TABLE_NEWSLETTER_RECIPIENTS."
  491. WHERE mail_status='1'
  492. AND customers_status='".$customers_status[$i]['id']."'");
  493. $group_data=xtc_db_fetch_array($group_query);
  494. $group_query=xtc_db_query("SELECT count(*) as count
  495. FROM ".TABLE_CUSTOMERS."
  496. WHERE customers_status='".$customers_status[$i]['id']."'");
  497. $group_data_all=xtc_db_fetch_array($group_query);
  498. $bc_array = explode(',', isset($newsletters_data['bc']) ? $newsletters_data['bc'] : ''); //DokuMan - set undefined index
  499. echo xtc_draw_checkbox_field('status['.$i.']','yes', in_array($customers_status[$i]['id'], $bc_array)).' '.$customers_status[$i]['text'].' <i>(<b>'.$group_data['count'].'</b>'.TEXT_USERS.$group_data_all['count'].TEXT_CUSTOMERS.'<br />';
  500. }
  501. echo xtc_draw_checkbox_field('status_all', 'yes',in_array('all', $bc_array)).' <b>'.TEXT_NEWSLETTER_ONLY.'</b>';
  502. ?>
  503. </td>
  504. </tr>
  505. <tr>
  506. <td width="10%"><?php echo TEXT_CC; ?></td>
  507. <td width="90%">
  508. <?php
  509. echo xtc_draw_input_field('cc',isset($newsletters_data['cc']) ? $newsletters_data['cc'] : '','size=100');
  510. ?>
  511. </td>
  512. </tr>
  513. <tr>
  514. <td width="10%" valign="top"><?php echo TEXT_BODY; ?></td>
  515. <td width="90%">
  516. <?php
  517. echo xtc_draw_textarea_field('newsletter_body', 'soft', '150', '45', stripslashes(isset($newsletters_data['body']) ? $newsletters_data['body'] : ''));
  518. ?>
  519. </td>
  520. </tr>
  521. </table>
  522. <a class="button" onclick="this.blur();" href="<?php echo xtc_href_link(FILENAME_MODULE_NEWSLETTER); ?>"><?php echo BUTTON_BACK; ?></a>
  523. <right><?php echo '<input type="submit" class="button" onclick="this.blur();" value="' . BUTTON_SAVE . '"/>'; ?></right>
  524. </form>
  525. <?php
  526. break;
  527. } // end switch
  528. ?>
  529. </td>
  530. </tr>
  531. </table>
  532. </td>
  533. </tr>
  534. </table>
  535. </td>
  536. <!-- body_text_eof //-->
  537. </tr>
  538. </table>
  539. <!-- body_eof //-->
  540. <!-- footer //-->
  541. <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
  542. <!-- footer_eof //-->
  543. </body>
  544. </html>
  545. <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>