Jump to content
Tseka85

Вызов функции нажатием кнопки в админке

Recommended Posts

Добрый день , есть  в admin\model\module файл smsclub.php с кодом :

Спойлер



<?php

class ModelModuleSmsclub extends Model {


	public function sendsms() {


		$url = 'https://';

	    $username = '***************';    // string User ID (phone number)

	    $password = '**************';        // string Password

	    $from = '******************';        // string, sender id (alpha-name) (as long as your alpha-name is not spelled out, it is necessary to use it)

	    $to = '*****************';

	    $text = iconv('utf-8','windows-1251', 'СМС через HTTP-шлюз от SMS CLUB');

	    $text = urlencode($text);       // string Message

	    $url_result = $url.'username='.$username.'&password='.$password.'&from='.urlencode($from).'&to='.$to.'&text='.$text;

	    

	    if($curl = curl_init())

	    {

	        curl_setopt($curl, CURLOPT_URL, $url_result);

	        curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);

	        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);

	        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

	        $out = curl_exec($curl);

	        echo $out;

	        curl_close($curl);

	   }

	}

   

}

	

?>


 

есть  в admin\controller\module файл smsclub.php с кодом :


 

Спойлер

 

 


<?php



class ControllerModuleSmsclub extends Controller {

	   
    public function sendsms() {

	   
		$this->load->model('module/smsclub');
        		
        $data['send_sms'] = $this->model_module_smsclub->sendsms();
        
               
    }

    

}
     


 

и есть  в  /admin/view/template/sale файл order_list.tpl с кодом :

Спойлер



 <div class="form-group">
                <label class="control-label" for="input-customer"><?php echo $entry_customer; ?></label>
                <input type="text" name="filter_customer" value="<?php echo $filter_customer; ?>" placeholder="<?php echo $entry_customer; ?>" id="input-customer" class="form-control" />
              </div>
               <button type="button" id="button-send_sms" form="form-order" formaction="<?php echo $send_sms; ?>" data-toggle="tooltip" title="<?php echo $send_sms; ?>" class="btn btn-primary"><i class="fa fa-envelope-o"></i>Отправить СМС</button>   
            </div>



$('#button-send_sms').on('click', function(e) {
  $('#form-order').attr('action', this.getAttribute('formAction'));

  if (confirm('<?php echo $text_confirm; ?>')) {
    $('#form-order').submit();
  } else {
    return false;
  }
});


 

Что я не так сделал , почему при нажатие на кнопку button-send_sms у меня не срабатывает функция sendsms()

Edited by Tseka85

Share this post


Link to post
Share on other sites
2 минуты назад, Tseka85 сказал:

Что я не так сделал

все

 

аякс запрос надо делать в tpl

 

посмотрите например как история заказа добавляется

Share this post


Link to post
Share on other sites
17 часов назад, spectre сказал:

все

 

аякс запрос надо делать в tpl

 

посмотрите например как история заказа добавляется

 Спасибо , понял направление . 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

On our site, cookies are used and personal data is processed to improve the user interface. To find out what and what personal data we are processing, please go to the link. If you click "I agree," it means that you understand and accept all the conditions specified in this Privacy Notice.