Ir para conteúdo

Pesquisar na Comunidade

Mostrando resultados para as tags ''php cron''.

  • Pesquisar por Tags

    Digite tags separadas por vírgulas
  • Pesquisar por Autor

Tipo de Conteúdo


Todas as áreas do Fórum

  • Q&A Desenvolvimento
    • Perguntas e respostas rápidas
  • Desenvolvimento Web
    • Desenvolvimento frontend
    • Javascript
    • PHP
    • Ruby
    • Python
    • Java
    • .NET
    • Docker, Kubernets e outros ambientes
    • Desenvolvimento com Wordpress
    • Desenvolvimento de apps
    • Desenvolvimento ágil
    • Desenvolvimento de Games
    • Banco de Dados
    • Design e UX
    • Algoritmos & Outras Tecnologias
  • Entretenimento e uso pessoal
    • Segurança & Malwares
    • Geral
    • Boteco iMasters

Encontrar resultados em...

Encontrar resultados que...


Data de Criação

  • Início

    FIM


Data de Atualização

  • Início

    FIM


Filtrar pelo número de...

Data de Registro

  • Início

    FIM


Grupo


Google+


Hangouts


Skype


Twitter


deviantART


Github


Flickr


LinkedIn


Pinterest


Facebook


Site Pessoal


Localização


Interesses

Encontrado 1 registro

  1. gerenciati

    Script php cron

    Pessoal boa tarde preciso de uma ajuda, neste script abaixo necessito mudar para enviar email somente na data de vencimento e registro do cliente. Exemplo cliente 1 data de registro 12 de outubro de 1982, preciso que este script chame todos pelas data de registro (dia) que foi registrado no sistema. todos do dia 12, todos do dia 13, todos do dia 14 etc... <?php /** * Created by PhpStorm. * User: webmaster * Date: 03/02/16 * Time: 22:50 */ class Cron extends CI_Controller { public function __construct() { parent::__construct(); setlocale(LC_ALL, 'pt_BR', 'pt_BR.utf-8', 'pt_BR.utf-8', 'portuguese'); date_default_timezone_set('America/Sao_Paulo'); } public function index() { echo 'index'; } // public function mensalidades() // { // // $this->db->select('*'); // //$this->db->select_max('data_vencimento'); // $this->db->from('socio a'); // $this->db->join('contasareceber b', 'a.id_socio = b.id_cliente'); // $this->db->where('a.tipo', 'P'); // $this->db->where('a.situacao', 'A'); // $this->db->where('b.flag', 'mensalidade'); // //$this->db->where('b.checked',0); // $this->db->where('month(b.data_vencimento)', date('m')); // $this->db->where('year(b.data_vencimento)', date('Y')); $this->db->where('day(b.data_vencimento)', date('D')); // $this->db->order_by('b.data_vencimento', 'DESC'); // //$this->db->limit(1); // // // $query = $this->db->get(); // // //var_dump($query->result()); // // // if ($query->num_rows() == 0) { // echo('Nenhum dado foi encontrado para exibir ou gerar mensalidade hoje'); // exit; // } // // foreach ($query->result() as $row) { // // echo '<pre>'; // echo $row->nome_socio; // echo '<br>'; // echo 'Vencimento:' . date('d-m-Y', strtotime($row->data_vencimento)); // echo '<br>'; // // $nextMonth = date('d-m-Y', strtotime("$row->data_vencimento +1 month")); // $nextMonthDate = date('Y-m-d', strtotime("$row->data_vencimento +1 month")); // // echo 'Proxima mensalidade : ' . $nextMonth; // echo '<hr>'; // // echo '</pre>'; // // echo '<br>'; // // $mes_vencimento = date('m', strtotime($row->data_vencimento)); // $mes_atual = date('m'); // // $data = array('checked' => 1); // // $this->db->where('id', $row->id); // $this->db->update('contasareceber', $data); // // echo '<br>'; // echo $row->checked; // // if ($row->checked == 0) { // // /** inserir nova mensalidade **/ // // // DB TIPO DE RECEITA // $this->db->select('*'); // $this->db->from('categoria'); // //$this->db->where('cat_id',40); // $this->db->like('cat_nome', 'mensalidade'); // $categoria = $this->db->get()->row(); // // // FORMA DE PAGAMENTO // $this->db->select('*'); // $this->db->from('financeiro_forma_pagamento'); // //$this->db->where('cat_id',40); // $this->db->like('nome_forma_pagamento', 'dinheiro'); // $pagamento = $this->db->get()->row(); // // $data_fatura = array( // 'id_cliente' => $row->id_socio, // 'cliente' => $row->nome_socio, // 'valor' => $categoria->cat_valor, // 'forma_pagamento' => $pagamento->id_forma_pagamento, // 'situacao_pagamento' => 'PD', // 'data_vencimento' => $nextMonthDate, // 'data_emissao' => date('Y-m-d'), // 'categoria' => $categoria->cat_id, // 'parcela' => 1, // 'dia_pagamento' => 10, // 'flag' => 'mensalidade' // ); // // echo '<pre>'; // print_r($data_fatura); // echo '</pre>'; // // $save = $this->db->insert('contasareceber', $data_fatura); // // } // // } // // } public function emailMensalidade() { //echo '<b style="color: gray;"> => Action Send Invoice Email </b>'; /** Email de notificação**/ $config['protocol'] = 'smtp'; $config['smtp_host'] = 'mail.dominio.com'; $config['smtp_port'] = '587'; $config['smtp_user'] = 'comunicados@dominio.com'; $config['smtp_pass'] = 'Z_tRtKjkil[7'aqsqsqsq; $config['mailtype'] = 'html'; $config['charset'] = 'UTF-8'; $config['wordwrap'] = TRUE; $config['newline'] = "\r\n"; //use double quotes to comply with RFC 822 standard $this->email->initialize($config); $this->db->select('*'); //$this->db->select_max('data_vencimento'); $this->db->from('socio a'); $this->db->join('contas b', 'a.id_socio = b.id_cliente'); $this->db->where('a.tipo', 'P'); $this->db->where('a.situacao', 'A'); // $this->db->where('b.flag','mensalidade'); //$this->db->where('b.checked',0); //$this->db->where('month(b.data_vencimento)', date('m')); $this->db->where('month(b.data_vencimento)', date('m')); $this->db->where('year(b.data_vencimento)', date('Y')); $this->db->where('day(b.data_vencimento)', date('d')); // $this->db->group_by('WEEK(b.data_vencimento)'); // $this->db->order_by('b.data_vencimento','DESC'); //$this->db->limit(1); $query = $this->db->get(); if ($query->num_rows() == 0) { $message = ('Nenhum dado foi encontrado para exibir ou gerar mensalidade hoje'); //exit; } else { $this->db->select('*'); $this->db->from('empresa'); $query2 = $this->db->get()->row(); $email_template = $query2->email_template; foreach ($query->result() as $row) { //print($row->cliente); //echo '<br>'; $next_invoice = date('Y-m-d', strtotime("$row->data_vencimento +5 month")) ; $date_now = date('Y-m-d'); //$date_now = $row->data_vencimento ; echo'<b>'; echo 'Date Maturity => '.$row->data_vencimento; echo '<br>'; echo 'Next date =>'.$next_invoice; echo '<br>'; echo 'Date Now => '.$date_now; echo '<hr> </b>'; /* $arr = array( "%user%" => $row->nome_socio, "%year%" => date('Y') );*/ //$message = strtr($email_template,$arr); if($next_invoice == $date_now) { echo '<b style="color: red;"> => Action Send Invoice </b>'; echo '<b>'; echo 'Next date =>' . $next_invoice; echo '<br>'; echo 'Data now => ' . $date_now; echo '<br> </b>'; $arr = array( "%user%" => $row->nome_socio, "%year%" => date('Y') ); $message = strtr($email_template,$arr); echo $message; //if you set the parameter to TRUE any attachments will be cleared as well //$this->email->clear(TRUE); $this->email->to($row->email);//$row->email $this->email->from('comunicados@dominio.com','Webmaster'); $this->email->subject('Contribuição Anual'); $this->email->message($message); $this->email->send(); //echo $this->email->print_debugger(); } } } } public function gerarMensalidade() { $this->db->select('*'); $this->db->from('socio a'); $this->db->join('contasareceber b', 'a.id_socio = b.id_cliente'); $this->db->where('a.tipo', 'P'); $this->db->where('a.situacao', 'A'); $this->db->where('b.flag', 'mensalidade'); $this->db->order_by('a.nome_socio', 'ASC'); $query = $this->db->get(); foreach ($query->result() as $row) { echo '<pre>'; echo($row->nome_socio . ' - ' . $row->data_vencimento); echo '</pre>'; $userExplode = explode('-', $row->data_vencimento); //data socios //$userDay = $userExplode[2]; $userMonth = $userExplode[1]; // $userYear = $userExplode[0]; //data atual $nowExplode = explode('-', date('Y-m-d')); //data socios //$userDay = $nowExplode[2]; $nowMonth = $nowExplode[1]; // $userYear = $nowExplode[0]; echo $nowMonth . ' == ' . $userMonth; } } public function teste(){ /** Email de notificação**/ $config['protocol'] = 'smtp'; $config['smtp_host'] = 'mail.dominio.com'; $config['smtp_port'] = '587'; $config['smtp_user'] = 'comunicados@dominio.com'; $config['smtp_pass'] = 'Z_tRtKjkil[7zayrythf'; $config['mailtype'] = 'html'; $config['charset'] = 'UTF-8'; $config['wordwrap'] = TRUE; $config['newline'] = "\r\n"; //use double quotes to comply with RFC 822 standard $this->email->initialize($config); $this->email->clear(TRUE); $this->email->to(' '); $this->email->from('comunicados@dominio.com', 'Webmaster'); $this->email->subject('Teste cronjob'); $this->email->message('Teste cronjob'); $this->email->send(); } public function testeEmailMensalidade() { echo '<b style="color: gray;"> => Action Send Invoice Email </b>'; // $data_vencimento = date('2018-02-23');//23/02/2018 // $data_cobranca_formated = date('d-m-Y', strtotime("$data_vencimento +5 month")); // $data_cobranca = date('Y-m-d', strtotime('+5 month', strtotime($data_vencimento))); // // $datas = [ // "Vencimento" => $data_vencimento, // "Cobrança" => $data_cobranca_formated // ]; // // echo $data_cobranca; // // // if($data_cobranca == date('Y-m-d')){ // // //echo 'enviar cobrança'; // } // echo'<code>'; // echo'<pre>'; // print_r($datas); // echo'</pre>'; // echo'</code>'; /** Email de notificação**/ // $config['protocol'] = 'smtp'; // $config['smtp_host'] = 'mail.dominio.com'; // $config['smtp_port'] = '587'; // $config['smtp_user'] = 'comunicados@dominio.com'; // $config['smtp_pass'] = 'Z_tRtKjkil[7xsewq1'; // $config['mailtype'] = 'html'; // $config['charset'] = 'UTF-8'; // $config['wordwrap'] = TRUE; // $config['newline'] = "\r\n"; //use double quotes to comply with RFC 822 standard // // $this->email->initialize($config); $this->db->select('*'); //$this->db->select_max('data_vencimento'); $this->db->from('socio a'); $this->db->join('contas b', 'a.id_socio = b.id_cliente'); $this->db->where('a.tipo', 'P'); $this->db->where('a.situacao', 'A'); // $this->db->where('b.flag','mensalidade'); //$this->db->where('b.checked',0); //$this->db->where('month(b.data_vencimento)', date('m')); $this->db->where('month(b.data_vencimento)', date('m')); $this->db->where('year(b.data_vencimento)', date('Y')); // $this->db->group_by('WEEK(b.data_vencimento)'); // $this->db->order_by('b.data_vencimento','DESC'); //$this->db->limit(1); $query = $this->db->get(); if ($query->num_rows() == 0) { $message = ('Nenhum dado foi encontrado para exibir ou gerar mensalidade hoje'); //exit; } else { foreach ($query->result() as $row) { // $message = '<br>';//19-02-2018 / 2018-02-19 // $message .= 'Nome:'; // $message .= $row->nome_socio." (".$row->id.")"; // // $message .= '<br>'; // $message .= 'Data atual: '; // $message .= date('d/m/Y', strtotime(date('Y-m-d'))); // // $message .= '<br>'; // $message .= 'Vencimento: '; // $message .= date('d/m/Y', strtotime($row->data_vencimento)); // $message .= '<br>'; // // $message .= 'Próxima mensalidade: '; // $message .= date('d/m/Y', strtotime("$row->data_vencimento +5 month")); // $message .= '<hr>'; $next_invoice = date('Y-m-d', strtotime("$row->data_vencimento +5 month")) ; $date_now = date('Y-m-d'); // echo'<b>'; // echo 'Next date =>'.$next_invoice; // echo '<br>'; // echo 'Fake date => '.$date_now; // echo '<br> </b>'; if($next_invoice == $date_now) { echo '<b style="color: red;"> => Action Send Invoice </b>'; echo '<b>'; echo 'Next date =>' . $next_invoice; echo '<br>'; echo 'Data now => ' . $date_now; echo '<br> </b>'; $message = '<p>Prezado (a) Associado (a):&nbsp;<b> ' . $row->nome_socio . ' </b></p> <p>Para que em ' . date(Y) . ' possamos continuar oferecendo nossas palestras, cursos, caminhadas preparat&oacute;rias e eventos sociais, necessitamos de sua generosa contribui&ccedil;&atilde;o anual.</p> '; echo $message; //if you set the parameter to TRUE any attachments will be cleared as well // $this->email->clear(TRUE); // $this->email->to($row->email); // $this->email->from('comunicados@meusite.com', 'Webmaster'); // $this->email->subject('Notificação Mensalidade a receber'); // $this->email->message($message); // $this->email->send(); } } } } }
×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.