Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include '../koneksi.php';
- include "../classes/class.phpmailer.php";
- $id=mysqli_real_escape_string($koneksi, $_GET['id']);
- $query = mysqli_query($koneksi, "SELECT * FROM mkt_activity JOIN master_mkt ON mkt_activity.ID_MKT = master_mkt.ID_MKT JOIN master_customer ON mkt_activity.ID_CST = master_customer.AccNo JOIN dtl_activity ON mkt_activity.id = dtl_activity.id WHERE mkt_activity.id='$id'");
- if ($query)
- {
- while ($result = mysqli_fetch_array($query))
- {
- $visit = $result['ID_VISIT'];
- $marketing = $result['MKT_NAME'];
- $company = $result['CompanyName'];
- $contact = $result['NAME_CONTACT'];
- $departement = $result['NAME_DEPT'];
- $purpose = $result['PURPOSE'];
- $model= $result['MODEL'];
- $headmail = "Dear Mr. Edwin Indradjaja <br><br> Today I Visit " . $contact . ", Departement " . $departement . ", " . $company . ", For " . $purpose . " <br><br>Detail Order : <br><br>";
- $footermail = " Detail Visit History, please open <a href= 'http://srp.pt-armstrong.co.id/newmodel/tampil_newmodel@@.php?id=" . $id . "'>Detail</a><br><br>Thank You <br> Best Regards <br><br><br>" . $marketing;
- }
- $mail = new PHPMailer;
- $mail->IsSMTP();
- $mail->SMTPSecure = 'ssl';
- $mail->Host = "mail.google.com"; //host masing2 provider email
- $mail->SMTPDebug = 2;
- $mail->Port = 465;
- $mail->SMTPAuth = true;
- $mail->Username = "esales.ptai@gmail.com"; //user email
- $mail->Password = "12345678"; //password email
- $mail->SetFrom("nendies.pb@gmail.com","eSales Armstrong"); //set email pengirim
- $mail->Subject = "Visit Report " . $purpose . " : " . $model ; //subyek email
- $mail->AddAddress("esales@pt-armstrong.co.id"); //tujuan email
- $mail->AddCC("nendies@gmail.com"); //tujuan CC
- $mail->isHTML(true);//Set email to Format Html
- $mail->Body = $headmail . "<table border=1>
- <tr>
- <th>No</th>
- <th>Part Code</th>
- <th>Model</th>
- <th>Qty Prod</th>
- <th>Life Time</th>
- <th>Qty/Month</th>
- <th>Start Mas Pro</th>
- <th>Remarks</th>
- </tr>";
- $query = mysqli_query($koneksi, "SELECT * FROM dtl_activity LEFT JOIN mkt_activity ON dtl_activity.id = mkt_activity.id JOIN master_mkt ON mkt_activity.ID_MKT = master_mkt.ID_MKT JOIN master_customer ON mkt_activity.ID_CST = master_customer.AccNo WHERE mkt_activity.id='$id'");
- $num=1;
- while ($result = mysqli_fetch_array($query))
- {
- $itemcode=$result['ITEM_CODE'];
- $model=$result['MODEL'];
- $qprod=$result['QTY_PRD'];
- $lifetime=$result['LIFE_TIME'];
- if ($lifetime!=0) {
- $qmonth=$qprod/$lifetime;
- $qmonth=$qmonth;
- }
- else
- $qmonth="-";
- $qmonth=round($qmonth,0);
- $startmaspro=$result['START_MASPRO'];
- $remarks=$result['REMARKS'];
- $mail->Body .= "
- <tr>
- <td align='right'>" . number_format($num) . "</td>
- <td>" . $itemcode . "</td>
- <td>" . $model . "</td>
- <td align='right'>" . number_format($qprod) . "</td>
- <td align='right'>" . number_format($lifetime) . "</td>
- <td align='right'>" . number_format($qmonth) . "</td>
- <td align='right'>" . date('d-m-Y', strtotime($startmaspro)) . "</td>
- <td>" . $remarks . "</td>
- </tr>";
- $num++;
- }
- $mail->Body .= "</table><br><br>" . $footermail ;
- if($mail->Send())
- echo "Message has been sent ";
- else echo "Failed to sending message";
- echo
- "<script>alert('Success'),window.open('detail_newmodel.php?id=".$id."','_SELF')</script>";
- }
- else
- {
- echo
- "
- <script>alert('Maaf Gagal Tambah Data'),window.open('detail_newmodel.php?id=".$id."','_SELF')</script>
- ";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement