Blame view

account/admin/sms_tpl.php 2.84 KB
42868d70   andryeyev   Создал GIT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
  <?php 
  global $setup;
  
          echo"<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js' type='text/javascript'></script>";
  		echo'<script>
  		jQuery(document).ready(function(){
  		
  		$("#sms_c").html($("#sms_msg").val().length);
  w=120;
  $( "input[name=\'sms_type\']" ).click(function() { 
  	i = $("#sms_msg").val().length;
  	if(this.value=="l"){w=120;if(i>w){$("#sms_c").css( "color","red" );}else{$("#sms_c").css( "color","black" );}}
  	else{w=70;if(i>w){$("#sms_c").css( "color","red" );}else{$("#sms_c").css( "color","black" );}}
  	$("#sms_c_sum").html(w);
  	});
  $("#sms_c_sum").html(w);
  
  
  $("#sms_msg").keyup(function(){
        i = this.value.length;
  	  if(i>w){$("#sms_c").css( "color","red" );}
  	  else{$("#sms_c").css( "color","black" );}
        $("#sms_c").html(i);
   });
  
  				
  });  
  					</script>';			
  
  
  
  if(isset($_POST['title']) && isset($_POST['msg'])){
  	$table_name = "sms_tpl";
  	$DB_AUTOQUERY = ($_POST['update_id']>0) ? DB_AUTOQUERY_UPDATE : DB_AUTOQUERY_INSERT;
  	$fields_values = array('title'=>$_POST['title'],'msg'=>$_POST['msg']);
  	$setup->db->autoExecute($table_name,$fields_values,$DB_AUTOQUERY,"id={$_POST['update_id']}");
  	//header("location: /admin.php/sms_tpl/");
  	echo "<script language=\"JavaScript\">{ location.href=\"/admin.php/sms_tpl/\"; self.focus(); } </script>";
  }
  
  if(isset($_GET['delete_tpl_ID']) && $_GET['delete_tpl_ID']>0){
  	$setup->db->query("delete from sms_tpl where id=?",array($_GET['delete_tpl_ID']));
  }
  
  if(isset($_GET['updateID']) && $_GET['updateID']>0){
  	$row_tpl = $setup->db->getRow("select * from sms_tpl where id=?",array($_GET['updateID']),DB_FETCHMODE_ASSOC);
  }
  
  $res = $setup->db->getAll("select * from sms_tpl",array(),DB_FETCHMODE_ASSOC);
  print'<table cellpadding="5" cellspacing="1" bgcolor="#000000">';
  foreach($res as $row){
  	print"<tr bgcolor='#ffffff'>
  	<td width='250'>".$row['title']."</td>
  	<td><input type='button' class='submit_orange' value='Ðåäàêòèðîâàòü' onClick=\"document.location='/admin.php/sms_tpl/?updateID=".$row['id']."'\"></td>
  	<td><input type='button' class='submit_red' value='Óäàëèòü' onClick=\"del('/admin.php/sms_tpl/?delete_tpl_ID=".$row['id']."');\"></td>
  	</tr>";
  }
  print"</table><br /><br />";
  
  print "<h1>SMS øàáëîíû</h1>";
  print "<form method='post' action=''>";
  print "<input type='hidden' name='update_id' value='".$row_tpl['id']."' />";
  print "Íàçâàíèå øàáëîíà:<br />";
  print "<input type='text' name='title' size='60' value='".$row_tpl['title']."' /><br />";
  print "Òåêñò:";
  print "<br /><textarea cols='50' rows='4' name='msg' id='sms_msg'>".$row_tpl['msg']."</textarea>";
  print"<br /><input type='radio' name='sms_type' id='sms_type' value='l' checked />ëàòèíèöà <input type='radio' name='sms_type' id='sms_type' value='k' />êèðèëèöà  Êîëëè÷åñòâî ñèìâîëîâ <span id='sms_c'>0</span> (<span id='sms_c_sum'></span>)";
  print "<br /><input type='submit' value='Ñîõðàíèòü' />";
  print'</form>';
  ?>