Jump to content

deib97

Members
  • Posts

    34
  • Joined

  • Last visited

Posts posted by deib97

  1. Hello, i have source code like this :

    <script type="text/javascript">
    var rowNum = 0;
    function addRow(frm) {
    	rowNum ++;
    	var row = '<p id="rowNum'+rowNum+'">Item name: <input type="text" name="name[]" value="'+frm.add_name.value+'"> Satuan: <input type="text" size="5" name="satuan[]" value="'+frm.add_satuan.value+'"> Item quantity: <input type="text" name="qty[]" size="20" value="'+frm.add_qty.value+'"> <input type="button" value="Remove" onclick="removeRow('+rowNum+');"></p>';
    	jQuery('#itemRows').append(row);
    	frm.add_qty.value = '';
    	frm.add_name.value = '';
            frm.add_satuan.value = '';
    }
    
    function removeRow(rnum) {
    	jQuery('#rowNum'+rnum).remove();
    }
    </script>
    

    This code, for make dynamic row when add operation.

    Then, item name is input text. How change this input :

    <select name="group" class='arial11' id="group">
                        <?php $qdepart = mysql_query("select * from pemakai_group order by group_name asc");
    				  if($qdepart != null){
    				  while($ddepart = mysql_fetch_array($qdepart)){
    				  		$no++;
                      		if( $data[id_group] == $ddepart[id_group] ){ $seldepart[$no] = "selected";}
    						echo "<option value=\"$ddepart[id_group]\" $seldepart[$no]>$ddepart[group_name]</option>";
                      }
    				  }
    				?>
                      </select>
    
  2. I have one table but i try to make like the result not finished.

    Hmm.. can you see my table :

    post-167002-0-28211600-1406042829_thumb.png

    I want to declare sum for parent kd_rekening in same row for "Anggaran" => jns_anggaran =1 and "Perubahan" => jns_anggaran = 2. And child ust load field nilai.
    post-167002-0-36830200-1406043371_thumb.jpg

     

    Thanks before

  3. I was trying for make a query for replace it. Because I dont understand with complex condition i make a query for each condition, but after i append all query each condition to one new table, sum of rows not same like table so2. I has 2 tables : so2 and pl2. maybe can be help me i attach in my dropbox *.sql : so2.sql and pl2.sql

    For distinct pl2 : i use this query :

    SELECT YEAR(`HRG_DATE`) AS Yr, MONTH(`HRG_DATE`) AS Mnth, DAY(`HRG_DATE`) AS Day, COUNT(*) AS Total FROM `pl2` GROUP BY YEAR(`HRG_DATE`), MONTH(`HRG_DATE`)
    

    And this image for describe condition : image

    Sorry i not attach media in here, bandwith killer. :pirate: :pirate:

    And i was make query every condition, this example for no.3(image) like this : (for checking before i hide so2.`PLIDR` , so2.`PLVLS`)

    SELECT so2.`ORJ_DATE` , so2.`CUS_CODE` , so2.`INV_CODE` , so2.`PLIDR` , so2.`PLVLS` , pl2.`HRG_DATE` , pl2.`CUS_CODE` , pl2.`INV_CODE` , pl2.`HRG_NETT` , pl2.`HRG_VALA`
    FROM so2
    INNER JOIN pl2 ON so2.CUS_CODE = pl2.CUS_CODE
    AND so2.INV_CODE = pl2.INV_CODE
    WHERE DATE( so2.ORJ_DATE )
    BETWEEN '2013-01-02'
    AND '2013-06-27'
    ORDER BY so2.ORJ_DATE ASC 
    

    How to make single query like this condition??

    thanks for helping me..

  4. How are you making this report?  Are you just using echo to output line after line after line?  Are you using FPDF?  Are you outputting an html table?

     

    Need more info and maybe some SMALL snippet of relevant code. 

     

    Don't know what those "things" you attached are, but I can't see them.  Did you review your post to see if they were visible to you?

     

    This example was made by the developer first. And now without sufficient documentation that I have to create a new one. I also feel confused with this kind of this report generation.

     

    Here it is from the echo of a table. Maybe if there was a code or library to make report like this.

  5. DROP TRIGGER IF EXISTS `auto_update_tabel_alat`;
    DELIMITER //
    CREATE TRIGGER `auto_update_tabel_alat` AFTER INSERT ON `mutasi_alat`
     FOR EACH ROW update alat set cabang_terakhir=(SELECT
    mutasi_alat.id_cabang
    FROM
    mutasi_alat
    where mutasi_alat.tgl_berlaku=(select max(mutasi_alat.tgl_berlaku) from mutasi_alat where id_alat=NEW.id_alat)) where 
    id=NEW.id_alat
    //
    DELIMITER ;
    

    :happy-04:

  6. Hi, i have 2 table, a table alat and a table mutasi_alat. Every I do action insert to the table mutasi_alat, with a relation alat.id_alat and insert date newer then the value that is in the table mutasi_alat.id_cabang. The table will trigger an update to the table alat.cabang_terakhir.

     

    Table 1 : alat

    tabel_alat.jpg?dl=1&token_hash=AAGypUvtY

     

    Table 2 : mutasi_alat

    tabel_mutasi_alat.jpg?dl=1&token_hash=AA

    I want to be trigger update into table alat after any action insert in table mutasi_alat.

    clue.jpg?dl=1&token_hash=AAFf3nou73ql-D4

     

    Do I have to make a single trigger or storeprocedure with this conditions?

    thanks

  7. Hi Barand,

     

    I try your code :

    CREATE PROCEDURE auto_insert (IN ulang INT)
    BEGIN
        INSERT INTO hari_libur (tgl_libur, keterangan, ulangi)
        SELECT MAX(tgl_libur) + INTERVAL 1 YEAR
            , keterangan
            , 1
        FROM hari_libur
        WHERE ulangi = 1
        GROUP BY CONCAT(MONTH(tgl_libur),DAY(tgl_libur));
    END
    

    CALL auto_insert(1)

     

    Yes, success... But this generate insert all. :(

    Maybe im wrong? cmiiw

    hasil.png?dl=1&token_hash=AAHA4SIawlzV0D

  8. I have table like this :

    CREATE TABLE IF NOT EXISTS `hari_libur` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `tgl_libur` date NOT NULL,
      `keterangan` varchar(64) NOT NULL,
      `ulangi` int(1) DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;
    
    --
    -- Dumping data for table `hari_libur`
    --
    
    INSERT INTO `hari_libur` (`id`, `tgl_libur`, `keterangan`, `ulangi`) VALUES
    (1, '2010-12-25', 'Hari Raya Natal', 1),
    (2, '2010-08-17', 'Proklamasi Kemerdekaan RI', 1),
    (3, '2010-01-01', 'Tahun Baru Masehi', 1),
    (4, '2012-08-19', 'Hari raya Idul Fitri', 0),
    (5, '2012-08-20', 'Hari Raya Idul Fitri', 0);
    
    

    I want to auto insert for "ulangi" = 1 is repeat every year when i call a storeprocedure. How to make it?

    So i dont entry data every start year.

    thanks

  9. How to implement jqrelcopy with timepicker (yiibooster)?

    I writen code like this :

    <?php
             $this->widget('ext.jqrelcopy.JQRelcopy',array(
                'id' => 'copylink',
                'removeText' => 'Remove',
                'removeHtmlOptions' => array('style'=>'color:red'),
                'options' => array(
                     'copyClass'=>'newcopy',
                     'limit'=>3,
                     'clearInputs'=>true,
                     'excludeSelector'=>'.skipcopy',
    //                 'append'=>CHtml::tag('span',array('class'=>'hint'),'You can remove this line'),
                  )
               ));
            ?>
             <div class="control-group "><label class="control-label required">Jam Kerja</label>
                 <div class="controls">
                    <a id="copylink" href="#" rel=".copy">Tambah Jam Kerja / Shift</a>
                    <div class="row copy">
                        <?php echo CHtml::label('',''); ?>
                        <?php $this->widget('bootstrap.widgets.TbTimePicker',
                                array(
                                'name' => 'some_time',
                                'value' => '00:00',
                                'htmlOptions'=>array('width'=>'50px'),    
                                'noAppend' => true, // mandatory
                                'options' => array(
                                'disableFocus' => true, // mandatory
                                'showMeridian' => false // irrelevant
                                ),    
                                )
                                );
                        ?>
                        <?php 
                            $this->widget('bootstrap.widgets.TbTimePicker',
                                array(
                                'name' => 'some_time',
                                'value' => '00:00',
                                'noAppend' => true, // mandatory
                                'options' => array(
                                'disableFocus' => true, // mandatory
                                'showMeridian' => false // irrelevant
                                )
                                )
                                );
                        ?>
                    </div>
                </div>
                   </div>   
    

    But the result shown like this :

    default_onchange.jpg?_subject_uid=152431

     

    The picker cannot flew on field 3. always default field 1.

  10. I want to input holiday once for next every year. How to schedule a yearly repeating holiday when i change year?. example : Xmas

    I have a code :

    <?php
    for($i=2013; $i<=2020; $i++)
    {
      $datetime = new DateTime("$i-12-25 00:00:00");
         echo "25 Dec $i<br>";
    }
    ?>
    
  11. Based on excel for pattern 14/1,

    Shift	1 2 2 2 2 2 2 2 Off 1 1 1 1 1 1 2 2 2 2 2 2 2 Off 1 1 1 1 1 1 2 2
    

    How to choose shift_start 1 or 2?? 

    I change and modify your code become to :

    1 1 1 1 1	1  Off Off  Off	Off	Off	Off	Off	Off	2  2	2 2	2 2	Off	Off	Off	Off	Off	Off	Off	Off	1 1 1
    
  12. Hmm,,, please, you can try this bro..

    this tes.php

    <form action="shift.php" method="POST">
        Tanggal : <input type="text" name="tanggal" value="" /> <!--date value ex: 2014-01-01-->
        <br> 
        Hari ke : <select name="hari_ke"> 
            <!--this for Lembur, i was change to variable, thanks for support
            // array for lembur on line 4
            $seq['lembur'] = array();
            $seq['lembur'][0]  = 4, if selected 4 ;
            $seq['kerja2']  = array();
            $seq['kerja2'][0]  = 4, if selected 4 ;
            -->
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
        </select><br>
        Shift : <select name="shift"> 
            <option value="1">1</option> 
            <!--if this value selected, "shift mulai" must default to 1, patern pola shift 7/1
        1 1 1 Off 1 1 1 1 1	1 Off 1	1 1 1 1	1 Off 1	1 1 1 1	1 Off 1	1 1 1 1	1
            -->
            <option value="2">2</option>
            <!--if this value selected, "shift mulai" must default to 1, patern pola shift 7/1
        2 2 2 Off 2 2 2 2 2	2 Off 2	2 2 2 2	2 Off 2	2 2 2 2	2 Off 2	2 2 2 2	2
            -->
            <option value="3">1 dan 2</option>
            <!--if this value selected, "shift mulai", can be change to 1 or 2 in shift mulai
            -->
        </select> *if selected 1, must be default or automatically "shift mulai" is 1,<br> *if selected 2, must be default or automatically "shift mulai" is 2,<br> *if selected 1 and 2, must be can change "shift mulai" to 1 or 2
        <br>
        Shift mulai : <select name="shift_mulai"> 
            <option>1</option>
            <!--if this value selected, based on shift value 3 => 1 dan 2, shift start for 1 and continue to 2, patern pola shift 7/1
        1 1 1 Off 2 2 2 2 2 2 Off 1 1 1 1 1 1 Off 2 2 2 2 2 2 Off 1 1 1 1 1 1
            -->
            <option>2</option>
            <!--if this value selected, based on shift value 3 => 1 dan 2, shift start for 2 and continue to 1, patern pola shift 7/1
        2 2 2 Off 1 1 1 1 1 1 Off 2 2 2 2 2 2 Off 1 1 1 1 1 1 Off 2 2 2 2 2 2
            -->
        </select> <br>
        Pola : <select name="pola_shift">
            <option value="1">7/1</option>
            <option value="2">14/1</option>
        </select><br><input type="submit" value="submit" />
    </form>
    

    and shift.php

    <?php
      $datei=$_POST["tanggal"];
      $day_number=$_POST["hari_ke"];
      $shift=$_POST["shift"];
      $shift_start=$_POST["shift_mulai"];
      $pattern_shift=$_POST["pola_shift"];
      
      if ($pattern_shift == 1) {
          $hpattern=7;
      }
      else
      {
          $hpattern=14;
      }
      date_default_timezone_set('UTC');  
      $hasil = explode("-", $datei); 
      $hasil[2]; // day
      $hasil[1]; // month
      $d1=$hasil[2];
      $m1=$hasil[1];
      $y1=$hasil[0];
      $num = cal_days_in_month(CAL_GREGORIAN, $m1, $y1);
      $d2 = $num;
     /* $m2 = $m1;
      $y2 = $y1;
      $start_date = array($y1,$m1,$d1);
      $implode1 = implode("-", $start_date);
       $end_date = array($y2,$m2,$d2);
      $implode2 = implode("-", $end_date);
      while(strtotime($implode1) <= strtotime($implode2))
      {
    	echo "$implode1 - ? <br>";
    	$implode1 = date ("Y-m-d", strtotime("+1 day", strtotime($implode1)));
      } */
      
    // array for lembur sequane
    $seq['lembur'] = array();
    $seq['lembur'][0]  = $day_number;
    
    // array for kerja sequance
     $seq['kerja']  = array();
    $seq['kerja'][0]  = $day_number; 
    
    //$seq['kerja2']  = array();
    //$seq['kerja2'][0]  = 4;
    
    // array for shift sequance
    $seq['shift']  = array();
    //$seq['shift2']  = array();
    
    // the max number foreach sequance , 'kerja2' => 7
    $seqances = array('lembur' => 7, 'kerja' => $hpattern);
    $x=0;
    // generate the sequances
    for($i = 0; $i < $d2; $i++)
    {
        // generate the number sequances for lembur and kerja
        foreach($seqances as $key => $maxSeq)
        {
            // if current postion is set, then skip it
            if(isset($seq[$key][$i]))
                continue;
    
            // get previous number in current squance
            $num = $seq[$key][$i - 1] + 1;
    
            // is number greater than the max sequance number
            // reset sequance
            if($num > $maxSeq)
                $num -= $maxSeq;
    
            // add number to current sequance
            $seq[$key][$i] = $num;
        }
        
        if ($hpattern== 7 ){
            if($seq['kerja'][$i] < 7)
            $shift = $shift_start;
        else
            $shift = 'Off';
            
        } else if ($hpattern=14) {
        // the shift sequance
        if($seq['kerja'][$i] < 7)
            $shift = $shift_start;
        elseif($seq['kerja'][$i] < 14)
            $shift = $shift_start;
        else
            $shift = 'Off';
        }
    //	if($seq['kerja2'][$i] < 7)
    //        $shift2 = ($x % 2 == 0) ? 2 : 1; // alternate between 2 and 1
    //    elseif($seq['kerja2'][$i] == 7) {
    //        $shift2 = 'Off';
    //        $x++; // increment x for each 'Off'
    //    }	
    		
        $seq['shift'][$i]  = $shift;
    //	$seq['shift2'][$i]  = $shift2;
    }
    ?>
    <style>
        th { color: red; width: 20px;}
        td { text-align: center; }
    </style>
    <table>
        <tr>
            <th>Tanggal</th>
            <th><?php echo implode('</th><th>', range(1, $d2)); ?></th>
        </tr>
    <?php foreach($seq as $key => $sequance): ?>
        <tr>
            <td><?php echo ucwords($key) ?></td>
            <td><?php echo implode('</td><td>', $sequance); ?></td>
        </tr>
    <?php endforeach; ?>
    </table>
    

    with your code,  :

    $x=0 before looping

    	if($seq['kerja2'][$i] < 7)
            $shift2 = ($x % 2 == 0) ? 2 : 1; // alternate between 2 and 1
        elseif($seq['kerja2'][$i] == 7) {
            $shift2 = 'Off';
            $x++; // increment x for each 'Off'
        }	
    

    The result  will be shown :

    Shift2  2 2 Off 1 1 1 1 1 1 Off 2 2 2 2 2 2 Off 1 1 1 1 1 1 Off 2 2 2 2 2 2 Off
    

    And i want to change shift start to 1 and continue to 2; or shift start to 2 and continue to 1

    Maybe with a bit of explanation may help you to help me.

    thanks

    im stuck :

  13.  

    Add   $x = 0;   before the for loop

     

    Now change the shift2 code to

        if($seq['shift2'][$i] < 7)
            $shift2 = ($x % 2 == 0) ? 2 : 1; // alternate between 2 and 1
        elseif($seq['shift2'][$i] == 7) {
            $shift2 = 'Off';
            $x++; // increment x for each 'Off'
        }

    The result become 2 all.. where i put variable x?

    before this? 

    for($i = 0; $i < 31; $i++)
    
    
  14. Hi, Cho0cu3r

    I have combination again. Im happy and try your code, but when I try to merge with my combination, the result not same with my simulation. How to change shift if pattern switch to 7/1 : 6x day 1 off  with dinamic shift 1 or 2.

    inputan.jpg?dl=1&token_hash=AAFJsoZjMRyn

    This my code :

    <?php
    
    // array for lembur sequane
    $seq['lembur'] = array();
    $seq['lembur'][0]  = 5;
    
    // array for kerja sequance
    $seq['kerja']  = array();
    $seq['kerja'][0]  = 6;
    
    $seq['kerja2']  = array();
    $seq['kerja2'][0]  = 5;
    
    // array for shift sequance
    $seq['shift']  = array();
    $seq['shift2']  = array();
    
    // the max number foreach sequance
    $seqances = array('lembur' => 7, 'kerja' => 14, 'kerja2' => 7);
    
    // generate the sequances
    for($i = 0; $i < 31; $i++)
    {
        // generate the number sequances for lembur and kerja
        foreach($seqances as $key => $maxSeq)
        {
            // if current postion is set, then skip it
            if(isset($seq[$key][$i]))
                continue;
    
            // get previous number in current squance
            $num = $seq[$key][$i - 1] + 1;
    
            // is number greater than the max sequance number
            // reset sequance
            if($num > $maxSeq)
                $num -= $maxSeq;
    
            // add number to current sequance
            $seq[$key][$i] = $num;
        }
    
        // the shift sequance
        if($seq['kerja'][$i] < 7)
            $shift = 1;
        elseif($seq['kerja'][$i] < 14)
            $shift = 2;
        else
            $shift = 'Off';
    
    	if($seq['kerja2'][$i] < 7)
            $shift2 = 2;  // change automatically 1 or 2 after off
        else
            $shift2 = 'Off';	
    		
        $seq['shift'][$i]  = $shift;
    	$seq['shift2'][$i]  = $shift2;
    }
    ?>
    <style>
        th { color: red; width: 20px;}
        td { text-align: center; }
    </style>
    <table>
        <tr>
            <th>Tanggal</th>
            <th><?php echo implode('</th><th>', range(1, 31)); ?></th>
        </tr>
    <?php foreach($seq as $key => $sequance): ?>
        <tr>
            <td><?php echo ucwords($key) ?></td>
            <td><?php echo implode('</td><td>', $sequance); ?></td>
        </tr>
    <?php endforeach; ?>
    </table>
    

    Based on your experience, Wheter such transactions should be stored in a database, with the target job to calculate the salary and overtime?

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.